First step in redesigning lua widgets
This commit is contained in:
@@ -23,10 +23,9 @@
|
||||
-- At this point, if you were to pprint(keys), the output would
|
||||
-- look like this:
|
||||
--
|
||||
-- { "hotkeys", "X", "Light Oven", "A", "Add Fuel" }
|
||||
-- { "X", "Light Oven", "A", "Add Fuel" }
|
||||
--
|
||||
-- The first array element is always the word "hotkeys". Notice
|
||||
-- also that a hotkeylist doesn't store the closures, they are
|
||||
-- Notice that a hotkeylist doesn't store the closures, they are
|
||||
-- silently ignored. The resulting array is in a format that can
|
||||
-- be returned directly to Unreal.
|
||||
--
|
||||
@@ -58,7 +57,7 @@ makeclass("hotkeylist")
|
||||
makeclass("hotkeypress")
|
||||
|
||||
function hotkeylist.create()
|
||||
local result = { "hotkeys" }
|
||||
local result = {}
|
||||
setmetatable(result, hotkeylist)
|
||||
return result
|
||||
end
|
||||
@@ -79,4 +78,3 @@ function hotkeypress.add(self, key, action, closure)
|
||||
self.closure = closure
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -55,13 +55,9 @@ function engio.getlookat()
|
||||
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.
|
||||
-- look-at widget is 'hotkeys'.
|
||||
if class.lookhotkeys ~= nil then
|
||||
local keys = hotkeylist.create()
|
||||
class.lookhotkeys(keys)
|
||||
setmetatable(keys, nil)
|
||||
return keys
|
||||
return "hotkeys"
|
||||
end
|
||||
|
||||
-- otherwise, if the class has a function 'getlookat', use that.
|
||||
@@ -73,6 +69,20 @@ function engio.getlookat()
|
||||
return ""
|
||||
end
|
||||
|
||||
function engio.gethotkeys()
|
||||
local class = tangible.getclass(place)
|
||||
|
||||
-- if the tangible doesn't have a 'lookhotkeys' function, do nothing
|
||||
if class == nil or class.lookhotkeys == nil then
|
||||
return {}
|
||||
end
|
||||
|
||||
local keys = hotkeylist.create()
|
||||
class.lookhotkeys(keys)
|
||||
setmetatable(keys, nil)
|
||||
return keys
|
||||
end
|
||||
|
||||
function engio.presshotkey(action)
|
||||
local class = tangible.getclass(place)
|
||||
|
||||
@@ -94,4 +104,4 @@ function jp3()
|
||||
tangible.animate{tan=actor, anim={action="play", seq="jump"}}
|
||||
tangible.animate{tan=actor, anim={action="play", seq="jump"}}
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user