Korodic Posted July 7, 2011 Share Posted July 7, 2011 (edited) Do variables save their previous data? How do they store data? Here is what I'm working on.... short StateVar short DoCode set DoCode to 1 if (StateVar==0) && (DoCode==1) JDDeskREF.setopenstate 1 set StateVar to 1 set DoCode to 0 endif if (StateVar==1) && (DoCode==1) JDDeskREF.setopenstate 0 set StateVar to 0 set DoCode to 0 endif end But the issue with this code is that the desk opens (meaning the variable state must default to zero) but it doesn't open, which makes me believe that when I set state to 1, that it isn't saving the data for the next time I press the activator (the option on the terminal). Edited July 7, 2011 by Skibblets Link to comment Share on other sites More sharing options...
PaladinRider Posted July 7, 2011 Share Posted July 7, 2011 (edited) Do variables save their previous data? How do they store data? Here is what I'm working on.... short StateVar short DoCode set DoCode to 1 if (StateVar==0) && (DoCode==1) JDDeskREF.setopenstate 1 set StateVar to 1 set DoCode to 0 endif if (StateVar==1) && (DoCode==1) JDDeskREF.setopenstate 0 set StateVar to 0 set DoCode to 0 endif end But the issue with this code is that the desk opens (meaning the variable state must default to zero) but it doesn't open, which makes me believe that when I set state to 1, that it isn't saving the data for the next time I press the activator (the option on the terminal). Not fully sure what you're trying to do. I think 'setopenstate' is only for doors. Just try JDDeskREF.activate. The variable 'DoCode' isn't really doing anything for you. If this script is run on an activator - using a Begin OnActivate block, the script will only run once anyway. If it is a Begin GameMode, you are setting DoOnce to 1 every frame, and then immediately checking if DoOnce is 1, which it always is. It is my understanding that Quest scripts will hold their variable value as long as the quest is running. Objects with a script will have their own individual values. (IE: Two Desks with that script, Desk1's StateVar will not necessarily equal Desk2's StateVar Edited July 7, 2011 by PaladinRider Link to comment Share on other sites More sharing options...
Korodic Posted July 7, 2011 Author Share Posted July 7, 2011 (edited) It is an overseer's desk. Yes, the openstate command is what makes the desk open correctly. I have tried to use the activate, I haven't used any type of blocks as of yet. I will experiential with those. The DoCode is in place because if I didn't have it, then it would instantly close/open the object beneath it. (DoCode makes sure each code is done once per activation). StateVar was meant to hold the value of whether the desk was opened or closed. So the button would do the opposite of the current state. EDIT: I see in vault 11 that they used a quest to change the variable. EDIT2: OK SO I HAVE TRIED THIS 100 F***ING WAYS. The devs also noted in vault 11 that the door needs a work around as getopenstate doesnt work correctly in this case. >:( Edited July 7, 2011 by Skibblets Link to comment Share on other sites More sharing options...
nosisab Posted July 7, 2011 Share Posted July 7, 2011 (edited) Do variables save their previous data? How do they store data? Here is what I'm working on.... short StateVar short DoCode set DoCode to 1 if (StateVar==0) && (DoCode==1) JDDeskREF.setopenstate 1 set StateVar to 1 set DoCode to 0 endif if (StateVar==1) && (DoCode==1) JDDeskREF.setopenstate 0 set StateVar to 0 set DoCode to 0 endif end But the issue with this code is that the desk opens (meaning the variable state must default to zero) but it doesn't open, which makes me believe that when I set state to 1, that it isn't saving the data for the next time I press the activator (the option on the terminal). The first test, the ...&& DoCode is meaningless since you are setting the variable to 1 just before. Local variables keep the setting all the while the script is running but will reset in between gaming sessions. So that code chunk works this way (don't taking into account the function itself) the first time, the first block run and StateVar becomes 1 and DoCode is made 0 ... the script continues and the second "if" is not done The second pass, the first if block is skipped and the second is performed ... The third pass, the first block is performed again (notice than setting the DoCode to 0 is meaningless, because the first set DoCode to 1 and you are in loop. Now, lets analyze what you want to do... to force DoCode to 1 "once" and only once you could use another variable, lets call it DoOnce and do If DoOnce == 0 Set DoOnce to 1 Set DoCode to 1 Endif If using OBSE and DoCode is to be initialized only once per game session you should use GetGameLoaded and or GetGameRestarted functions. Still, I don't know what is the script block mode, is reasonable to assume it is an OnActivate and you want to toggle the state...To me seen simpler if you get it's state before anything else: GetOpenState --- and do whatever you want based on the value it returns 0 = none (not a door) 1 = open 2 = opening 3 = closed 4 = closing Edited July 7, 2011 by nosisab Link to comment Share on other sites More sharing options...
Recommended Posts