Author Topic: A very basic scripting question  (Read 409 times)

Legacy_LostChangeling

  • Newbie
  • *
  • Posts: 49
  • Karma: +0/-0
A very basic scripting question
« on: April 03, 2015, 08:37:24 pm »


               

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?  '<img'>



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
A very basic scripting question
« Reply #1 on: April 03, 2015, 09:00:50 pm »


               

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


if(abc<4)


  {


  abc++;


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


  }



               
               

               
            

Legacy_LostChangeling

  • Newbie
  • *
  • Posts: 49
  • Karma: +0/-0
A very basic scripting question
« Reply #2 on: April 04, 2015, 04:59:37 am »


               

Yup, it worked nicely. Thanks, mate!  '<img'>


 


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?



               
               

               
            

Legacy_LostChangeling

  • Newbie
  • *
  • Posts: 49
  • Karma: +0/-0
A very basic scripting question
« Reply #3 on: April 04, 2015, 09:22:05 am »


               

Just found out elsewhere that the answer is yes. But thanks for your kind help all the same, friends!  '<img'>