Advertisement
Guest User

16

a guest
Jun 22nd, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.73 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. local term = require("term");
  7. local gpu = component.gpu;
  8. local running = true;
  9. x1,y1,z1 = 0,-1,0
  10. debug = component.debug;
  11. world = debug.getWorld();
  12. player = debug.getPlayer("3131CuNb");
  13.  
  14. function refreshCord ()
  15.   x,y,z = player.getPosition();
  16.   x1,y1,z1 = math.floor(x),math.floor(y)+2,math.floor(z);
  17.   end
  18.  
  19. local app = curlib.app:new();
  20. local win1 = curlib.window:new({ x = 3, y = 2,
  21.   width = 60, height = 20, shadow = true});
  22. local button = curlib.button:new({
  23.   x = win1.width - 9,
  24.   y = win1.height -1,
  25.   width = 8, height = 1,
  26.   text = "Quit", shadow = true}
  27. );
  28.  
  29. input1 = curlib.input:new({x = 10, y = 3, width = 30});
  30. input2 = curlib.input:new({x = 2, y = 17, width = 30,text="dreamcraft:item.GlowingMarshmallow"});
  31. meta = curlib.input:new({x = 35, y = 14, width = 6,text = "0"})
  32. inputBlockID = curlib.input:new({x = 35, y = 12, width = 6,text = "3327"})
  33. button.onClick = function(control, x, y)
  34.   app.status("my click function called");
  35.   running = false;
  36. end
  37.  
  38.  
  39. local btnAlign1 = curlib.button:new({ x = 2,  y = 10, width = 15, height = 2, text = "CommandBlock"});
  40. local addCode = curlib.button:new({ x = 2,  y = 3, width = 10, height = 1, text = "addCode"});
  41. local removeBlockUp = curlib.button:new({ x = 2,  y = 7, width = 15, height = 2, text = "removeBlockUp"});
  42. local btnAlign2 = curlib.button:new({ x = 2, y = 5, width = 10, height = 1, text = "give Items"});
  43. local popInfinityChest = curlib.button:new({ x = 35, y = 5, width = 5, height = 5, text = "popBlock"});
  44. local doubleAll = curlib.button:new({ x = 57, y = 8, width = 10, height = 5, text = "doubleAll"});
  45.  
  46.  
  47. btnAlign1.onClick = function (control, x, y)
  48.   refreshCord ()
  49.   world.setBlock(x1,y1,z1,137,0);
  50. end
  51.  
  52. removeBlockUp.onClick = function (control, x, y)
  53.   refreshCord ()
  54.   world.setBlock(x1,y1,z1,0,0);
  55. end
  56.  
  57.  
  58. popInfinityChest.onClick = function (control, x, y)
  59.   refreshCord ()
  60.   world.setBlock(x1,y1,z1,tonumber(inputBlockID.text),tonumber(meta.text));
  61. end
  62.  
  63.  
  64. doubleAll.onClick = function (control, x, y)
  65.       refreshCord ()
  66.       if world.getBlockId(x1,y1,z1) == 3327 then
  67.       nbt = world.getTileNBT(x1,y1,z1)
  68.     for k = 1, 244 do
  69.       nbtk=nbt["value"]["Contents"]["value"][k]
  70.       if nbtk~= nil then
  71.         nbt["value"]["Contents"]["value"][k]["value"]["intCount"]["value"]=nbtk["value"]["intCount"]["value"]*2
  72.         end
  73.       end
  74.     world.setTileNBT(x1,y1,z1,nbt)
  75.     end
  76.   end
  77.  
  78.  
  79. addCode.onClick = function (control, x, y)
  80.     refreshCord ()
  81.       inpu = input1.text
  82.       nbt = world.getTileNBT(x1,y1,z1)
  83.       nbt["value"]["Command"]["value"]=inpu
  84.       world.setTileNBT(x1,y1,z1,nbt)
  85. end
  86.  
  87. btnAlign2.onClick = function (control, x, y)
  88.   refreshCord ()
  89.   inpu = input2.text
  90.   metaData = 0
  91.   if meta.text ~= "" and inpu ~= ""  then
  92.     metaData = tonumber(meta.text)
  93.     world.insertItem(inpu,64,tonumber(metaData),"",x1,y1,z1,1)
  94.    
  95.   end
  96.  
  97. end
  98.  
  99.  
  100.  
  101.  
  102.  
  103. --adds the button to the window
  104. win1:addChild(button);
  105. --adds the text to the window
  106. win1:addChild(btnAlign1);
  107. win1:addChild(btnAlign2);
  108. win1:addChild(popInfinityChest);
  109. win1:addChild(removeBlockUp);
  110. win1:addChild(addCode);
  111. win1:addChild(doubleAll);
  112.  
  113. win1:addChild(input1);
  114. win1:addChild(input2);
  115. win1:addChild(inputBlockID);
  116. win1:addChild(meta);
  117.  
  118. --adds the window to the app
  119. app:addChild(win1);
  120.  
  121. --initializes the app and makes a first screen draw of everything
  122. app:init();
  123.  
  124.  
  125. -- application main loop
  126. while running do
  127.  
  128.   local event, addr, arg1, arg2, arg3 =  app:doEvents();
  129.  
  130.   if (event == "clipboard") then
  131.     input2.text= arg1
  132.   end
  133.   if (event == "interrupted") then
  134.     running = false;
  135.   end
  136. end
  137.  
  138.  
  139. curlib.cleanPalette();
  140.  
  141. gpu.setBackground(0);
  142. gpu.setForeground(0xc1c1c1);
  143. term.clear();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement