summary refs log tree commit diff stats
path: root/res/scripts/common.lua
diff options
context:
space:
mode:
Diffstat (limited to 'res/scripts/common.lua')
-rw-r--r--res/scripts/common.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/res/scripts/common.lua b/res/scripts/common.lua index dbc021c..1d4879f 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua
@@ -414,6 +414,14 @@ function SetAnimationSlowdown(spriteName, amount)
414 sprite.animSlowdown = amount 414 sprite.animSlowdown = amount
415end 415end
416 416
417--- Sets the enclosure zone for a sprite.
418-- The sprite will be prevented from exiting the area defined by that zone.
419function AddEnclosureZone(spriteName, zone)
420 local spriteId = getSpriteByAlias(spriteName)
421 local sprite = getSprite(spriteId)
422 sprite.enclosureZone = zone
423end
424
417--- Removes the enclosure zone for the specified sprite. 425--- Removes the enclosure zone for the specified sprite.
418-- This allows the sprite to move outside of the confines of the zone. 426-- This allows the sprite to move outside of the confines of the zone.
419function RemoveEnclosureZone(spriteName) 427function RemoveEnclosureZone(spriteName)
@@ -607,3 +615,10 @@ function IsSpriteInZone(spriteName, zoneName)
607 615
608 return (pos:x() >= zone.ul:x()) and (pos:x() <= zone.dr:x()) and (pos:y() >= zone.ul:y()) and (pos:y() <= zone.dr:y()) 616 return (pos:x() >= zone.ul:x()) and (pos:x() <= zone.dr:x()) and (pos:y() >= zone.ul:y()) and (pos:y() <= zone.dr:y())
609end 617end
618
619--- Sets the name of the script on the current map that will be executed when the player interacts with this sprite.
620function SetInteractionScript(spriteName, scriptName)
621 local spriteId = getSpriteByAlias(spriteName)
622 local sprite = getSprite(spriteId)
623 sprite.interactionScript = scriptName
624end