Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /c
- local pl = game.player;
- local prevPos = nil;
- local memPos = nil;
- local prevMemPos = nil;
- local tpSpecPoints = { "S", "U", "M", "L", "C", "R", "B", "D", "P" };
- local tpPoints =
- {
- { name = "Solid fuel", pos = {-1660, -1761}},
- { name = "Cir2", pos = {209, 1718}},
- { name = "Ammonia", pos = {-1660, 668}},
- { name = "Food", pos = {-847, 1295}},
- { name = "Iron", pos = {296, -1457}},
- { name = "Copper", pos = {260, -1803}},
- { name = "Chromium", pos = {213, -2766}},
- { name = "Lead", pos = {213, -3766}},
- { name = "Coke(1)", pos = {-550, -320}},
- { name = "Coke(2)", pos = {-281, -2811}},
- { name = "Tar Proc", pos = {-1640, -250}},
- { name = "Alien2", pos = {-165, 653}},
- { name = "Sand", pos = {2898, -156}},
- { name = "-------- Q Input / Output", pos = {83, -343}},
- { name = "Borax", pos = {68, -580}},
- { name = "Engine", pos = {-1007, -1677}},
- { name = "Build", pos = {846, 1032}}
- };
- function getPos (btn)
- if btn.name == "SpecM" then
- return memPos;
- elseif btn.name == "SpecC" then
- return { 0, 0};
- elseif btn.name == "SpecB" then
- return prevMemPos;
- elseif btn.name == "SpecP" then
- return prevPos;
- elseif btn.name == "SpecU" then
- return { pl.position.x, pl.position.y - 100};
- elseif btn.name == "SpecD" then
- return { pl.position.x, pl.position.y + 100};
- elseif btn.name == "SpecL" then
- return { pl.position.x - 100, pl.position.y};
- elseif btn.name == "SpecR" then
- return { pl.position.x + 100, pl.position.y};
- end
- for _, tpPoint in pairs (tpPoints) do
- if tpPoint.name == btn.caption then
- return tpPoint.pos;
- end
- end
- return nil;
- end
- script.on_event(defines.events.on_gui_click, function(event)
- local btn = event.element;
- if btn.name == "SpecS" then
- prevMemPos = memPos;
- memPos = pl.position;
- return;
- end
- local pos = getPos(btn);
- if (pos ~= nil) then
- prevPos = pl.position;
- pl.teleport (pos);
- end
- end)
- local frameCont = pl.gui.left;
- if frameCont.tpOffsetFrame ~= nil then frameCont.tpOffsetFrame.destroy() end;
- local tpOffsetFrame = frameCont.add{type = "frame", name = "tpOffsetFrame", direction = "vertical"};
- local tpOffsetFrameTable = tpOffsetFrame.add{type ="table", name = "offsetTpFrameTable", column_count = 3, row_count = 3 };
- for index, tpSpecBtn in pairs (tpSpecPoints) do
- local specBtn = tpOffsetFrameTable.add ({type = "button", name = "Spec" .. tpSpecBtn, caption = tpSpecBtn });
- specBtn.style.maximal_width = 40;
- end
- if frameCont.tpFrame ~= nil then frameCont.tpFrame.destroy() end;
- local tpFrame = frameCont.add{type = "frame", name = "tpFrame", direction = "vertical"};
- local tpFrameTable = tpFrame.add{type ="table", name = "tpFrameTable", column_count = 1 };
- for index, tpPoint in pairs (tpPoints) do
- tpFrameTable.add ({type = "button", name = "tpButton" .. index, caption = tpPoint.name });
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement