6 posts
Posted 27 October 2012 - 02:19 PM
Hi,
http://pastebin.com/QzUpBh0W is the Startup scipt.
http://pastebin.com/NGZGcsnC is the API.
I get the error" startup:3: attempt to perform arithmetic __div on nil and nil" when ran. Reloaded the world, restarted minecraft and it still has the error, am I doing something wrong? Also, does it help then inside the print.center() it used to have "termW/2-#str/2" is that maybe where the errors being created from?
Thanks,
Jazza
1548 posts
Location
That dark shadow under your bed...
Posted 27 October 2012 - 02:39 PM
you need quotes around
resources/APIs/menu
on line 3 in the load api command or it thinks resources, APIs and menu are all variables to be divided
2088 posts
Location
South Africa
Posted 27 October 2012 - 02:39 PM
Your menu API file has a few mistakes
Spoiler
--menu API V1.0
--Variables
local menuSelect = 1
local menuRunning = true
termW, termH = term.getSize()
--Functions
function print.center(str,yLine)
term.setCursorPos(0,yLine)
print(str)
end
function printMenu(title,...)
menuOps = {...}
while menuRunning do
clear()
print.center(title) -- has no yLine
term.setCursorPos(2,1)
for local i=1,#menuOps,1 do -- Try for i=1,#menuOps do
if i=menuSelect then term.setTextColor(red) end print.center(menuOps[i],i+1) -- if i == menuSelect (needs two ='s
end
local event, local key = os.pullEvent("key") -- Try making it just event, key = os.pullEvent("key")
if key == 200 and menuSelect > 1 then
menuSelect = menuSelect - 1
elseif key == 208 and menuSelect < #menuOps then
menuSelect = menuSelect + 1
elseif key == 28 then
local menuRunning false -- local menuRunning = false
end
end
end
Not sure if these are the problems.
6 posts
Posted 27 October 2012 - 02:51 PM
Ah, thank both of you for that =D Now it works, but has a few little errors. I should be able to work it out tho =)
1548 posts
Location
That dark shadow under your bed...
Posted 27 October 2012 - 02:52 PM
cool stuff. good luck
6 posts
Posted 27 October 2012 - 03:32 PM
Alright, I got it to work. I also added a solved tag to the title. I added a colour argument, so you can specify what you want.
--menu API V1.0
--Variables
local menuSelect = 3
local menuRunning = true
termW, termH = term.getSize()
--Functions
function printcenter(str,yLine)
term.setCursorPos(termW/2-#str/2,yLine)
print(str)
end
function printMenu(...)
menuOps = {...}
while menuRunning do
term.clear()
term.setCursorPos(1,1)
for i = 2,#menuOps,1 do
if i == menuSelect then
term.setTextColor(tonumber(menuOps[1]))
printcenter(menuOps[i],i+1)
else
term.setTextColor(1)
printcenter(menuOps[i],i+1)
end
end
event, key = os.pullEvent("key")
if key == 200 and menuSelect > 3 then
menuSelect = menuSelect - 1
elseif key == 208 and menuSelect < #menuOps then
menuSelect = menuSelect + 1
elseif key == 28 then
local menuRunning = false
end
end
end