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

Get clicks from wired monitor

Started by Blender Squats, 21 February 2016 - 01:01 AM
Blender Squats #1
Posted 21 February 2016 - 02:01 AM
Hi! I'm looking for some help with a project for controlling a reactor in Sky Factory 2.

I have Optifine installed, but the actual code is being run through a personal server.

I have tried to make a button api which appears to work on the actual terminal, but when run through a monitor it will not continue after the monitor is clicked.

The pictures are in my drive's public folder.

–> Here <–

I comment separated my code into sections based on the file that it was on in my computer (please look for the breaks). It can be found at this link.

Any help or explanation would be welcome. I am just a beginner so I would love to know more.

Thanks ^_^/>
Bomb Bloke #2
Posted 21 February 2016 - 09:36 AM
parallel.waitForAny(main(clicked), button.monDetect());

Couple of problems here;

First, that's not how you use parallel.waitForAny(). You need to pass it function pointers. You're running your functions before passing it whatever they return; you haven't included source for your button API, but main() certainly doesn't return a function pointer.

It seems you would be better off just having main() access "clicked" as an upvalue, instead of trying to pass it anything.

The other issue is that "clicked" is assigned the value of the variable titled "none", but nowhere do you assign a value to the "none" variable. I guess you meant to assign "none" as a string (that is to say, stick some quotes into line 49)?
Blender Squats #3
Posted 21 February 2016 - 02:41 PM
Hi! Thanks for your help. I see what you are saying and probably can get it done. What I was saying before was that what the pastebin contains is a sum of all the code from across files. These files are indicated by comments such as:
–startup code (/startup)

the (/startup) indicated what file the code was from. so I did include the API code (under "–api code(/api/button)"), I think that you probably just didn't understand about the different files, as I didn't make it very clear.

Regards
Bomb Bloke #4
Posted 21 February 2016 - 03:46 PM
I suggest swapping out this:

parallel.waitForAny(main(clicked), button.monDetect());

print(clicked);

… with something like this:

while true do
	local clicked = button.monDetect()
	
	main(clicked)
	
	print(clicked)
end

Make sure you don't use the "monitor" script to start your one - that'll convert all "monitor_touch" events into "mouse_click" events, which your script won't pick up on.
Blender Squats #5
Posted 21 February 2016 - 04:14 PM
No, I got it. I figured out another way which suits my needs best.

Here is my new working code for reference.

/startup: here

/apis/button: here

/programs/reactor: here

Thanks for the help. ;)/>
Creator #6
Posted 21 February 2016 - 05:55 PM
The pastebin contains no code at all.
Blender Squats #7
Posted 21 February 2016 - 08:36 PM
That pastbin has been removed due to fixed code. the new pastebins contain the fixed code.
Blender Squats #8
Posted 25 February 2016 - 12:22 AM
Hi! A bit of a problem arose when I tried to edit the API which was responsible for logging button clicks.

I named it "button" and it was working, but had a serious y-cord glitch where you could click anywhere below the button and it would still log it as clicked.

Here is the new problem.

The API code is here.

Reactor code here for reference.

The code my be a little half-baked, but I thank you for understanding.
Bomb Bloke #9
Posted 25 February 2016 - 01:44 AM
Looks like the computer is probably trying to output an error there, but since you last set the background colour to red, the text matches it and nothing's visible.

I suggest a search and replace changing all instances of red to, I dunno, pink. You can change them back again once you've read any errors this reveals.
Blender Squats #10
Posted 25 February 2016 - 02:24 AM
Thanks, fixed it. Made a stupid error in the api (note button instead of buttonY)
Silver07 #11
Posted 04 March 2016 - 06:18 AM
Buttons, Now digital, and in color :P/>
Edited on 04 March 2016 - 05:19 AM