Bomb Bloke, on 19 September 2015 - 01:44 PM, said:
I actually made that on the original code. Ended up figuring out what the problem was. Apparently, the sColor variable should be declared either as a pointer (I believe this is the term for 'local sColor') outside the if/else statement or as a global variable. I didn't know that local variables inside if/else statements could only be used inside these statements.
KingofGamesYami, on 19 September 2015 - 12:10 PM, said:
addButton(1, 5, 9, 3, 'color', defaultColors[9], 2)...
function addButton(id, decrement, increment, y, type, color, value)
registeredButtons[id] = {}
registeredButtons[id]['minX'] = decrement
registeredButtons[id]['maxX'] = increment
registeredButtons[id]['y'] = y
registeredButtons[id]['type'] = type
registeredButtons[id]['btn_color'] = color
registeredButtons[id]['value'] = value
end
...local bColor = defaultColors[data.btn_color]
You end up with nil, since defaultColors[ 256 ] doesn't exist. From the first snippet, change it to simply '9', not defaultColors[ 9 ] or change the last snippet to just data.btn_color.
If you didn't already know, that particular error means a term function that expected a number didn't get one - culprits are commonly term.setCursorPos and term.setBackgroundColor.
Yap. That was the other problem. Thank you very much to both of you for your help!


Posted by
