I wrote a simple tower building script/program, it works, but then I thought " I'm going to use this code a lot" so I started an Inventory.lua filled with functions no scripting of its own.
If I run this I get attempt to index upvalue 'Inventory' (a boolean value)
Inventory.lua
local robot = require ("robot")
slot = 1
function nextFull()
if robot.count(slot) == 0 then
slot = slot + 1
robot.select(slot)
end
end
build.lua
local tArgs = {...}
local length = tonumber(tArgs[1])
local width = tonumber(tArgs[2])
local height = tonumber(tArgs[3])
local robot = require ("robot")
local Inventory = require ("Inventory")
local slot = 1
toggle = true
print ("Enter Length for Structure")
length = io.read()
print ("Width?")
width = io.read()
print = ("Height?")
height = io.read()
length = length - 1
width = width - 1
robot.select(1)
function block()
if toggle == true then
for i=2,length do
Inventory.nextFull()
robot.placeDown()
robot.forward()
toggle = false
end
else
for j=2,width do
Inventory.nextFull()
robot.placeDown()
robot.forward()
toggle = true
end
end
end
function row()
block()
robot.turnRight()
end
function layer()
for k=0,3 do
row()
end
end
layer()
for l=1,height do
robot.up()
layer()
end
robot.turnRight()
robot.back()
robot.back()
robot.select(16)
for m=1,height do
robot.down()
robot.place()
end
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
I wrote a simple tower building script/program, it works, but then I thought " I'm going to use this code a lot" so I started an Inventory.lua filled with functions no scripting of its own.
If I run this I get attempt to index upvalue 'Inventory' (a boolean value)
Inventory.lua
build.lua
Link to post
Share on other sites