Jump to content

Problems with globals.


antstubell

Recommended Posts

Having an issue with assigning values to globals. This function is part of a large script but this is the part that is the problem. Properties are there just I didn't show them here.

So the variable SMTgv_ShrineTempValHolder holds a value temporarily depending on which shrine has been activated. I've tested this variable and it does change depending on the shrine activated 1, 2, 3/

The variables SMTgv_ShrineActivated01, SMTgv_ShrineActivated02 and SMTgv_ShrineActivated03 (not seen here because I hit the problem) will then store the value of the most recently activated shrine.

What I intended the script to do was that if SMTgv_ShrineActivated01 was 'empty' default is 0 then it would store the value of the last activated shirne. Then next time this function is called if SMTgv_ShrineActivated01 is 'filled' not a value of 0 then SMTgv_ShrineActivated02 will store the most recently activated shrine value.

In essence the 3 global values between them will have stored a 3 digit 'code'. 1,2,3 or 231 or 321 etc. These values can be checked later to do other stuff.

Problem - The first shrine activated, say it gives a value of 2, is stored in SMTgv_ShrineActivated01 but on checking in console SMTgv_ShrineActivated02 also has a value of 2.

Need help on this, again it could be script blindness - been on this script for hours.

 

 

Function AssignVal()
debug.notification("Assigning a Value.")

If SMTgv_ShrineActivated01.GetValue() == 0; if the first value is not set > set the first value
SMTgv_ShrineActivated01.SetValue(SMTgv_ShrineTempValHolder.GetValue())
EndIf
If (SMTgv_ShrineActivated01.GetValue() != 0) && (SMTgv_ShrineActivated02.GetValue() == 0)
SMTgv_ShrineActivated02.SetValue(SMTgv_ShrineTempValHolder.GetValue())
EndIf

EndFunction

 

Link to comment
Share on other sites

No, it's not that. Changed function to this but still second global takes the same value as the first.

 

Function AssignVal()
debug.notification("Assigning a Value.")

If SMTgv_ShrineActivated01.GetValue() == 0; if the first value is not set > set the first value
SMTgv_ShrineActivated01.SetValue(SMTgv_ShrineTempValHolder.GetValue())
Utility.Wait(1)
ElseIf (SMTgv_ShrineActivated01.GetValue() != 0) && (SMTgv_ShrineActivated02.GetValue() == 0)
SMTgv_ShrineActivated02.SetValue(SMTgv_ShrineTempValHolder.GetValue())
EndIf

EndFunction

 

 

EDIT

Fixed it. As I said it is a long script so I guessed that somewhere earlier in the script a variable was not resetting or resetting at the wrong point. I amended the function to the following and now it works. Not sure if the utility.Wait is necessary now but not hurting.

 

Function AssignVal()
debug.notification("Assigning a Value.")

If SMTgv_ShrineActivated01.GetValue() == 0; if the first value is not set > set the first value
SMTgv_ShrineActivated01.SetValue(SMTgv_ShrineTempValHolder.GetValue())
Utility.Wait(0.5)
ElseIf (SMTgv_ShrineActivated01.GetValue() != 0) && (SMTgv_ShrineActivated02.GetValue() == 0)
SMTgv_ShrineActivated02.SetValue(SMTgv_ShrineTempValHolder.GetValue())
EndIf
Utility.Wait(0.5)
SMTgv_ShrineTempValHolder.SetValue(0)

EndFunction

 

Edited by antstubell
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...