Posted 17 March 2015 - 11:45 PM
hello all trying to make a drive info program for a monitor on spacial io i am trying to make it auto create the buttons using a modified version of direwolf20's button api i am getting an error and having a problem finding how to fix it. the main issue is that i am getting a nil error from a table i set up
--init and load-------------------
os.loadAPI("button")
c=peripheral.wrap("top")
invintory={}
direct="west"
local Rname=_
active={}
mon=peripheral.find("monitor")
xendv,yendv=mon.getSize()
print(mon.getSize())
print(xendv..yendv)
size={}
size={xmin=1,xmax = 10,ymin = 1,ymax = 3,xend = xendv,yend = yendv , xval = size.xmax - size.xmin , yval= size.ymax - size.ymin} -- error is here in the xvalues it keeps giving me nil for any of the values after in the outputs even tho i have defined them
print(size.xmin)
print("monitor size is "..xendv .." "..yendv)
print(size.yend .. size.xend)
------------------------------
function Materialize()
end
function Dematerialiaze()
end
------------------------------
function Stack(Rname,direct)
v=c.getInventorySize()
for i=1,v do
print("checking slot"..i)
sleep()
cond= c.getStackInSlot(i)
if cond then
stack = cond.display_name
print("stackname is ".. stack)
table.insert(invintory,i,stack)
print("item in slot "..i.."is ".. invintory[i])
else
end
end
for i=1,#invintory do
if invintory[i] == Rname then
print("requested area is "..Rname)
print("moving required area")
c.pushItem(direct,i)
end
for i=1,v do
if cond then
stack =cond.display_name
print("checking if required area is still in slot "..i)
if stack == Rname then print("true") print("attempting to move area")
for i=1,#invintory do
if invintory[i] == Rname then
print("requested area is "..Rname)
print("moving required area")
c.PushItem(tostring(direct),i)
end
end
end
end
end
end
end
-------------------
function createButton()
local i = 1
v=c.getInventorySize()
print("enter")
while i<=v do
cond=c.getStackInSlot(i)
if cond then
print(cond.display_name)
print("enter")
button.setTable(cond.display_name,Stack,tostring(cond.display_name),direct)
print("xmin is "..size.xmin)
if not button.checkLoc(size.xval,size.yval) then button.setLoc(cond.display_name,size.xmin,size.xmax,size.ymin,size.ymax)
button.screen()
else
print("enter")
while button.checkLoc(size.xval,size.yval) do
size.xmin=size.xmin+10 size.xmax=size.xmax+10 if size.xmax >= xend then size.ymin=size.ymin+5 size.ymax=size.ymax+5 size.xmin=1 size.xmax=10 end
if not button.checkLoc(xval,yval) then button.setLoc(cond.display_name,size.xmin,size.xmax,size.ymin,size.ymax) button.screen() end
print("exit")
end
i=1+1
end
end
i=i+1
end
end
------------------
function getClick()
event,side,x,y = os.pullEvent("monitor_touch")
button.checkxy(x,y)
end
----------------
mon.clear()
createButton()
--getClick()