[Solved]Get all map entities?

Started by zutokaza, June 01, 2017, 09:44:18 PM

Previous topic - Next topic
June 01, 2017, 09:44:18 PM Last Edit: June 06, 2017, 04:52:31 AM by zutokaza
Is it possible make a NPC target entities with a prefix?

Code ( lua) Select
target_movement:set_target(map:get_entities("bird_"))
Solarus Works on ReactOS Opensource Windows OS

https://www.reactos.org/forum/viewtopic.php?f=2&t=14759&p=120616#p120616

Well a movement can only have one direction at a time, so you have to choose a target.
You can always make a loop to detect the closest entity from a list of entities, and repeat this in a timer.

Quotemake a loop to detect the closest entity from a list of entities

How is that done? My script looks like this so far.

Code ( lua) Select
-- Call a function every second.
sol.timer.start(5000, function()
    local birds = map:get_entities("bird_")
    local npc_near_birds = npc_1:get_distance(birds)
    if npc_near_birds < 10 then
       movement = sol.movement.create("target")
       movement:set_target(birds)
       movement:set_speed(48)
       movement:start(npc_1)
    end
  return true  -- To call the timer again (with the same delay).
end)
Solarus Works on ReactOS Opensource Windows OS

https://www.reactos.org/forum/viewtopic.php?f=2&t=14759&p=120616#p120616

Can anyone give me an example? Please...  :D
Solarus Works on ReactOS Opensource Windows OS

https://www.reactos.org/forum/viewtopic.php?f=2&t=14759&p=120616#p120616

I think the best example would be the "Evil Tile".  these are the tiles in dungeons that lift up and fly at the hero, one at a time, with a timed delay between each tile's movements.
My tilesets page can be found here:
http://absolute-hyrule-tutorials.solarus-games.org/

June 05, 2017, 08:36:50 PM #5 Last Edit: June 05, 2017, 09:04:17 PM by zutokaza
Quote from: ffomega on June 05, 2017, 01:50:45 PM
I think the best example would be the "Evil Tile".  these are the tiles in dungeons that lift up and fly at the hero, one at a time, with a timed delay between each tile's movements.

Do you know what map and game the "Evil Tile" exists in?

Edit:
Found it.
https://github.com/solarus-games/zsdx/blob/dev/data/maps/evil_tiles.lua
Solarus Works on ReactOS Opensource Windows OS

https://www.reactos.org/forum/viewtopic.php?f=2&t=14759&p=120616#p120616