antstubell Posted September 4, 2021 Share Posted September 4, 2021 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 valueSMTgv_ShrineActivated01.SetValue(SMTgv_ShrineTempValHolder.GetValue())EndIfIf (SMTgv_ShrineActivated01.GetValue() != 0) && (SMTgv_ShrineActivated02.GetValue() == 0)SMTgv_ShrineActivated02.SetValue(SMTgv_ShrineTempValHolder.GetValue())EndIfEndFunction Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 4, 2021 Share Posted September 4, 2021 Use ElseIf in between them. I believe the Set is not taking place fast enough for the second block's Get and thus also returning true the first time around and setting the second global. Link to comment Share on other sites More sharing options...
antstubell Posted September 5, 2021 Author Share Posted September 5, 2021 (edited) 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 valueSMTgv_ShrineActivated01.SetValue(SMTgv_ShrineTempValHolder.GetValue())Utility.Wait(1)ElseIf (SMTgv_ShrineActivated01.GetValue() != 0) && (SMTgv_ShrineActivated02.GetValue() == 0)SMTgv_ShrineActivated02.SetValue(SMTgv_ShrineTempValHolder.GetValue())EndIfEndFunction EDITFixed 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 valueSMTgv_ShrineActivated01.SetValue(SMTgv_ShrineTempValHolder.GetValue())Utility.Wait(0.5)ElseIf (SMTgv_ShrineActivated01.GetValue() != 0) && (SMTgv_ShrineActivated02.GetValue() == 0)SMTgv_ShrineActivated02.SetValue(SMTgv_ShrineTempValHolder.GetValue())EndIfUtility.Wait(0.5)SMTgv_ShrineTempValHolder.SetValue(0)EndFunction Edited September 5, 2021 by antstubell Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 5, 2021 Share Posted September 5, 2021 Glad you found a solution. Link to comment Share on other sites More sharing options...
Recommended Posts