Posted 02 September 2015 - 10:46 AM
Currently I am trying to make a functioning button I used the code off http://www.computerc...utorial-part-i/ and followed the process all the way up to part III, however the person who made this tutorial has no longer posted any further tutorials on the subject so I am stumped on his last bit of coding
The setup:
The code http://pastebin.com/Vj6p0ASU
Everytime I run the script and test out the button I'll click a button that'll appear on the screen and then
I don't know why it keeps calling nil and if I replace the while loop with:
This shows me that there are values where I clicked, however for some reason the while loop
In this while loop 'xPos' and 'yPos' doesn't hold the value unless I covert it to a string character, but I can't use that but when I call the function hoping for a number it calls nil instead. *confused face*
I don't know where to look to find the answers I am looking for hence this post, I will be grateful for who ever can solve my problem or point me in the right direction
for me to solve my problem
The setup:
Spoiler
The code http://pastebin.com/Vj6p0ASU
Everytime I run the script and test out the button I'll click a button that'll appear on the screen and then
firstButton.lua:173: attempt to call nil
I don't know why it keeps calling nil and if I replace the while loop with:
while true do
event, side, xPos, yPos = os.pullEvent("[b]monitor_touch[/b]")
print(event .. " => Side: " .. tostring(side) .. ", " ..
"X: " .. tostring(xPos) .. ", " ..
"Y: " .. tostring(yPos))
end
This shows me that there are values where I clicked, however for some reason the while loop
while true do
event, side, xPos, yPos = os.pullEvent("monitor_touch")
for key, button in pairs(buttons) do
if button.click(xPos,yPos) then
redstone.setOutput(key, button.toggle())
button.draw(monitor1)
end
end
end
In this while loop 'xPos' and 'yPos' doesn't hold the value unless I covert it to a string character, but I can't use that but when I call the function hoping for a number it calls nil instead. *confused face*
I don't know where to look to find the answers I am looking for hence this post, I will be grateful for who ever can solve my problem or point me in the right direction
for me to solve my problem