mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-03-01 03:30:04 +00:00
Prepare for scripted event handling
This commit is contained in:
parent
fc365eaee8
commit
e9012275d5
@ -1235,14 +1235,24 @@ def initMap(x, y, dir)
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Send an event to the script
|
||||
export def scriptEvent(event, param)
|
||||
if global=>w_mapScript
|
||||
return global=>w_mapScript(event, param)
|
||||
fin
|
||||
return -1
|
||||
end
|
||||
|
||||
// Check for script(s) attached to the given location, and call them if there are any.
|
||||
// Returns TRUE if any were triggered.
|
||||
def checkScripts(x, y)
|
||||
word p
|
||||
word pNext
|
||||
word script
|
||||
word pNext
|
||||
byte anyTriggered
|
||||
|
||||
scriptEvent(EVENT_LEAVE, 0)
|
||||
global=>w_mapScript = 0
|
||||
anyTriggered = FALSE
|
||||
x = x - triggerOriginX
|
||||
y = y - triggerOriginY
|
||||
@ -1256,10 +1266,10 @@ def checkScripts(x, y)
|
||||
p = p + 2
|
||||
while p < pNext
|
||||
if x == ^p
|
||||
script = p=>1
|
||||
script = p=>1
|
||||
setWindow2()
|
||||
skipScripts = FALSE
|
||||
script()
|
||||
script() // When should the script be installed as an event handler?
|
||||
clearPortrait()
|
||||
// Some scripts need to suppress running of any further scripts on the square
|
||||
// because they swapped out the render engine.
|
||||
@ -1271,6 +1281,7 @@ def checkScripts(x, y)
|
||||
fin
|
||||
p = pNext
|
||||
loop
|
||||
scriptEvent(EVENT_ENTER, 0)
|
||||
return anyTriggered
|
||||
end
|
||||
|
||||
|
@ -66,3 +66,8 @@ const LEAVE_OPEN = 1
|
||||
const HEAP_BOTTOM = $F000
|
||||
const HEAP_SIZE = $800
|
||||
|
||||
// Event code
|
||||
const EVENT_ENTER = 1
|
||||
const EVENT_LEAVE = 2
|
||||
const EVENT_USE_ITEM = 3
|
||||
|
||||
|
@ -25,6 +25,7 @@ struc Global
|
||||
word w_mapX
|
||||
word w_mapY
|
||||
byte b_mapDir
|
||||
word w_mapScript
|
||||
|
||||
// Shared player gold amount
|
||||
word w_gold
|
||||
|
Loading…
x
Reference in New Issue
Block a user