lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


personally for ingame usage I don't think using multiple VM's is necessary as Michael said, use namespaces.
so the way I will be implementing Lua for now ;) is to have one VM and have each script use a namespace (read table)
and my application will setup any entities using the correct namespace.. the only downfall of this is knowing what the namespace is called, I mean, if you enable a user to create a random script which follows some basic rules, like the table should contain certain functions, you still have the problem of the host machine knowing what namespace is used, this isn't a problem if your dealing with everything via script because you can amend you script easily, but when your assigning script to entities via some form of editor this becomes a problem.. unless you have another rule stating the namespace should match the script name.. so.. (untested script follows, just example ;)

--enemy.lua

enemy= {
 	PositionX = 0.0,
 	PositionY = 0.0,
 	PositionZ = 0.0
}  

function enemy:new()   
	return {} 
end  

function enemy:Initialise(x,y,z)   
	self.PositionX,self.PositionY,self.PositionZ = x,y,z 
end

function enemy:Update(time)
   self.PositionX = (self.PositionX + 1.0) * time
end

then you can assume from the filename what the namespace is.. this is very ugly and prone to errors, but until I understand a little more of the workings and features of Lua I'm stuck in doing it this way for the time being.

Regards,

PT



[Big snip]
>------------------------------------------------------------------------
>----------------
>A multiple Virtual Machine architecture :