Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Jscript ➜ Weird errors

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  (23,169 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.


19,122 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.