Alex L.
said:
Konrad J.
said:
Alex L.
said:
state = {};
DO NOT DO THIS IN A NORMAL SCRIPT EVER!!!!!
Hmm, I tried that and I thought it gave an error. I'll have to try that again. I see why you should not do it in a script others might use, you would erase objects other scripts might have stored. So that brings up another question.
How would you just delete objects your script created? Sort of like a cleanup or a reset command.
delete state.myObj; That should work, but you might want to consider namespaceing your state so have state.konrad = {}; then use state.konrad in place of state
Ya, all my globals are namespaced with fwGlobal, I guess some other script could use that same name possible. Maybe I'll make it a little more distinct. Perfect I'll try that delete. THanks! Any ideas on the code above why "if (fwGlobal in state)" never seems to come out false? I'm trying to make sure the fwGlobal exists in state, if not then I create it. It always comes up false so it always recreates it, writing over all the variables with defaults, "state.fwGlobal = fwGlobal". It should only come up false once, the rest should be true so it can read all the globals from state. Its gotta be something stupid I'm doing?