GPS 텔레포트 [GPS TELEPORT]


GPS를 맵상에 표시하면 그 위치로 텔레포트합니다. 매우 시끄럽습니다

Content
1 year, 11 months ago
1.0 - 1.1
129
Cheats
Owner:
Ikamusme
Source:
N/A
Homepage:
N/A
License:
MIT
Created:
3 years ago
Latest Version:
1.1.3 (1 year, 11 months ago)
Factorio version:
1.0 - 1.1
Downloaded by:
129 users

사용 방법 : CTRL + ALT + 마우스 왼 클릭으로 작동합니다
이 모드는 매우 시끄럽습니다. 혼자 할때 사용하십시오.
멀티에서 사용시 타인의 짜증을 유발합니다.

How to use : Ctrl + Alt + Mouse Left Click
This mod is very noisy. recommend single play.
When used in multiplayer, you may fight with others.

패치정보
1.0.0 : 최초 제작
1.0.1 : 썸네일 변경
1.1.0 : 팩토리오 버전과 모드 버전의 일치화 , 코드 수정
1.1.1 : ON/OFF 기능 추가 (alt+h)
1.1.2 : 맵 사이즈를 넘어갈때 발생하는 현상 수정. 맵 최대 크기를 넘지 않는 텔레포트를 적용했습니다
1.1.3 : 팩토리시모 모드의 맵 크기와 GPS 텔레포트의 처리가 맞지 않아 예외 처리 추가

Change Log
1.0.0 : Build
1.0.1 : change Thumnail
1.1.0 : update version , modify code
1.1.1 : add On/Off (alt+h)
1.1.2 : An error that occurs when the GPS coordinates exceed the map size is set as the maximum size limit of the map. (google translate)
1.1.3 : Added exception handling because Factorissimo2 mode and teleport do not match (google translate)

[source code] 1.1.3

function explode(div,str)
if (div=='') then return false end
local pos,arr = 0,{}
for st,sp in function() return string.find(str,div,pos,true) end do
table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider
pos = sp + 1 -- Jump past current divider
end
table.insert(arr,string.sub(str,pos))
return arr
end

script.on_event(defines.events.on_console_chat, function(event)
local player = game.players[event.player_index]
local message = event.message
if player.gui.top.GPS ~= nil then -- GUI가 존재할경우
if player.gui.top.GPS.state == true then
if string.sub(message,2,5) == 'gps=' then
local explode_str = explode("]",message)
local text_len = string.len(explode_str[1])
message = string.sub(explode_str[1],6,text_len)
explode_str = explode(",",message)
local x = tonumber(explode_str[1])
local y = tonumber(explode_str[2])
local world = explode_str[3]
if x == nil then x = player.position.x end
if y == nil then y = player.position.y end
if world == nil then world = 'nauvis' end -- 이동하는 좌표값에 월드가 없으면 너비스로 지정
local is_world = tostring(game.surfaces[world]) -- 월드가 있다면 table 라는 문자열로 변한
if is_world == 'table' then
-- 맵의 최대크기를 구한다
local map_size_width = game.surfaces[world].map_gen_settings.width
local map_size_height = game.surfaces[world].map_gen_settings.height
-- 이동 할려는 좌표값이 검은 영역이 아닌 경우에는 최대 제한 해제
local tile_name
local tile_check = game.surfaces[world].get_tile(x,y).valid
if tile_check then tile_name = game.surfaces[world].get_tile(x,y).name
else tile_name = "out-of-map" end
-- 맵의 범위를 제한 한다.
if x < (map_size_width / 2) * -1 then
if tile_name == "out-of-map" then x =(map_size_width / 2) * -1 end
end
if x > (map_size_width / 2) then
if tile_name == "out-of-map" then x = map_size_width / 2 end
end
if y < (map_size_height / 2) * -1 then
if tile_name == "out-of-map" then y = (map_size_height / 2) * -1 end
end
if y > (map_size_height / 2) then
if tile_name == "out-of-map" then y = map_size_height / 2 end
end
player.teleport({x,y},world)
end
end
end
end
end)

local function gps_toggle(player_index)
local player = game.players[player_index]
if player.gui.top.GPS == nil then
player.gui.top.add{name="GPS", type="checkbox", caption="Off", state=true, visible=false}
player.gui.top.GPS.state = false
player.set_shortcut_toggled("GPS-shortcut", false)
end
if player.gui.top.GPS ~= nil then
if player.gui.top.GPS.state == false then
player.gui.top.GPS.state = true
player.set_shortcut_toggled("GPS-shortcut", true)
player.gui.top.GPS.caption = "On"
else
player.gui.top.GPS.state = false
player.set_shortcut_toggled("GPS-shortcut", false)
player.gui.top.GPS.caption = "Off"
end
end
end

script.on_event("GPS-Toggle", function(event)
gps_toggle(event.player_index)
end)

script.on_event(defines.events.on_lua_shortcut, function(event)
if event.prototype_name == "GPS-shortcut" then
gps_toggle(event.player_index)
end
end)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[source code] 1.1.2
function explode(div,str)
if (div=='') then return false end
local pos,arr = 0,{}
for st,sp in function() return string.find(str,div,pos,true) end do
table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider
pos = sp + 1 -- Jump past current divider
end
table.insert(arr,string.sub(str,pos))
return arr
end

