Advertisement
Guest User

Untitled

a guest
May 1st, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.55 KB | None | 0 0
  1. /c
  2.  
  3. local pl = game.player;
  4.  
  5. local prevPos = nil;
  6. local memPos = nil;
  7.  
  8. local tpSpecPoints = { "S", "U", "M", "L", "C", "R", "B", "D", "P" };
  9.  
  10. local tpPoints =
  11. {
  12.   { name = "HighTech", pos = {96, 22}},
  13.  
  14.   { name = "Iron", pos = {274, -1485}},
  15.   { name = "Copper", pos = {103, -1803}},
  16.   { name = "Chromium", pos = {103, -2766}},
  17.   { name = "Lead", pos = {103, -3766}},
  18.  
  19.   { name = "PH", pos = {-586, -829}},
  20.   { name = "Petr1", pos = {-150, -350}},
  21.   { name = "Petr2", pos = {-155, -495}},
  22.   { name = "Coke", pos = {-550, -320}},
  23.   { name = "Tar Proc", pos = {-1640, -250}},
  24.   { name = "Alien1", pos = {-144, 100}},
  25.   { name = "Alien2", pos = {-116, 250}},
  26.   { name = "Alien3", pos = {-165, 423}},
  27.   { name = "Alien4", pos = {-165, 653}},
  28.  
  29.   { name = "Sand", pos = {432, -323}},
  30.   { name = "Wood", pos = {-777, -105}},
  31.  
  32.   { name = "-------- Q Input / Output", pos = {83, -343}},
  33.   { name = "Q[1]", pos = {-375, -800}},
  34.   { name = "Q[2]", pos = {-700, -100}},
  35.   { name = "Q[3]", pos = {-715, 450}},
  36.   { name = "Q[4]", pos = {-1165, 865}},
  37.  
  38.   { name = "I[0]", pos = {-510, -208}},
  39.   { name = "L[0]", pos = {-300, -1540}},
  40.   { name = "Cop[0]", pos = {-470, -1116}},
  41.  
  42.   { name = "-------- T Input / Output", pos = {84, -716}},  
  43.   { name = "T[0]", pos = {-715, -365}},
  44.   { name = "T[1]", pos = {-1904, -270}},
  45.  
  46.   { name = "Stone[0]", pos = {-927, 277}},
  47.  
  48.   { name = "Boiler", pos = {91, -60}},
  49.   { name = "Coal[0]", pos = {-85, -200}},
  50.   { name = "----------------Nexelit Input", pos = {177, -862}},
  51.   { name = "Nexelit[0]", pos = {68, -580}},
  52.   { name = "Nexelit[1]", pos = {580, -376}}
  53. };
  54.  
  55. function getPos (btn)
  56.  
  57.   if btn.name == "SpecM" then
  58.     return memPos;
  59.   elseif btn.name == "SpecC" then
  60.     return { 0, 0};
  61.   elseif btn.name == "SpecB" or btn.name == "SpecP" then
  62.     return prevPos;
  63.   elseif btn.name == "SpecU" then
  64.     return { pl.position.x, pl.position.y - 100};
  65.   elseif btn.name == "SpecD" then
  66.     return { pl.position.x, pl.position.y + 100};
  67.   elseif btn.name == "SpecL" then
  68.     return { pl.position.x - 100, pl.position.y};
  69.   elseif btn.name == "SpecR" then
  70.     return { pl.position.x + 100, pl.position.y};
  71.   end
  72.  
  73.   for _, tpPoint in pairs (tpPoints) do  
  74.     if tpPoint.name == btn.caption then    
  75.       return tpPoint.pos;    
  76.     end
  77.   end
  78.  
  79.   return nil;
  80. end
  81.  
  82. script.on_event(defines.events.on_gui_click, function(event)
  83.  
  84.   local btn = event.element;
  85.  
  86.   if btn.name == "SpecS" then
  87.     memPos = pl.position;
  88.     return;
  89.   end
  90.  
  91.   local pos = getPos(btn);
  92.  
  93.  
  94.   if (pos ~= nil) then
  95.     prevPos = pl.position;
  96.     pl.teleport (pos);
  97.   end
  98.  
  99. end)
  100.  
  101.  
  102. local frameCont = pl.gui.left;
  103.  
  104.  
  105. if frameCont.tpOffsetFrame ~= nil then frameCont.tpOffsetFrame.destroy() end;
  106. local tpOffsetFrame = frameCont.add{type = "frame", name = "tpOffsetFrame", direction = "vertical"};
  107. local tpOffsetFrameTable = tpOffsetFrame.add{type ="table", name = "offsetTpFrameTable", column_count = 3, row_count = 3 };
  108. for index, tpSpecBtn in pairs (tpSpecPoints) do
  109.   local specBtn = tpOffsetFrameTable.add ({type = "button", name = "Spec" .. tpSpecBtn, caption = tpSpecBtn });
  110.   specBtn.style.maximal_width = 40;
  111. end
  112.  
  113.  
  114. if frameCont.tpFrame ~= nil then frameCont.tpFrame.destroy() end;
  115. local tpFrame = frameCont.add{type = "frame", name = "tpFrame", direction = "vertical"};
  116. local tpFrameTable = tpFrame.add{type ="table", name = "tpFrameTable", column_count = 1 };
  117. for index, tpPoint in pairs (tpPoints) do
  118.   tpFrameTable.add ({type = "button", name = "tpButton" .. index, caption = tpPoint.name });  
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement