-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.lua
45 lines (41 loc) · 1.16 KB
/
actions.lua
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
-- actions.lua -- Action definitions
module('actions', package.seeall)
require 'event'
function onSceneClick(vp)
--regardless of current action
GAME:getMainCharacter():walkTo(vp)
return false
end
function onActorClick(target)
local ui = GAME:getUserInterface()
if string.sub(ui:getActionText(),1,5) == "Go to" then
GAME:getMainCharacter():walkTo(target)
else --any other action
local valid = true
function arrive(subject)
if not valid then return true end
if subject:getName() == GAME:getMainCharacter():getName() and subject:getPosition() == target:getPosition() and valid then
if string.sub(ui:getActionText(),1,8) == "Interact" then
--INTERACT ACTION
elseif string.sub(ui:getActionText(),1,4) == "Pick" then
--PICKUP ACTION
end
return true
end
return false
end
function abort(subject)
if subject:getName() == GAME:getMainCharacter():getName() then
valid = false
return true
end
return false
end
event.on('actorArrived', arrive);
event.on('abortWalking', abort);
GAME:getMainCharacter():walkTo(target)
end
return false
end
event.on('sceneClick', onSceneClick)
event.on('actorClick', onActorClick)