1
General discussion / Need Help With Enemy Scripting
« on: October 28, 2018, 07:08:22 PM »
I'm trying to create a hallway, not unlike like this one from ALttP...

Here's mine...

I unfortunately can't get my spike traps to act accordingly. Here's the script I made below...
Two things I'm trying to get the code to do (unsuccessfully) are...

Here's mine...

I unfortunately can't get my spike traps to act accordingly. Here's the script I made below...
Code: [Select]
-- Lua script of enemy trap.
-- This script is executed every time an enemy with this model is created.
-- Feel free to modify the code below.
-- You can add more events and remove the ones you don't need.
-- See the Solarus Lua API documentation for the full specification
-- of types, events and methods:
-- http://www.solarus-games.org/doc/latest
local enemy = ...
local game = enemy:get_game()
local map = enemy:get_map()
local hero = map:get_hero()
local sprite
local movement
-- Event called when the enemy is initialized.
function enemy:on_created()
-- Initialize the properties of your enemy here,
-- like the sprite, the life and the damage.
sprite = enemy:create_sprite("enemies/" .. enemy:get_breed())
enemy:set_invincible(1)
enemy:set_damage(1)
end
-- Event called when the enemy should start or restart its movements.
-- This is called for example after the enemy is created or after
-- it was hurt or immobilized.
function enemy:on_restarted()
movement = sol.movement.create("path")
movement:set_path{4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
movement:set_speed(96)
movement:start(enemy)
path_movement:set_loop(true)
end
Two things I'm trying to get the code to do (unsuccessfully) are...
- Travel back and forth at a set speed on the same left/right path over and over
- Not be stopped by the hero, enemies, attacks, anything really. (to add to this I would like it to make that 'tink tink' noise when you slash it, shoot it, try to blow it up whatever)