Jump to content

Can I set or change the File value of a Scene object in Lua?


Gonan
 Share

Recommended Posts

I am trying to work out how to manually take control of the monsterAI.lua controlled entities, my initial thoughts are is there a way to assign a script file to the entity programmatically in a lua script. And if so can the entity be stopped, and have the script reset back to monsterAI.lua once I release manual control.

 

The Idea is to be able to tab key among my army of entities, and "mind control" them, taking over from their normal monsterAI.lua script and using my own controller.lua script. When I tab out they revert back to their normal script.

 

I haven't been able to find any API reference to setting the script file for an entity. Would this be a possibility.

Link to comment
Share on other sites

Thanks, I added a line to the Monsterai.lua Script:Start

 

System:Print("self.GetScript()="..self.entity:GetScript())

 

this gives the full path and file name of the script in the log.

Then using those results followed it with a line to load a new script

 

self.entity:SetScript("C:/Users/....................../monstera3.lua")

 

In the log this caused the old script to be deleted, the new script loaded and then executed. So looks like it can be done, with that method, though will have to check that it doesn't cause any leaks.

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...