script.on_event(defines.events.on_console_chat, function(event)
local player = game.players[event.player_index]
local message = event.message
if player.gui.top.GPS ~= nil then -- GUI가 존재할경우
if player.gui.top.GPS.state == true then
if string.sub(message,2,5) == 'gps=' then
local explode_str = explode("]",message)
local text_len = string.len(explode_str[1])
message = string.sub(explode_str[1],6,text_len)
explode_str = explode(",",message)
local x = tonumber(explode_str[1])
local y = tonumber(explode_str[2])
local world = explode_str[3]
if x == nil then x = player.position.x end
if y == nil then y = player.position.y end
if world == nil then world = 'nauvis' end -- 이동하는 좌표값에 월드가 없으면 너비스로 지정
local is_world = tostring(game.surfaces[world]) -- 월드가 있다면 table 라는 문자열로 변한
if is_world == 'table' then
-- 맵의 최대크기를 구한다
local map_size_width = game.surfaces[world].map_gen_settings.width
local map_size_height = game.surfaces[world].map_gen_settings.height
-- 맵의 범위를 제한 한다.
if x < (map_size_width / 2) * -1 then x =(map_size_width / 2) * -1 end
if x > (map_size_width / 2) then x = map_size_width / 2 end
if y < (map_size_height / 2) * -1 then y = (map_size_height / 2) * -1 end
if y > (map_size_height / 2) then y = map_size_height / 2 end
player.teleport({x,y},world)
end
end
end
end
end)

local function gps_toggle(player_index)
local player = game.players[player_index]
if player.gui.top.GPS == nil then
player.gui.top.add{name="GPS", type="checkbox", caption="Off", state=true, visible=false}
player.gui.top.GPS.state = false
player.set_shortcut_toggled("GPS-shortcut", false)
end
if player.gui.top.GPS ~= nil then
if player.gui.top.GPS.state == false then
player.gui.top.GPS.state = true
player.set_shortcut_toggled("GPS-shortcut", true)
player.gui.top.GPS.caption = "On"
else
player.gui.top.GPS.state = false
player.set_shortcut_toggled("GPS-shortcut", false)
player.gui.top.GPS.caption = "Off"
end
end
end

script.on_event("GPS-Toggle", function(event)
gps_toggle(event.player_index)
end)

script.on_event(defines.events.on_lua_shortcut, function(event)
if event.prototype_name == "GPS-shortcut" then
gps_toggle(event.player_index)
end
end)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[source code] 1.1.1
function explode(div,str)
if (div=='') then return false end
local pos,arr = 0,{}
for st,sp in function() return string.find(str,div,pos,true) end do
table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider
pos = sp + 1 -- Jump past current divider
end
table.insert(arr,string.sub(str,pos))
return arr
end

script.on_event(defines.events.on_console_chat, function(event)
local player = game.players[event.player_index]
local message = event.message
if player.gui.top.GPS ~= nil then -- GUI가 존재할경우
if player.gui.top.GPS.state == true then
if string.sub(message,2,5) == 'gps=' then
local explode_str = explode("]",message)
local text_len = string.len(explode_str[1])
message = string.sub(explode_str[1],6,text_len)
explode_str = explode(",",message)
local x = tonumber(explode_str[1])
local y = tonumber(explode_str[2])
local world = explode_str[3]
if x == nil then x = player.position.x end
if y == nil then y = player.position.y end
if world == nil then world = 'nauvis' end -- 이동하는 좌표값에 월드가 없으면 너비스로 지정
local is_world = tostring(game.surfaces[world]) -- 월드가 있다면 table 라는 문자열로 변한
if is_world == 'table' then
player.teleport({x,y},world)
end
end
end
end
end)

local function gps_toggle(player_index)
local player = game.players[player_index]
if player.gui.top.GPS == nil then
player.gui.top.add{name="GPS", type="checkbox", caption="Off", state=true, visible=false}
player.gui.top.GPS.state = false
player.set_shortcut_toggled("GPS-shortcut", false)
end
if player.gui.top.GPS ~= nil then
if player.gui.top.GPS.state == false then
player.gui.top.GPS.state = true
player.set_shortcut_toggled("GPS-shortcut", true)
player.gui.top.GPS.caption = "On"
else
player.gui.top.GPS.state = false
player.set_shortcut_toggled("GPS-shortcut", false)
player.gui.top.GPS.caption = "Off"
end
end
end

script.on_event("GPS-Toggle", function(event)
gps_toggle(event.player_index)
end)

script.on_event(defines.events.on_lua_shortcut, function(event)
if event.prototype_name == "GPS-shortcut" then
gps_toggle(event.player_index)
end
end)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[source code] 1.1.0

function explode(div,str)
if (div=='') then return false end
local pos,arr = 0,{}
for st,sp in function() return string.find(str,div,pos,true) end do
table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider
pos = sp + 1 -- Jump past current divider
end
table.insert(arr,string.sub(str,pos))
return arr
end

script.on_event(defines.events.on_console_chat, function(event)
local player = game.players[event.player_index]
local message = event.message
if string.sub(message,2,5) == 'gps=' then
local explode_str = explode("]",message)
local text_len = string.len(explode_str[1])
message = string.sub(explode_str[1],6,text_len)
explode_str = explode(",",message)
local x = tonumber(explode_str[1])
local y = tonumber(explode_str[2])
local world = explode_str[3]
if x == nil then x = player.position.x end
if y == nil then y = player.position.y end
if world == nil then world = 'nauvis' end -- 이동하는 좌표값에 월드가 없으면 너비스로 지정
local is_world = tostring(game.surfaces[world]) -- 월드가 있다면 table 라는 문자열로 변한
if is_world == 'table' then
player.teleport({x,y},world)
end
end
end)