Page 1 of 1

Lua Module for ScriptedRotation

Posted: 12.02.2008, 14:07
by Pierral
Hello !

I'm trying to make a Lua module for an object which has a ScriptedRotation. But for some reason I don't understand, Celestia tells me "Failed to load module for ScriptedRotation" every time I start.
I have my module "rtfifo.lua" in "scripts/celxx" directory, and here is my module :

Code: Select all

rtAttProto = { }

-- constructor method

function rtAttProto:new(o)
   o = o or {}
   setmetatable (o, self)
   self.__index = self

   o.period = 1

   return o
end

-- orientation function

function rtAttProto:orientation(tjd)
   local t = tjd

   -- return a quaternion representing the orientation
   w, x, y, z = fifolib.popAtt(t)

   return w, x, y, z

end

function rtAtt(sscvals)

   return rtAttProto:new(sscvals)

end


And here is the .scc

Code: Select all

    ScriptedRotation
    {
        Module "rtfifo"
        Function "rtAtt"
    }


"fifolib" is a library I made and added to Lua. It works very well in a celx script launched with celestia, and i was asking why it does not in Lua module. But after some research, I found that the module was not even loaded.
Can someone help me with Lua Module and Scc file please ?
I already read wiki documentation, i downloaded and analyzed "flight_control" script, and i think i did the same, but it does not work for me... :cry:

Thanks !

Pierral.

Posted: 12.02.2008, 14:22
by selden
CELX scripts, LuaHooks, and Scripted SSC functions run in three separate contexts. Routines and libraries loaded in one context are not available to the others. Your Scripted module needs to explicitly load the libraries that it needs.

Some, but not all, Lua syntax errors are reported in Celestia's console log. Type a tilde (~) to see it, and use the arrow keys to navigate up and down in it. If your keyboard supports diacritical marks, you may have to type <tilde><space>

Posted: 12.02.2008, 14:28
by Pierral
Ok thanks Selden. I'll explicitly declare my "fifolib" with require in my "rtfifo.lua" file.

But do you think it's because of that i have the error "Failed to load module rtfifo" (in scriptrotation.cpp::initialize) ?

Posted: 12.02.2008, 14:37
by selden
"failed to load module" is caused by any error in the module. You need to look at the line of the console log where it says the SSC file was loaded. Many (but not all) module errors generate an error message which includes the module line number where Lua detected an error. That might not be the actual cause of the problem, though. Incorrectly nested end statements will generate misleading line numbers, for example.

Posted: 12.02.2008, 14:44
by Pierral
Ok so it's a Lua error, thanks !

Can i abuse and ask you where can i find the console log please ?

Thanks for all !

Posted: 12.02.2008, 14:50
by selden
Type a tilde (~) to see Celestia's console log, and use the arrow keys to navigate up and down in it. If your keyboard supports diacritical marks, you may have to type <tilde><space>

Posted: 12.02.2008, 15:12
by Pierral
Yes !!!!
Thanks Selden ! that's a tricky command, but it's so helpfull !!!
I found that i was not in the good directory, and now i can see lua error and lines !
I can debug my script now !!
thanks a lot !! :D

Posted: 12.02.2008, 15:15
by selden
You are very welcome.