Teleport Player?

Place to get help with not working mods / modding interface.
Post Reply
PanTobi
Fast Inserter
Fast Inserter
Posts: 202
Joined: Fri Feb 05, 2016 12:34 am
Contact:

Teleport Player?

Post 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


PanTobi
Fast Inserter
Fast Inserter
Posts: 202
Joined: Fri Feb 05, 2016 12:34 am
Contact:

Re: Teleport Player?

Post by PanTobi »

Yeee... but how to detect when Player enter this Zone and how i actualy use it ? :o

User avatar
Impatient
Filter Inserter
Filter Inserter
Posts: 880
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Re: Teleport Player?

Post 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.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Teleport Player?

Post 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.

User avatar
Impatient
Filter Inserter
Filter Inserter
Posts: 880
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Re: Teleport Player?

Post 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.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Teleport Player?

Post 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

User avatar
Impatient
Filter Inserter
Filter Inserter
Posts: 880
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Re: Teleport Player?

Post by Impatient »

thx bro

Post Reply

Return to “Modding help”