Aller au contenu

Photo

A very basic scripting question


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
LostChangeling

LostChangeling
  • Members
  • 25 messages

Suppose I have an integer variable declared beforehand in Module Properties --> Advanced --> Variables, like say 'abc'. With a value of 0 at first. Suppose I want this variable to increase by 1 everytime my PC completes some quest, until it reaches say 4. Thus each time a quest is completed a script will be run which goes:

 

If abc is less than 4, then increase it by 1.

 

How do you translate this into NWScript? I believe I did something like this before, except I can't remember now how I did it. I'm sure it can't be just like this:

 

if abc < 4

abc += 1;

 

No, I need to declare abc in some way, if I remember correctly. So how do you script this? Help, please?  ;)



#2
WhiZard

WhiZard
  • Members
  • 1 204 messages

int abc = GetLocalInt(GetModule(), "VariableName");

if(abc<4)

  {

  abc++;

  SetLocalInt(GetModule(), "VariableName", abc);

  }


  • pamelahoward et LostChangeling aiment ceci

#3
LostChangeling

LostChangeling
  • Members
  • 25 messages

Yup, it worked nicely. Thanks, mate!  :D

 

By the way, if double plus means to increase the variable's value by one, does double minus likewise mean to decrease it by one?



#4
LostChangeling

LostChangeling
  • Members
  • 25 messages

Just found out elsewhere that the answer is yes. But thanks for your kind help all the same, friends!  ;)


  • Verilazic aime ceci