com3D wrote:Even if scripts are put in 2 different folders (scripts & behaviors) and the script from scripts folder is not called with a dofile
Whaaaa? I have to admit that I didn't test this, but I didn't think it would be a problem because, I _thought_ it should default to looking in the scripts folder.
com3D wrote:Then I did the same with a second new script (ZZZ_Nistur.lua) and it makes the editor crash again. If I remove the "_Nistur" then it works fine.
Curiouser and curiouser.
Right. I have some use cases to test out. I'll get back to you with this
In other news, I almost have the "extended" MScriptBehaviour working. I have the lua looking like it's working, but the problem is currently that the way I'm embedding the file doesn't null terminate the file, so I'm either going to have to pass a size through to MScript when loading it, or stick a 0 byte at the end. Neither of which are particularly difficult, I just need to decide which. Null terminating would make most sense perhaps, but if I can pass through the size, because I'm using luaL_loadbuffer rather than lua_dostring then it means that I can embed compiled lua scripts in release builds which means smaller executables and (in theory) faster loading times.
The way that the extended MScriptableBehaviour will work is as follows:
MScriptableBehaviour "player" {
health = 10,
onBegin = function()
self.speed = 12
end,
update = function()
move(self.speed)
if hit then
self.health = self.health - 1
end
end,
onEnd = function()
end,
}
The system no longer passes through the object or behaviour IDs. they are stored inside the behaviour and can be retrieved with self.__id.object and self.__id.behaviour The reason behind this is that they shouldn't be used eventually (of course, initially they will be) but I'm hoping that someone will take my code and extend the lua MScriptableBehaviour and add in wrappers for all of these in the embedded script so from a behaviour you could just do something such as
self:setScale({10, 10, 10})
and you wouldn't have to worry about the IDs at all.
Anyway, a few more tests before that one gets submitted, but the script is almost all there. Just need to get the file loading to work