More Lua questions
I am trying to clean up my vessel script by moving the animations to a separate module file. I am basically following the format shown here: https://copyprogramming.com/howto/in-lua-how-do-you-import-modules
This is my module file make_anim.lua (in same directory as the vessel script):
I am attempting to load it in my vessel script (in the Config/Vessels directory, along with the aforementioned module file) with:
and calling the function with:
The vessel script runs, but none of these animations work. If I copy all the function back into my vessel script everything works fine, but I can't seem to get this module implemented. I'm at my wit's end with Lua. I thought it was going to be easier than coding C++ modules but it seems it is a whole new circus of syntax that I can't grok.
I am trying to clean up my vessel script by moving the animations to a separate module file. I am basically following the format shown here: https://copyprogramming.com/howto/in-lua-how-do-you-import-modules
This is my module file make_anim.lua (in same directory as the vessel script):
Code:
local make_anim = {}
function make_anim.Elevator()
anim_elevator = vi:create_animation(0.5)
elevator =
{
type = 'rotation',
mesh = 0,
grp = {134, 142},
ref = {x=0,y=-0.9223039,z=-4.268489},
axis = {x=1,y=0,z=0},
angle = 33*RAD
}
vi:add_animationcomponent(anim_elevator,0,1,oapi.create_animationcomponent(elevator))
end
return make_anim
I am attempting to load it in my vessel script (in the Config/Vessels directory, along with the aforementioned module file) with:
Code:
make_anim_module = require("make_anim")
and calling the function with:
Code:
make_anim.Elevator()
The vessel script runs, but none of these animations work. If I copy all the function back into my vessel script everything works fine, but I can't seem to get this module implemented. I'm at my wit's end with Lua. I thought it was going to be easier than coding C++ modules but it seems it is a whole new circus of syntax that I can't grok.