Question about variables

Posted by Shaun Biggs on Tue 31 Jul 2001 08:59 PM — 3 posts, 10,961 views.

USA #0
I'm trying to have a script check flags to see if I have already cast certain spells. Every time I try to assign or compare the variables I get error messages about type mismatches or not being able to assign data into that variable type.

I have been trying one of these two methods:
world.getVariable( "zSpellAff_armor" ) = "true";
if ( world.getVariable( "zSpellAff_armor" ).isEqual( "true" ) )...


world.getVariable( "zSpellAff_armor" ) = 1;
if ( world.getVariable( "zSpellAff_armor" ) == 1 )...

What am I doing wrong with both of these, and how can I fix it?
Australia Forum Administrator #1
I presume that the first line in each example is supposed to set the variable, not get it? I also presume you are using JScript here? They should read:



world.setVariable( "zSpellAff_armor", "true" );

if ( world.getVariable( "zSpellAff_armor" ) == "true" ) ...


In the first line, the value to set must be inside the function call. In the second line, you simply test for '== "true"' - you don't have to use IsEqual.



world.setVariable( "zSpellAff_armor", 1);

if ( world.getVariable( "zSpellAff_armor" ) == 1 ) ...


My earlier remarks apply to line 1 above, the second line was fine.

Amended on Tue 31 Jul 2001 10:49 PM by Nick Gammon
USA #2
Didn't notice the SetVariable command. Thank you very much for helping me out. Since you seem to know just about everything, do you know how I can get this Michael Jackson song out of my head?