-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand-manager.lua
More file actions
50 lines (39 loc) · 1020 Bytes
/
command-manager.lua
File metadata and controls
50 lines (39 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
local _messages
function onLoad()
updateMessages()
end
function updateMessages()
_messages = {}
for _, containedObject in ipairs(self.getObjects()) do
local command = containedObject.name
local desc = containedObject.description
table.insert(_messages, {command = command, desc = desc})
end
end
function isContained(command)
for i = 1, #_messages do
if _messages[i].command == command then
return _messages[i]
end
end
return false
end
function onChat(message, player)
local contained = isContained(message)
if contained then
createDialog(contained)
end
end
function createDialog(message)
Player["Black"].showMemoDialog(message.command, message.desc)
end
function onObjectEnterContainer(container, enter_object)
if container == self then
updateMessages()
end
end
function onObjectLeaveContainer(container, leave_object)
if container == self then
updateMessages()
end
end