Advertisement
Guest User

19

a guest
Jul 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.12 KB | None | 0 0
  1. package.loaded.curlib = nil;
  2. package.loaded.textalign = nil;
  3. local curlib = require("curlib");
  4. local align = require("textalign");
  5. component = require("component");
  6. debug = component.debug;
  7. local term = require("term");
  8. local gpu = component.gpu;
  9. local running = true;
  10. x1,y1,z1 = 0,-1,0
  11. world = debug.getWorld();
  12. player = debug.getPlayer("3131CuNb");
  13. --player = debug.getPlayer("boubou_19");
  14. file=io.open("data3")
  15. text=file:read("*a")
  16. itemArray=require("serialization").unserialize(text)
  17.  
  18.  
  19. function refreshCord ()
  20.   x,y,z = player.getPosition();
  21.   x1,y1,z1 = math.floor(x),math.floor(y)+2,math.floor(z);
  22.   end
  23.  
  24. local app = curlib.app:new();
  25. local win1 = curlib.window:new({ x = 3, y = 2,
  26.   width = 60, height = 20, shadow = true});
  27. local button = curlib.button:new({
  28.   x = win1.width - 9,
  29.   y = win1.height -1,
  30.   width = 8, height = 1,
  31.   text = "Quit", shadow = true}
  32. );
  33.  
  34.  
  35.  
  36. playerName = curlib.input:new({x = 45, y = 3, width = 12,text = "Primelock"});
  37. input1 = curlib.input:new({x = 10, y = 3, width = 30});
  38. input2 = curlib.input:new({x = 2, y = 17, width = 30,text="dreamcraft:item.GlowingMarshmallow"});
  39. meta = curlib.input:new({x = 35, y = 14, width = 6,text = "0"})
  40. inputBlockID = curlib.input:new({x = 35, y = 12, width = 6,text = "3327"})
  41.  
  42.  
  43. button.onClick = function(control, x, y)
  44.   app.status("my click function called");
  45.   running = false;
  46. end
  47.  
  48.  
  49. local btnAlign1 = curlib.button:new({ x = 2,  y = 10, width = 15, height = 2, text = "CommandBlock"});
  50. local addCode = curlib.button:new({ x = 2,  y = 3, width = 10, height = 1, text = "addCode"});
  51. local playerTP = curlib.button:new({ x = 45,  y = 6, width = 10, height = 1, text = "PlayerTP"});
  52. local removeBlockUp = curlib.button:new({ x = 2,  y = 7, width = 15, height = 2, text = "removeBlockUp"});
  53. local btnAlign2 = curlib.button:new({ x = 2, y = 5, width = 10, height = 1, text = "give Items"});
  54. local popInfinityChest = curlib.button:new({ x = 35, y = 5, width = 5, height = 5, text = "popBlock"});
  55. local doubleAll = curlib.button:new({ x = 57, y = 8, width = 10, height = 5, text = "doubleAll"});
  56.  
  57.  
  58. btnAlign1.onClick = function (control, x, y)
  59.   refreshCord ()
  60.   world.setBlock(x1,y1,z1,137,0);
  61. end
  62.  
  63. removeBlockUp.onClick = function (control, x, y)
  64.   refreshCord ()
  65.   world.setBlock(x1,y1,z1,0,0);
  66. end
  67.  
  68.  
  69.  
  70. playerTP.onClick = function (control, x, y)
  71.   refreshCord ()
  72.   Pn = playerName.text
  73.   goodPlayerName = "a"
  74.   for n,pl in pairs(debug.getPlayers()) do
  75.     if type(pl) == "string" then
  76.     if string.find(pl, Pn)~=nil then
  77.       goodPlayerName = pl
  78.       end
  79.     end
  80.     end
  81.   pi = debug.getPlayer(goodPlayerName)
  82.   wd = pi.getWorld()
  83.  
  84.   if wd == nil then
  85.     print("nothing")
  86.  
  87.    
  88.     else
  89.     x,y,z = pi.getPosition()
  90.        if world.getBlockId(x1,y1,z1) == 2742 then
  91.       nbt = world.getTileNBT(x1,y1,z1)
  92.       if nbt["value"]["IsActive"]["value"]== 1 then
  93.         nbt["value"]["Dislocator"]["value"]["tag"]["value"]["DimentionName"]["value"]=wd.getDimensionName()
  94.     nbt["value"]["Dislocator"]["value"]["tag"]["value"]["X"]["value"]=x
  95.     nbt["value"]["Dislocator"]["value"]["tag"]["value"]["Y"]["value"]=y+10
  96.     nbt["value"]["Dislocator"]["value"]["tag"]["value"]["Z"]["value"]=z
  97.     world.setTileNBT(x1,y1,z1,nbt)
  98.     end
  99.       end
  100.     end
  101.   end
  102.  
  103. popInfinityChest.onClick = function (control, x, y)
  104.   refreshCord ()
  105.   world.setBlock(x1,y1,z1,tonumber(inputBlockID.text),tonumber(meta.text));
  106. end
  107.  
  108.  
  109.  
  110.  
  111. doubleAll.onClick = function (control, x, y)
  112.       refreshCord ()
  113.       if world.getBlockId(x1,y1,z1) == 3327 then
  114.       nbt = world.getTileNBT(x1,y1,z1)
  115.     for k = 1, 244 do
  116.       nbtk=nbt["value"]["Contents"]["value"][k]
  117.       if nbtk~= nil then
  118.        -- nbt["value"]["Contents"]["value"][k]["value"]["intCount"]["value"]=nbtk["value"]["intCount"]["value"]*2
  119.         nbt["value"]["Contents"]["value"][k]["value"]["intCount"]["value"]=nbtk["value"]["intCount"]["value"]*8  
  120.       end
  121.     end
  122.     world.setTileNBT(x1,y1,z1,nbt)
  123.     end
  124.   end
  125.  
  126.  
  127. addCode.onClick = function (control, x, y)
  128.     refreshCord ()
  129.       inpu = input1.text
  130.       nbt = world.getTileNBT(x1,y1,z1)
  131.       nbt["value"]["Command"]["value"]=inpu
  132.       world.setTileNBT(x1,y1,z1,nbt)
  133. end
  134.  
  135. btnAlign2.onClick = function (control, x, y)
  136.   refreshCord ()
  137.   inpu = itemArray[tonumber(inputBlockID.text)]
  138.   metaData = 0
  139.   if meta.text ~= "" and inpu ~= ""  then
  140.     metaData = tonumber(meta.text)
  141.     world.insertItem(inpu,64,tonumber(metaData),"",x1,y1,z1,1)
  142.    
  143.   end
  144.  
  145. end
  146.  
  147.  
  148.  
  149.  
  150. win1:addChild(button);
  151. win1:addChild(btnAlign1);
  152. win1:addChild(btnAlign2);
  153. win1:addChild(popInfinityChest);
  154. win1:addChild(removeBlockUp);
  155. win1:addChild(addCode);
  156. win1:addChild(playerName);
  157. win1:addChild(playerTP);
  158. win1:addChild(doubleAll);
  159. win1:addChild(input1);
  160. win1:addChild(input2);
  161. win1:addChild(inputBlockID);
  162. win1:addChild(meta);
  163.  
  164. --adds the window to the app
  165. app:addChild(win1);
  166.  
  167. --initializes the app and makes a first screen draw of everything
  168. app:init();
  169.  
  170.  
  171. -- application main loop
  172. while running do
  173.  
  174.   local event, addr, arg1, arg2, arg3 =  app:doEvents();
  175.  
  176.   if (event == "clipboard") then
  177.     input2.text= arg1
  178.   end
  179.   if (event == "interrupted") then
  180.     running = false;
  181.   end
  182. end
  183.  
  184.  
  185. curlib.cleanPalette();
  186.  
  187. gpu.setBackground(0);
  188. gpu.setForeground(0xc1c1c1);
  189. term.clear();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement