w,h = term.getSize()
local CurrItems = {
}
local FileData = {
}
local map = {
[1] = false, [2] = false, [3] = false,
[5] = false, [6] = false, [7] = false,
[9] = false, [10] = false, [11] = false
}
count = 0
function printCentered(str, y)
term.setCursorPos(w/2 - #str/2,y)
term.write(str)
end
term.clear()
term.setCursorPos(1,1)
term.write("Enter the name of the item: ")
item = read()
term.write("Enter the X location the item is at: ")
x = read()
term.write("Enter the Y Location the item is at: ")
y = read()
term.write("Is the item craftable? (y)es or (n)o: ")
craft = read()
term.clear()
term.setCursorPos(1,1)
if (craft == "y") then
term.write("Fill in the map of how the crafting recipe goes")
printCentered("1 or 0",2)
printCentered("X X X",8)
printCentered("X X X",9)
printCentered("X X X",10)
term.setCursorPos(w/2-3,8)
value = read()
map[1] = ((value == "1" and true) or false)
term.setCursorPos(w/2,8)
value = read()
map[2] = ((value == "1" and true) or false)
term.setCursorPos(w/2+3,8)
value = read()
map[3] = ((value == "1" and true) or false)
term.setCursorPos(w/2-3,9)
value = read()
map[5] = ((value == "1" and true) or false)
term.setCursorPos(w/2,9)
value = read()
map[6] = ((value == "1" and true) or false)
term.setCursorPos(w/2+3,9)
value = read()
map[7] = ((value == "1" and true) or false)
term.setCursorPos(w/2-3,10)
value = read()
map[9] = ((value == "1" and true) or false)
term.setCursorPos(w/2,10)
value = read()
map[10] = ((value == "1" and true) or false)
term.setCursorPos(w/2+3,10)
value = read()
map[11] = ((value == "1" and true) or false)
for i = 1,11 do
if (i ~= 4 and i ~= 8) then
if (map[i]) then
count = count + 1
end
end
end
end
CurrItems[item] = {
count = count,
location = {tonumber(x),tonumber(y)},
map = map
}
File = fs.open("disk/items.txt", "r")
FileData = textutils.unserialise(File.readAll())
table.insert(FileData[item], CurrItems[item])
File.close()
File = fs.open("disk/items.txt", "w")
File.write(textutils.serialise(FileData))
File.close()
--print(item)
--print(CurrItems[item].count)
--print(CurrItems[item].location[1])
--print(CurrItems[item].location[2])
--for i = 1,11 do
-- if (i ~= 4 and i ~= 8) then
-- print(CurrItems[item].map[i])
-- end
--end
Comments