Some work to make hotkeys a 'real thing' on the lua side
This commit is contained in:
@@ -18,22 +18,34 @@ function engio.move(action, xyz, facing)
|
||||
tangible.animate(actor, nil, {action=action, xyz=xyz, facing=facing})
|
||||
end
|
||||
|
||||
function cube.getlookat()
|
||||
return { "Hotkeys", "X", "I Am a Cube" }
|
||||
function cube.lookhotkeys(keys)
|
||||
keys:add("X", "Cube Hi", function () dprint("Cube Hi") end)
|
||||
keys:add("A", "Cube Bye", function () dprint("Cube Bye") end)
|
||||
end
|
||||
|
||||
function sphere.getlookat()
|
||||
return { "Hotkeys", "X", "I Am a Sphere" }
|
||||
function sphere.lookhotkeys(keys)
|
||||
keys:add("X", "Sphere Hi", function () dprint("Sphere Hi") end)
|
||||
keys:add("A", "Sphere Bye", function () dprint("Sphere Bye") end)
|
||||
end
|
||||
|
||||
|
||||
function engio.getlookat()
|
||||
local class = tangible.getclass(tangible.place())
|
||||
if class ~= nil then
|
||||
local getlookat = class.getlookat
|
||||
if getlookat ~= nil then
|
||||
return getlookat()
|
||||
end
|
||||
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
|
||||
return ""
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user