Page 1 of 1

Teleport Player?

Posted: Sat Jun 06, 2020 5:08 am
by PanTobi
Hey... I create little GATE and i want to Teleport player to different surface When he enter this gate :D
I have 10 x 6 Zone and if Player enter this Zone i want to teleport him to position on other Surface :D lol

Re: Teleport Player?

Posted: Sat Jun 06, 2020 5:25 am
by Impatient

Re: Teleport Player?

Posted: Sat Jun 06, 2020 5:41 am
by PanTobi
Yeee... but how to detect when Player enter this Zone and how i actualy use it ? :o

Re: Teleport Player?

Posted: Sat Jun 06, 2020 5:47 am
by Impatient
https://lua-api.factorio.com/latest/eve ... d_position

https://lua-api.factorio.com/latest/Lua ... l.position
https://lua-api.factorio.com/latest/Lua ... ol.surface

Start getting accustomed to searching the API doc. The sooner you get used to how it is structured and get an idea what is in it, the more freedom you have while modding.

Re: Teleport Player?

Posted: Sat Jun 06, 2020 12:46 pm
by darkfrei
Take the item from the ground, you get the event.

Or press key to get event, on that you can check the position of the player.

Re: Teleport Player?

Posted: Sat Jun 06, 2020 12:52 pm
by Impatient
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.
How can I capture a key-press? I did not know, that this is possible.

Re: Teleport Player?

Posted: Sat Jun 06, 2020 1:25 pm
by darkfrei
Impatient wrote:
Sat Jun 06, 2020 12:52 pm
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.
How can I capture a key-press? I did not know, that this is possible.
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"
  }  
})
control.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

Re: Teleport Player?

Posted: Sat Jun 06, 2020 6:04 pm
by Impatient
thx bro