This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
CopyYou's profile picture

[tekkit classic/computercraft 1.33] table.insert

Started by CopyYou, 14 September 2014 - 10:30 AM
CopyYou #1
Posted 14 September 2014 - 12:30 PM
hello there,

First of all, I am still using computercraft 1.33, wich is included in the tekkit classic modpack(i never moved on xD, precious, precious worlds). I apologize.
I am pretty new at Lua coding, and i can't figure this out, so i hope i'm at the right place for this.

I am trying to write a function that adds a string at the end of a table for a sort of login system i've been writing.
To write this i started learning how tables exactly work, and i think i have a mild understanding of them now, however when i tried to use the function table.insert() i get the error "attempt to call nil", wich is supposed to mean the function doesn't exist, but since this is supposed to be an ingrained function of lua i don't understand how that would work.


local Table = {"One"}
table.insert(Table, "Three")

Does anyone know how I can solve this, or at the very least work around this?

Thanks in advance,
CopyYou
Lyqyd #2
Posted 14 September 2014 - 06:44 PM
I'd imagine your actual code doesn't capitalize the variable, so you've got this instead:


local table = {"one"}
table.insert(table, "three")

That of course wouldn't work, since you'd have overwritten the table API. If that isn't the case, try restarting the in-game computer, as you may have accidentally mangled the table API with earlier testing code. Once the in-game computer has rebooted, go straight into the lua prompt and try your code, without the local (since it localizes the variable to just that entry in the lua prompt). Be sure not to call the table you create "table". If that still doesn't work, let us know.
CopyYou #3
Posted 16 September 2014 - 08:07 PM
That indeed did the trick. I did indeed start without caps, but i did caps it after a while. Thank you!