diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-03-01 22:19:46 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-03-01 22:19:46 -0500 |
| commit | 7fa69be4e88f1fcf057871fec7e4503f50578465 (patch) | |
| tree | 70a01aafe4092c29c112f72895494dbfa2033496 /res/scripts/common.lua | |
| parent | d8e7d815c197c5477678d835038dc3ff86c2a7e8 (diff) | |
| download | tanetane-7fa69be4e88f1fcf057871fec7e4503f50578465.tar.gz tanetane-7fa69be4e88f1fcf057871fec7e4503f50578465.tar.bz2 tanetane-7fa69be4e88f1fcf057871fec7e4503f50578465.zip | |
Started writing the Mixolydia scene!
Looking pretty good so far. TODO: direction facing functions have inverted Y coordinate. confusion expression doesn't exist yet. rest of scene.
Diffstat (limited to 'res/scripts/common.lua')
| -rw-r--r-- | res/scripts/common.lua | 59 |
1 files changed, 59 insertions, 0 deletions
| diff --git a/res/scripts/common.lua b/res/scripts/common.lua index 1b0c4a9..dad9c5d 100644 --- a/res/scripts/common.lua +++ b/res/scripts/common.lua | |||
| @@ -30,6 +30,12 @@ SpriteLayer = { | |||
| 30 | ABOVE = 1 | 30 | ABOVE = 1 |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | BehaviourType = { | ||
| 34 | NONE = 0, | ||
| 35 | WANDER = 1, | ||
| 36 | PATH = 2 | ||
| 37 | } | ||
| 38 | |||
| 33 | CutsceneOptions = { | 39 | CutsceneOptions = { |
| 34 | DO_NOT_CHANGE_ANIMATION = 1 -- Prevents player party animation being set to "frozen" at the start of a cutscene or "still" at the end | 40 | DO_NOT_CHANGE_ANIMATION = 1 -- Prevents player party animation being set to "frozen" at the start of a cutscene or "still" at the end |
| 35 | } | 41 | } |
| @@ -426,6 +432,13 @@ function WaitForSpritePath(spriteName) | |||
| 426 | end | 432 | end |
| 427 | end | 433 | end |
| 428 | 434 | ||
| 435 | --- Turns off the sprite's behaviour. | ||
| 436 | function DisableBehaviour(spriteName) | ||
| 437 | local spriteId = getSpriteByAlias(spriteName) | ||
| 438 | local sprite = getSprite(spriteId) | ||
| 439 | sprite.behaviourType = BehaviourType.NONE | ||
| 440 | end | ||
| 441 | |||
| 429 | --- Fades out the currently playing music. | 442 | --- Fades out the currently playing music. |
| 430 | -- This does not block. If you want it to block, call Delay for the same amount | 443 | -- This does not block. If you want it to block, call Delay for the same amount |
| 431 | -- of time. | 444 | -- of time. |
| @@ -456,3 +469,49 @@ function EnablePlayerControl() | |||
| 456 | local playerSprite = getSprite(playerId) | 469 | local playerSprite = getSprite(playerId) |
| 457 | playerSprite.controllable = true | 470 | playerSprite.controllable = true |
| 458 | end | 471 | end |
| 472 | |||
| 473 | --- Makes the specified sprite face toward the †arget sprite. | ||
| 474 | -- This version of the function uses the closest cardinal direction. | ||
| 475 | -- @param spriteName the name of the sprite to change the direction of | ||
| 476 | -- @param targetName the name of the sprite to face toward | ||
| 477 | function FaceTowardSpriteCardinally(spriteName, targetName) | ||
| 478 | local spriteId = getSpriteByAlias(spriteName) | ||
| 479 | local targetId = getSpriteByAlias(targetName) | ||
| 480 | local sprite = getSprite(spriteId) | ||
| 481 | local target = getSprite(targetId) | ||
| 482 | local diff = vec2i.new(target.loc:x() - sprite.loc:x(), target.loc:y() - sprite.loc:y()) | ||
| 483 | local dir = cardinalDirectionFacingPoint(diff) | ||
| 484 | |||
| 485 | SetDirection(spriteName, dir) | ||
| 486 | end | ||
| 487 | |||
| 488 | --- Detaches the sprite's followers and erases their following trails. | ||
| 489 | function BreakUpParty(spriteName) | ||
| 490 | local spriteId = getSpriteByAlias(spriteName) | ||
| 491 | character():breakUpParty(spriteId) | ||
| 492 | end | ||
| 493 | |||
| 494 | --- Makes the specified sprite solid. | ||
| 495 | -- This means that other sprites will be blocked if they collide with this one. | ||
| 496 | function MakeSpriteSolid(spriteName) | ||
| 497 | local spriteId = getSpriteByAlias(spriteName) | ||
| 498 | local sprite = getSprite(spriteId) | ||
| 499 | sprite.solid = true | ||
| 500 | end | ||
| 501 | |||
| 502 | --- Makes the specified sprite not solid. | ||
| 503 | -- This means that other sprites will not be blocked if they collide with this | ||
| 504 | -- one. | ||
| 505 | function MakeSpriteNotSolid(spriteName) | ||
| 506 | local spriteId = getSpriteByAlias(spriteName) | ||
| 507 | local sprite = getSprite(spriteId) | ||
| 508 | sprite.solid = false | ||
| 509 | end | ||
| 510 | |||
| 511 | --- Sets the sprite's movement speed. | ||
| 512 | -- As a reference: 1 is slow (good for NPCs), 2 is Lucas's default walking speed | ||
| 513 | function SetMovementSpeed(spriteName, speed) | ||
| 514 | local spriteId = getSpriteByAlias(spriteName) | ||
| 515 | local sprite = getSprite(spriteId) | ||
| 516 | sprite.movementSpeed = speed | ||
| 517 | end | ||
