Files
integration/luprex/lua/login.lua

61 lines
1.8 KiB
Lua

makeclass('login')
makeclass("engio")
makeclass('cube')
makeclass('sphere')
function login.init()
local actor = tangible.actor()
dprint("login.init:", actor)
tangible.animinit(actor, {bp="character", plane="earth", xyz={0, 0, 90}})
tangible.build{class=cube, xyz={500,-100,0}}
tangible.build{class=sphere, xyz={500,100,0}}
end
function engio.move(action, xyz, facing)
-- todo: sanity check the parameters.
local actor = tangible.actor()
dprint("engio.move ", action, " ", xyz[1], " ", xyz[2], " ", xyz[3])
tangible.animate(actor, nil, {action=action, xyz=xyz, facing=facing})
end
function cube.lookhotkeys(keys)
keys:add("X", "Cube Hi", function () dprint("Cube Hi") end)
keys:add("A", "Cube Bye", function () dprint("Cube Bye") end)
keys:add("Y", "Cube Yo", function () dprint("Cube Yo") end)
end
function sphere.lookhotkeys(keys)
keys:add("X", "Sphere Hi", function () dprint("Sphere Hi") end)
keys:add("A", "Sphere Bye", function () dprint("Sphere Bye") end)
keys:add("Y", "Sphere Yo", function () dprint("Sphere Yo") end)
end
function engio.getlookat()
local class = tangible.getclass(tangible.place())
-- if the tangible is not of any class, return empty string.
if class == nil then
return ""
end
-- if the class has a function 'lookhotkeys', then the correct
-- look-at widget is 'hotkeys'. We're going to automatically
-- generate the correct response.
if class.lookhotkeys ~= nil then
local keys = hotkeylist.create()
class.lookhotkeys(keys)
setmetatable(keys, nil)
return keys
end
-- otherwise, if the class has a function 'getlookat', use that.
if class.getlookat ~= nil then
return class.getlookat()
end
-- by default, return the empty string.
return ""
end