🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Copying lua states

Started by
10 comments, last by utopico 21 years ago
No it is not what I mean. What I want is the one lua script to act as a separate unit without direct interaction from other script so as if to represent a typical C++ object.

so a typical lua script has just a two functions:

function init()
--setup
state = 0 -- init state
end


function procMsg(self, msg)
-- called everytime a message is received through the message system
-- will typically change a state
if state == 0 then
-- do some cool stuf
if msg:getType() == "cool" then
state = 1
end
else if state == 1 then
-- do more cool stuf
state = 0
end
end
end


Here the state variable is accessible to procMsg each time and wont be changed in the meantime. If I where to have more similar script in the same lua state, for one I would have to change the function name (no big deal), but I would be very carefull to what variables I used in the different script for not to create interference between them.
Is there another way, cause it would have been nice to solve the problem in another way than to have a lot of lua states
Advertisement
I still don''t understand why you want to do this, so I will gracefully exit from this topic.
---------------------http://www.stodge.net

This topic is closed to new replies.

Advertisement