Euflorium: The Eufloria Community

Eufloria => Eufloria Classic => Eufloria Classic Support => Topic started by: annikk.exe on December 31, 2010, 09:31:47 AM

Title: Problem with function LevelDraw()
Post by: annikk.exe on December 31, 2010, 09:31:47 AM
Hello,

When I declare a variable in my function LevelDraw(), and run the level, it works fine.
But then, if I quit and reload the level, all the variables that were learned from the previous time I played are still there!

This is a problem because it stops new things being procedurally generated.  When the level loads, I want to say "if init == nil then" run a whole bunch of math.randoms to procedurally generate stuff, as well as setting "init" to = 1.  That way the code should only be run once.  But when I do this inside a LevelDraw, it remembers the values of all variables between plays.  :/


This is hard problem to explain..  :P
Title: Re: Problem with function LevelDraw()
Post by: Pilchard123 on December 31, 2010, 05:05:47 PM
Stick something like

if (Quit(true) or Quit(false)) then
init = nil
end

in your LevelLogic. That code probably won't work, but I hope it explains what I mean. Basically, check if the level is quit, then reset init.
Title: Re: Problem with function LevelDraw()
Post by: Alex on January 01, 2011, 03:34:14 AM
Currently unsure if just putting "all your variables = nil" at the end of your level logic function will work (execution may be interrupted after a call to Quit()) but if so then in future I will add LevelShutdown
Title: Re: Problem with function LevelDraw()
Post by: annikk.exe on January 01, 2011, 06:09:46 AM
I found a workaround to this. Somewhat obvious, but basically I just declare all my variables in LevelSetup instead.  That works fine, so no need to worry about this really..