Run Script on Load Alternative

Post Reply
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Run Script on Load Alternative

Post by clintonman »

I found another way to run scripts automatically when they load. Place a System.SendCommandLine in the OnPostLoad will run what is sent to it.
Attached is 2 tests, one just runs a command straight out and the second calls the remote script that loads with it. The second one only works when loaded into a scene.

WARNING: Don't use a System.ThisOwner() inside the SendCommandLine, it will hard crash trueSpace.

Code: Select all

// ---------------------------------
// Advanced handlers 
// ---------------------------------

function OnPostLoad(params)
{
   System.SendCommandLine('System.Alert("I am a simple command run")');
}
Attachments
Auto Run Simple Command.RsObj
(38.75 KiB) Downloaded 185 times
Auto Run Remote Command.RsObj
(11.98 KiB) Downloaded 166 times
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5206
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Run Script on Load Alternative

Post by trueBlue »

Sweet! Thanks for sharing!

Code: Select all

function Execute(params)
{
System.Alert("I can also delete this script after it is loaded")
Node.Delete(System.ThisName())
}
function OnPostLoad(params)
{
System.SendCommandLine('Activity.Run(Space.CurrentScene() + "/Run")');
}
Post Reply