[solved] luahookscript doesn't work
Posted: 19.02.2009, 12:00
hey,
I tried to create my own luahook script by the help of hank's old thread:
I also tried to get along with the "lua_edu_tools"which worked but I still wasn't able to create my own script.
what I did was making an entry in celestia.cfg:
LuaHook "luahookinit.lua"
my luahookinit.lua looked like this:
then my client.lua looked like:
I also tried to do it like the lua_edu_tools:
then my client.lua was:
but that didn't work either.
I did not get any output on the screen.
Is there sth. about the event handler included into the lua_edu_tools.lua?
If I Did not wrap the celestia:print()-command int o a function it's done but only once.
Nevertheless I don't get why I do not get an output when just copying hank's example.
hope somebody can figure out what's goin wrong here.
Thanks
Stuffer
I tried to create my own luahook script by the help of hank's old thread:
but it didn't work. Since this thread is not that new I was wondering if anything has changed in the celestia source code so this example doesn't work anymore.hank wrote:First, you would add the following line to your celestia.cfg file:Code: Select all
LuaHook "luahooktest.lua"
Then you would create the file luahooktest.lua in your Celestia resources directory. It could look like this:Code: Select all
hooktest = {};
hooktest.luaoverlay =
function(self)
local time = celestia:gettime();
celestia:flash("Time "..time,1);
end;
celestia:setluahook(hooktest);
In this very simple example, a Lua object (table) called hooktest is created and a method luaoverylay is defined for it. Then the object is attached to Celestia with a call to celestia:setluahook. The luaoverlay method of the hooktest object will be called from the CelestiaCore draw method each time Celestia redraws the display. The luaoverlay method gets the current simulation time and flashes it on the screen (nominally for one second, but actually the message is updated with a new time almost instantly by the next call to luaoverlay).
- Hank
I also tried to get along with the "lua_edu_tools"which worked but I still wasn't able to create my own script.
what I did was making an entry in celestia.cfg:
LuaHook "luahookinit.lua"
my luahookinit.lua looked like this:
Code: Select all
require "client"
celestia:setluahook("client")
then my client.lua looked like:
Code: Select all
printtesttext =
function(self)
celestia:print("text",1)
end
I also tried to do it like the lua_edu_tools:
then my client.lua was:
Code: Select all
client =
{
printtesttext =
function(self)
celestia:print("text",1)
end
}
but that didn't work either.
I did not get any output on the screen.
Is there sth. about the event handler included into the lua_edu_tools.lua?
If I Did not wrap the celestia:print()-command int o a function it's done but only once.
Nevertheless I don't get why I do not get an output when just copying hank's example.
hope somebody can figure out what's goin wrong here.
Thanks
Stuffer