
I have 10 x 6 Zone and if Player enter this Zone i want to teleport him to position on other Surface

How can I capture a key-press? I did not know, that this is possible.darkfrei wrote: Sat Jun 06, 2020 12:46 pm ...
Or press key to get event, on that you can check the position of the player.
You can add keys in data.lua: (code from https://mods.factorio.com/mod/OmniCar)
Code: Select all
data:extend ({
{
type = "custom-input",
name = "go-north",
key_sequence = "UP",
action = "lua"
},
{
type = "custom-input",
name = "go-east",
key_sequence = "RIGHT",
action = "lua"
},
{
type = "custom-input",
name = "go-south",
key_sequence = "DOWN",
action = "lua"
},
{
type = "custom-input",
name = "go-west",
key_sequence = "LEFT",
action = "lua"
}
})
Code: Select all
for i, go_direction in pairs ({'go-north', 'go-east', 'go-south', 'go-west'}) do
script.on_event(go_direction, function(event)
local player = game.players[event.player_index]
local orientation = (i-1)/4 -- 0 to 1
move_to (player, orientation, go_direction) -- your function
end)
end