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

[lua] [syntax] Vector API

Started by Sand, 07 October 2012 - 09:19 AM
Sand #1
Posted 07 October 2012 - 11:19 AM
Syntax Issues
Lua is still fairly new to me and i was wondering if i could get some syntax help, the lua flexibility can be confusing at times, im used to rigid languages like java


displacement = vector.new(0,0,0)
listOfVectors = { a = nil, b = nil, c = nil, d = nil, e = nil}
--- So i have two problems the first is doing something like this
---will produce a syntax error
displacement.x = displacement.x + 1
-- Now that i have written that i think i  could solve it with:
displacement[1] = displacement[1] + 1
--But my other issue is
listOfVectors.a = displacement
print(listOfVectors.a:toString())
--This will get mad at me for trying to print nil
Lyqyd #2
Posted 07 October 2012 - 06:27 PM
I can't see any particular problems with what you're trying to do, except the displacement[1] line. That one wouldn't work. Is this the actual code giving you issues, or is this a separate example of what you're trying to do? We need the actual code throwing errors if this isn't it.