Scripting help

Scripts in a Platformer

What Platformer enemies can do with a script, with an example.

A Platformer is seen from the side, so a few words work a little differently there. @variables work just the same, and they go with the hero from level to level.

WordsIn a Platformer
patrolwanderrun awayfollow the {Hero}go homeThe enemy walks left and right along its floor. Walking steps like run away 3 blocks stop at a wall or a ledge.
movemy directionOnly left or right. To go up, jump.
jumpjump up 4 blocksjump toward the {Hero}jump awayThe enemy really jumps. The next line waits until it lands, and when I land happens then.
hop left 1 blockjump right 3 blocksjump right 3 blocks, up 3 blocksA hop or jump to the left or right, landing that many blocks away. A hop stays low. A jump goes 2 blocks high, or as high as its up part says. The parts can come in either order, and up is how high it goes, not where it lands. The next line waits until it lands.
when I see the {Hero}The hero is inside the enemy's Notice range, Left or Right.
stop attackingTouching an enemy still hurts the hero. I am harmless stops that too.
use my weaponUses the enemy's weapon once, right now, at the hero, even after stop attacking. The next line waits until the shot is away. With no weapon, Charge or Spooky, nothing happens.
turn aroundwhen I reach an edgewhen I bump into a wallOnly for Platformers.
charge at the {Hero}Only for swimmers. A swimmer's jump leaps out of the water and back in.
fight smartdodgeThe villager wordsOnly for Adventures.
my rowmy row is 4Row 1 is the bottom row, and an enemy's row is the block its feet are in, so one standing on the bottom row's ground is in row 2. Put in the air, it falls. See Where a character is.

After its first jump, an enemy falls off ledges it walks over. Falling out of the level beats it.

How it moves has the ready-made scripts Coward, Ambusher, Hit and run, Grumpy, Show-off and Hopper. Hopper jumps at the hero it sees.

Seesaw platforms

Enemies and bosses can stand on a seesaw platform. Only the hero tips it. As it tips, the enemies on it tip with it and slide downhill, then hang on at the low end. If it tips too far to stand on, they fall off.

How fast they slide is their Grip in Object settings, which a script can change with my grip is sticky, my grip is normal or my grip is slippery.

Enemies and bosses don't tip a seesaw unless they are heavy: Weight set to Heavy in Object settings, or my weight is heavy in the script. A heavy one tips the seesaw toward the side it stands on and holds it there. It also shoves the seesaw down where it lands; a higher jump and a landing further from the middle shove it harder.

This boss stomps its way along a seesaw and back, tipping it toward itself each time:

​
repeat forever
end

A script can make an enemy keep its footing:

WordsWhat it does
when my tilt is over 1 blockWhen the low end of the platform I'm on drops more than this many blocks below its middle. It can happen again after the platform tips back under that line.
walk uphillwalk downhillWalk up or down the platform until it's level. Add a distance to stop sooner, like walk uphill 2 blocks. While walking it doesn't slide. When it's level, nothing happens.
if I am tiltingWhether the platform I'm on has tipped at all. my tilt is how far, in blocks.

Example: a slime that hops at you

Start from Walks around and add two rules. The slime leaps at the hero it sees, and turns back at the edge of its floor instead of walking off:

​
​