Gammon Forum
Entire forum
MUSHclient
Jscript
Weird errors
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Saiyr
USA (6 posts) bio
|
Date
| Sun 31 Aug 2003 08:33 PM (UTC) |
Message
| I made two functions within a *.jvs file. One was to constantly update a world variable by adding a number that set off a trigger. The other was to display that number at the end of combat. The first function works fine, it's simple. However, the second one is a bit odd. It doesn't execute from a trigger. It says:
Error number: -2146827276
Event: Execution of line 1 column 12
Description: Expected '/'
Line in error:
/fmt_numb()
Called by: Immediate execution
I don't see why it needs another '/', but I tried //fmt_numb(), and that didn't work either. It /does/, however, work when I manually type it in. Can someone help? | top |
|
Posted by
| Poromenos
Greece (1,037 posts) bio
|
Date
| Reply #1 on Sun 31 Aug 2003 11:12 PM (UTC) |
Message
| It would help if you pasted the code or something... |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | top |
|
Posted by
| Saiyr
USA (6 posts) bio
|
Date
| Reply #2 on Mon 01 Sep 2003 12:54 AM (UTC) |
Message
| function format_number()
{
var input;
var output = "";
var k = 0;
var i = 0;
var inlen = 0;
var input2 = parseInt( world.GetVariable( "battle" ) ).toString();
var input = input2.split('');
inlen = input.length % 3;
for( i = k = 0; i < input.length; i++, k++ )
{
if( i != 0 && ( i - inlen ) % 3 == 0 )
{
output[k] = ',';
k++;
output[k] = input[i];
output += ',';
output += input[i];
}
else
output += input[i];
}
world.note( "You gained a total of " + output + " power level." );
world.SetVariable( "battle", 0 );
}
function add_battle()
{
var addition = GetVariable("temp");
addition.replace(/,/g, "");
world.SetVariable( "battle", parseInt(world.GetVariable( "battle" )) + parseInt( addition ) );
world.SetVariable("temp", 0 );
} | top |
|
Posted by
| Saiyr
USA (6 posts) bio
|
Date
| Reply #3 on Mon 01 Sep 2003 12:58 AM (UTC) |
Message
| I forgot to say, /add_battle() works in a trigger and /format_number() doesn't. | top |
|
Posted by
| Nick Gammon
Australia (22,985 posts) bio
Forum Administrator |
Date
| Reply #4 on Mon 01 Sep 2003 08:00 AM (UTC) |
Message
| Can you copy and paste the trigger? However on the face of it, you should be sending to "script" and not have any slashes, let alone two of them. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Saiyr
USA (6 posts) bio
|
Date
| Reply #5 on Mon 01 Sep 2003 07:24 PM (UTC) |
Message
| Ah, I thought you needed slashes, and it worked for one but not the other. It works now, thanks. | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
13,902 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.