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

Place to get help with not working mods / modding interface.
Post Reply
adamius
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Mar 19, 2018 9:18 am
Contact:

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

Post 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

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”