Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Redstone Controller Installer
- function download(code, location)
- url = http.get("https://www.pastebin.com/raw/"..code)
- f = fs.open(location,"w") --#opens file in write mode, has to be specified with location
- f.write(url.readAll()) --#reads every byte of url and writes it to location
- f.close() --# always close the file >:c
- return true --#return true so function can be used in ifs
- end
- if peripheral.getType("top") ~= "modem" then
- print("No Modem Found. Please Install Modem into back of computer then run the code again.");
- else
- term.clear();
- term.setCursorPos(1,1);
- local minecraftID;
- local displayName;
- local increment;
- local color;
- while true do
- term.clear();
- term.setCursorPos(1,1)
- print("Please enter the item id that you wish to add \n (Ex. minecraft:redstone) ALL LOWERCASE\n> ");
- term.setCursorPos(3, 3)
- minecraftID = read();
- print("Please enter the Display Name of the item that you wish to add (Ex. Redstone Dust)\n> ")
- term.setCursorPos(3, 6)
- displayName = read();
- print("Please Type the amount that you want to increment by. \n> ");
- term.setCursorPos(3, 9)
- increment = read();
- term.clear();
- term.setCursorPos(1,1)
- print("===========================================");
- print("Please Enter The Display Color");
- print("===========================================");
- print(" 1) White 2) Orange 3) Magenta");
- print(" 4) Light Blue 5) yellow 6) lime");
- print(" 7) Pink 8) Gray 9) Light Gray");
- print("10) Cyan 11) Purple 12) Blue");
- print("13) Brown 14) Green 15) Red");
- print("===========================================");
- print("> ")
- term.setCursorPos(3, 10)
- while true do
- color = tonumber(read());
- if color == nil or color < 1 or color > 16 then
- print("Error Color Not Found. Try Again.")
- else
- break;
- end
- end
- local displayColor;
- if color == 1 then color = colors.white; displayColor = "White";
- elseif color == 2 then color = colors.orange; displayColor = "Orange";
- elseif color == 3 then color = colors.magenta; displayColor = "Magenta";
- elseif color == 4 then color = colors.lightBlue; displayColor = "Light Blue";
- elseif color == 5 then color = colors.yellow; displayColor = "Yellow";
- elseif color == 6 then color = colors.lime; displayColor = "Lime";
- elseif color == 7 then color = colors.pink; displayColor = "Pink";
- elseif color == 8 then color = colors.gray; displayColor = "Gray";
- elseif color == 9 then color = colors.lightGray; displayColor = "Light Gray";
- elseif color == 10 then color = colors.cyan; displayColor = "Cyan";
- elseif color == 11 then color = colors.purple; displayColor = "Purple";
- elseif color == 12 then color = colors.blue; displayColor = "Blue";
- elseif color == 13 then color = colors.brown; displayColor = "Brown";
- elseif color == 14 then color = colors.green; displayColor = "Green";
- elseif color == 15 then color = colors.red; displayColor = "Red";
- end
- term.clear();
- term.setCursorPos(1,1);
- print("=========================================");
- print("Is This Correct? [y/n]")
- print("=========================================");
- print("Item ID: " .. minecraftID);
- print("Display Name: " .. displayName);
- print("Increment: " .. increment);
- print("Color: " .. displayColor);
- print("=========================================");
- print("> ")
- term.setCursorPos(3, 9)
- local answer = read();
- if answer == "y" then break; end
- end
- local data = {};
- data["itemID"] = minecraftID;
- data["displayName"] = displayName;
- data["increment"] = increment;
- data["color"] = color;
- os.setComputerLabel("[" .. displayName .. "] Trade Station Controller");
- fs.delete("data.dat");
- local file = fs.open("data.dat", "w");
- file.write(textutils.serialize(data));
- file.close();
- fs.delete("/SmallGUI/init.lua")
- print("Downloading SmallGUI Library...");
- download("kY7CPumC", "/SmallGUI/init.lua");
- fs.delete("startup.lua");
- print("Downloading Trade Station Controller Program...");
- download("bGmPju0E", "startup.lua");
- os.reboot();
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement