Page 1 of 1

Map editor - how to use named areas/positions and Lua scripts section

Posted: Tue Feb 11, 2020 1:05 am
by adamius
Hi,

I'd like an event to fire when a player enters an area in the world or steps on a tile. Possibly I can do this using "named areas" via the map editor. I'm currently doing this via a handler that watches where the player moves (on_player_changed_position).

How exactly do I use named areas/positions created within the map editor? I can certainly create them. Now how to I get an event when a player walks/drives into them? Is this what they can do? Which event receives them?

using a wiki search for "map editor"
https://wiki.factorio.com/Map_editor
and found this:
Areas and positions
The area and position editor mode allows to create positions and areas in the world that can be named. These can then be easily accessed in scripts.
Any examples? Since its easy I'd expect this to be trivial. I can't find anything in lua-api.factorio.com for responding to named areas.

So specific questions:
1) How exactly do I use the areas named in the map editor?
2) The map editor has a lua script area. What is this about? Can I put a control.lua code in here to set up a event handler?

thanks

Re: Map editor - how to use named areas/positions and Lua scripts section

Posted: Fri Feb 14, 2020 4:59 pm
by eradicator
1)
Best guess: LuaSurface.get_script_areas(). Which would still mean you have to check player position and test if it collides with the area.

2)
No. That's just for quick testing snippets that are executed when you drag your mouse around in that screen.