In Grimrock 1 you can spawn a script entity and set its source using the SetSource() method. You don't really get dofile functionality but you can get fairly close. Take a look at jkos' LoG Framework.
In Grimrock 2, you can imitate dofile (or dostring) like this:
1. Add this object definition:
Code: Select all
defineObject{
name = "file_doer",
components = {
{
class = "ScriptController",
name = "controller",
onInit = function(self)
self.go.script:loadFile(fileDoerControl.script.filename)
end,
},
{
class = "Script",
},
},
placement = "floor",
}
2. Add a script_entity called fileDoerControl with this function:
Code: Select all
function dofile(scriptName,fName)
filename = fName
spawn("file_doer",self.go.level,self.go.x,self.go.y,self.go.facing,self.go.elevation,scriptName)
end
Now you can call fileDoerControl.script.dofile("cows","mod_assets/scripts/cows.lua") to create an object named "cows" with a ScriptComponent named "script" that immediately executes cows.lua. It will support connectors too because it has a ScriptControllerComponent, though of course these connectors will have to be added dynamically.
If you want dostring instead then just replace the loadFile() call with setSource().
As for 'goto', why the hell do you want goto in the first place...
As for other lua features, security.