Weird errors

Posted by Saiyr on Sun 31 Aug 2003 08:33 PM — 6 posts, 20,583 views.

USA #0
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?
Greece #1
It would help if you pasted the code or something...
USA #2
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 );
}
USA #3
I forgot to say, /add_battle() works in a trigger and /format_number() doesn't.
Australia Forum Administrator #4
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.
USA #5
Ah, I thought you needed slashes, and it worked for one but not the other. It works now, thanks.