Data Realms Fan Forums
http://forums.datarealms.com/

Debugging attached Lua scripts the easier way
http://forums.datarealms.com/viewtopic.php?f=73&t=25671
Page 1 of 1

Author:  weegee [ Tue Sep 27, 2011 7:39 pm ]
Post subject:  Debugging attached Lua scripts the easier way

Excuse me if I'm going to say something well known or stupid :)

I was annoyed that I need to reload CC every time I want to change Lua script attached to device, so I wrote a little workaround:

INI file:
Code:
ScriptPath = UnmappedLands.rte/Scenes/Objects/Teleport/TeleportDebug.lua


TeleportDebug.lua, a stub used only while you're debugging. CF_PutTeleport() is a function which actually does something useful
Code:
function Create(self)
   print ("TeleportDebug")
   dofile("UnmappedLands.rte/Scenes/Objects/Teleport/Teleport.lua")
   CF_PutTeleport(self);
end


Teleport.lua, actual script in which you write you code, replace your debug stub with it in INI once everything's fine.
Code:
function Create(self)
   CF_PutTeleport(self);
end

function CF_PutTeleport(self)
   print ("Change Places!");
end


This way your code is reinterpreted EVERY TIME your script runs, not a single time when it loads when CC starts :)

Author:  Roast Veg [ Tue Sep 27, 2011 8:06 pm ]
Post subject:  Re: Debugging attached Lua scripts the easier way

Or failing that, open the console and type:
Code:
PresetMan:ReloadAllScripts()


But your way works too.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/