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

TouchPoint API Total Lua Noob

Started by SkyDevil_, 20 July 2015 - 04:54 AM
SkyDevil_ #1
Posted 20 July 2015 - 06:54 AM
Hi im having issues getting a button to toggle a Project red cable on and off im currently using the TouchPoint API to help me with the buttons but when i clikc the button the cable colour i define will turn on but when i click the buton again it stays on.
Sorry my english if my english is not great.
LUA code
http://pastebin.com/X9ikUKCv
Bomb Bloke #2
Posted 22 July 2015 - 03:33 AM
Sorry, your code is correct. It's a result of this bug.

As a workaround, you can add this to the top of your script:

function colours.subtract(cols, ...)
	for i = 1, #arg do
		if bit.band(cols, arg[i]) == arg[i] then
			cols = cols - arg[i]
		end
	end
	
	return cols
end
colors.subtract = colours.subtract
NeXuS473 #3
Posted 27 March 2016 - 09:54 PM
hi there

i have the same poblem with my program (colors.subtract is not working) so i inserted your code at the top but it still does not work.
it says: "attempt to index ? (a nil value)" at line 3 in your code

plz help :(/>
Bomb Bloke #4
Posted 28 March 2016 - 01:19 AM
That line attempts to index into two tables; arg and bit. arg won't be nil (due to the structure of the surrounding code), so that indicates that bit is - which in turn suggests that disable_lua51_features is set to true within ComputerCraft.cfg.

Switching to bit32 should work. If not, post your full code.
NeXuS473 #5
Posted 29 March 2016 - 05:05 PM
thanks a lot!
Setting disable_lua51_features=false worked!