Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1. /c
  2.  
  3. local pl = game.player;
  4.  
  5. local tpPoints =
  6. {
  7.   { name = "Center", pos = {0, 0}},
  8.   { name = "PH", pos = {-412, -424}},
  9.   { name = "Petr", pos = {-150, -350}},  
  10.   { name = "Coke", pos = {-550, -320}},
  11.   { name = "Alien", pos = {-144, 100}},
  12.  
  13.   { name = "Q Input", pos = {215, -350}},
  14.   { name = "Q[1]", pos = {-375, -800}},
  15.   { name = "Q[2]", pos = {-700, -100}},
  16.   { name = "Q[3]", pos = {-715, 450}},
  17.   { name = "Q[4]", pos = {-1165, 865}},
  18.  
  19.   { name = "I Output", pos = {84, -406}},
  20.   { name = "I Input", pos = {110, -392}},
  21.   { name = "I[0]", pos = {-510, -208}},  
  22.  
  23.   { name = "L Input", pos = {175, -600}},
  24.   { name = "L[0]", pos = {78, 1}},  
  25.  
  26.   { name = "A Input", pos = {177, -530}},
  27.   { name = "A[0]", pos = {10, -1200}},
  28.  
  29.   { name = "Cop Input", pos = {177, -462}},
  30.   { name = "Cop[1]", pos = {-820, 420}},
  31.  
  32.   { name = "CR Input", pos = {177, -662}},
  33.   { name = "CR[0]", pos = {0, -380}},
  34.  
  35.   { name = "Tin Input", pos = {177, -800}},
  36.  
  37.   { name = "Stone[0]", pos = {-927, 277}},
  38.  
  39.   { name = "Boiler", pos = {91, -60}},
  40.   { name = "Coal[0]", pos = {-85, -200}}
  41. };
  42.  
  43. function getPos (btnName)
  44.  
  45.   for _, tpPoint in pairs (tpPoints) do  
  46.     if tpPoint.name == btnName then    
  47.       return tpPoint.pos;    
  48.     end
  49.   end
  50.  
  51.   return nil;
  52. end
  53.  
  54. script.on_event(defines.events.on_gui_click, function(event)
  55.  
  56.   local pos = getPos(event.element.caption);
  57.  
  58.   if (pos ~= nil) then
  59.     pl.teleport (pos);
  60.   end
  61.  
  62. end)
  63.  
  64.  
  65. local frameCont = pl.gui.left;
  66.  
  67. if frameCont.tpFrame ~= nil then frameCont.tpFrame.destroy() end;
  68.  
  69. local tpFrame = frameCont.add{type = "frame", name = "tpFrame", direction = "vertical"};
  70. local tpFrameTable = tpFrame.add{type ="table", name = "tpFrameTable", column_count = 1 };
  71.  
  72. for index, tpPoint in pairs (tpPoints)
  73.   do tpFrameTable.add {type = "button", name = "tpButton" .. index, caption = tpPoint.name };
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement