Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while true do
- term = require("term")
- serialization = require("serialization")
- term.clear()
- term.setCursor(1,1)
- term.write("Enter type to add: ")
- type = io.read()
- if type:lower() == "recipe" then
- term.clear()
- term.setCursor(1,1)
- term.write("Enter name: ")
- local Name = io.read()
- term.clear()
- term.write("Enter type of recipe: ")
- aType = io.read()
- local recipe = {}
- table.insert(recipe, {rName = Name, rType = aType})
- for i = 1, 9 do
- term.clear()
- term.setCursor(1,1)
- term.write("Type in slot "..i..": ")
- local sType = io.read()
- term.clear()
- term.setCursor(1,1)
- term.write("Name in slot "..i..": ")
- local sName = io.read()
- if i >= 4 then
- if i == 4 then aSlot = 5 end
- if i == 5 then aSlot = 6 end
- if i == 6 then aSlot = 7 end
- if i == 7 then aSlot = 9 end
- if i == 8 then aSlot = 10 end
- if i == 9 then aSlot = 11 end
- else
- aSlot = i
- end
- table.insert(recipe, {cType = tonumber(sType), cName = sName, cSlot = aSlot})
- end
- handle = io.open("/gr/recipes.lua")
- local output = serialization.unserialize(handle:read("*all"))
- handle:close()
- table.insert(output, recipe)
- handle = io.open("/gr/recipes.lua","w")
- handle:write(serialization.serialize(output))
- handle:close()
- elseif type:lower() == "food" then
- term.clear()
- term.setCursor(1,1)
- term.write("Name of food: ")
- local sName = io.read()
- term.clear()
- term.setCursor(1,1)
- term.write("X of food: ")
- local fX = io.read()
- term.clear()
- term.setCursor(1,1)
- term.write("Y of food: ")
- local fY = io.read()
- handle = io.open("/gr/foods.lua")
- local output = serialization.unserialize(handle:read("*all"))
- handle:close()
- table.insert(output, {x = tonumber(fX), y = tonumber(fY), fName = sName})
- handle = io.open("/gr/foods.lua", "w")
- handle:write(serialization.serialize(output))
- handle:close()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement