Yet another problem with my Interaction API and this time it's complaining about me using a table term when I am not using any tables.
This is one line 3 of the code, click the link above to go to the pastebin.
This used to work, but for some reason doesn't... and it started ever since I implemented interaction.drawButton() which is further down.
~Hydro
"index expected, got nil" without an array anywhere
Started by Hydrotronics, Feb 24 2016 06:46 PM
4 replies to this topic
#1
Posted 24 February 2016 - 06:46 PM
#2
Posted 24 February 2016 - 06:57 PM
You have to create a list, before you can declare functions in it:
prognam = shell.getRunningProgram()
screenX, screenY = term.getSize()
_G["interact"] = {} --You haven't use _G, if you want to use your API just in the normal shell or higher instances.
function interact.centertext(text,ypos)
local char = tostring(text)
local chars = string.len(char)
local hchars = math.floor(chars / 2)
local xpos = math.ceil((screenX / 2) - hchars)
term.setCursorPos(xpos,ypos)
print(text)
end
#3
Posted 24 February 2016 - 07:03 PM
Ta 
is this because i set it in interact.(funcname)?
I'm usually used to just making function names so this is the first time i've actually added a catagory to the functions.
is this because i set it in interact.(funcname)?
I'm usually used to just making function names so this is the first time i've actually added a catagory to the functions.
#4
Posted 24 February 2016 - 07:07 PM
Hydrotronics, on 24 February 2016 - 07:03 PM, said:
Ta 
is this because i set it in interact.(funcname)?
I'm usually used to just making function names so this is the first time i've actually added a catagory to the functions.
is this because i set it in interact.(funcname)?
I'm usually used to just making function names so this is the first time i've actually added a catagory to the functions.
Tables are very powerful types (click here for more information).
Edited by Sewbacca, 24 February 2016 - 07:13 PM.
#5
Posted 24 February 2016 - 07:07 PM
The syntax a.b is equivalent to a[ "b" ]. In other words, it accesses the table a with the key b.
Also, do not confuse tables with lists. They are tables. There are no lists in Lua.
Also, do not confuse tables with lists. They are tables. There are no lists in Lua.
Edited by KingofGamesYami, 24 February 2016 - 07:08 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











