I have the sample program as shown here:
rem ***** LOADS LUA FILE ON SPACEBAR PRESS *****
rem ************* SHOWS MEMORY AVAILABLE *************
sync on
sync rate 60
color backdrop rgb(0,0,0)
make object cube 1,10
dim space_on(0)
dim return_on(0)
dim luaerror(0) : luaerror()=0
do
roll object left 1,1
text 0,0,str$(system smem available())
text 0,20,str$(luaerror())
if spacekey()=1 and space_on()=0
space_on()=1
r=load lua("lua.txt")
if r=0 then luaerror()=1
endif
if returnkey()=1 and return_on()=0
return_on()=1
lua reset
endif
if returnkey()=0 and return_on()=1 then return_on()=0
if spacekey()=0 and space_on()=1 then space_on()=0
sync
LOOP
When the spacebar is pressed, the LUA file is loaded. Then if return is pressed LUA RESET is called. However, if space is pressed again to try and re-load the file, or return is pressed again then the program crashes.
I would really like to be able to call a LUA file and be able to call and reset repeatedly. The reason is; I have a large number of variables stored in the file, so if I just keep calling it without resetting the environment then I soon lose a lot of memory. I need to load a LUA file every time I open a map in my editor, so want to flush out the memory each time a new map is loaded.
Any help would be appreciated in trying to find out what the problem is. Thanks!