Jump to content
Sign in to follow this  
Galactygon

AddGlobals()

Recommended Posts

The scripting action AddGlobals() only works for "GLOBAL" variables. This action does nothing for "LOCALS" or "MYAREA" or any other type of variable that is not a "GLOBAL" variable.
This example from the IESDP works

IF
  Global("Var1","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobal("Var1","GLOBAL",75) //Var1 = 75
    SetGlobal("Var2","GLOBAL",25) //Var2 = 25
    AddGlobals("Var1","Var2") //Var1 = 100
END
But this does not:


IF
  Global("Var1","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("Var1","LOCALS",75) //Var1 = 75
    SetGlobal("Var2","LOCALS",25) //Var2 = 25
    AddGlobals("Var1","Var2") //Var1 will still be set to 75
END
Edited by Galactygon

Share this post


Link to post

So this is like IncrementGlobal but able to use a GLOBAL variable instead of an integer?

 

I don't understand this question. All the involved variables are integer.

Share this post


Link to post
So this is like IncrementGlobal but able to use a GLOBAL variable instead of an integer?

 

Yes.

Share this post


Link to post

 

So this is like IncrementGlobal but able to use a GLOBAL variable instead of an integer?

 

I don't understand this question. All the involved variables are integer.

 

Ard got me, but yes, I meant literally "GLOBAL" in the script instead of a fixed modder-written number.

Share this post


Link to post

Ah yes. addglobals adds 2 global variables. But you don't have to (and can't) specify the scope (GLOBAL).

Share this post


Link to post
Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×