Clickable buttons in CC
Started by Engineer, Mar 11 2013 10:18 AM
34 replies to this topic
#21
Posted 21 March 2013 - 05:46 AM
> not unreadable to me at least
> not error prone
> more efficient than looping through a table every time you click v_v
> my method is more dynamic
> not error prone
> more efficient than looping through a table every time you click v_v
> my method is more dynamic
#22
Posted 21 March 2013 - 03:52 PM
Yeah hey. My os is now gui! Thanks for helping me theOriginalbit and engineer.
#23
Posted 22 March 2013 - 03:09 AM
im still confused how to make the buttons show up though
#25
Posted 22 March 2013 - 04:09 AM
Ristyo, on 22 March 2013 - 03:09 AM, said:
im still confused how to make the buttons show up though
term.setBackgroundColor(colors.blue)
term.setTextColor(colors.white)
for i = 1, #buttons_table do
local button = buttons_table[i]
for y = 1, button[4] do
for x = 1, button[3] do
term.setCursorPos( button[1] + x, button[2] + y )
write(' ')
end
end
term.setCursorPos( button[1], button[2] )
write( button[5] )
end
the above code would print them all out.
#26
Posted 29 March 2013 - 08:24 PM
Engineer, on 11 March 2013 - 10:18 AM, said:
local evt, button, x, y = os.pullEvent("mouse_click")
if x >= [your Xmin] and x <= [your xMax] and y >= [your yMin] and y <= [your yMax] then
-- your code
end
If you find any spelling errors or if you have a question post it below!
Also feedback is appreciated.
if x >= [your Xmin] and x <= [your xMax] and y >= [your yMin] and y <= [your yMax] then
-- your code
end
If you find any spelling errors or if you have a question post it below!
Also feedback is appreciated.
#27
Posted 30 March 2013 - 12:39 AM
ScruffyRules, on 29 March 2013 - 08:24 PM, said:
Engineer, on 11 March 2013 - 10:18 AM, said:
local evt, button, x, y = os.pullEvent("mouse_click")
if x >= [your Xmin] and x <= [your xMax] and y >= [your yMin] and y <= [your yMax] then
-- your code
end
If you find any spelling errors or if you have a question post it below!
Also feedback is appreciated.
if x >= [your Xmin] and x <= [your xMax] and y >= [your yMin] and y <= [your yMax] then
-- your code
end
If you find any spelling errors or if you have a question post it below!
Also feedback is appreciated.
#28
Posted 27 May 2013 - 06:32 PM
Multiple buttons
Let's go and process your values. I like them to put them in a table so you have later an easier way of determiningwich which button is clicked.
Let's go and process your values. I like them to put them in a table so you have later an easier way of determining
#30
Posted 01 June 2013 - 06:52 PM
How would you output the buttons to a monitor?
#31
Posted 01 June 2013 - 07:32 PM
You would use os.pullEvent('monitor_touch') instead of os.pullEvent('mouse_click')
And for your information, this tutorial is about making a button and not about displaying a button.
And for your information, this tutorial is about making a button and not about displaying a button.
#32
Posted 03 June 2013 - 05:41 AM
I wish I had come here and read through the forums sooner, but I muddled through and came up with a reasonable method of getting clickable buttons on my advanced monitors.
I actually wrote a set of mini-operating systems that work together for the purpose of replacing the wireless redstone mod that will be leaving FTB if redpower doesn't get updated, and so far it's working splendidly!
Now, right off the bat I do not claim to be a world-class programmer. What I do claim to be is someone who can set a goal and make it happen, albeit sloppily, so if my code offends you, please keep the criticism constructive!
First off. this is a small screen sample of the final product:
http://dev.extrabit....l%20Display.png
It does adjust automatically, and on the fly, so you can place more screens and everything remains clickable without rebooting.
This is the configuration file for adding more buttons:
http://dev.extrabit....tons.config.png
You don't have to hard-code any coordinates, it will generate the button and keep track of its position for you.
The syntax here is Label: server event|state
The label is what you see on the screen, the server optional but it's where you want to send the command to with the channel number that server listens on in a separate config, and with an optional 't' before the servers name if the button is a toggle (can be turned on or off)
The event is the command name to send to that server, for the purposes of differentiation (one server can handle multiple clients which themselves deal directly with machines) and the state is the default starting state of the button.
True and false are pretty obvious, pulse means when the command reaches its client, the redstone pulses on for 1 second, then off (I use it to play music.)
and ~true and ~false are used when you want to have the button show the opposite of the redstone state.
For example, my witch spawner is off by default, but that means the restone is ON to prevent them from spawning. I want the computer to show that they are not spawning with the button being red(off) so I use ~false so that the display will show false but the redstone will be set to true.
For anyone who wants to peek at the code, it's available here:
http://dev.extrabit....nOS/buttons.lua
With the draw code being in my gui file.
If anyone has some ideas as to how I could improve this code, I'd welcome it, and if you would like to try the OS out, PM me and I will gladly share install instructions.
I actually wrote a set of mini-operating systems that work together for the purpose of replacing the wireless redstone mod that will be leaving FTB if redpower doesn't get updated, and so far it's working splendidly!
Now, right off the bat I do not claim to be a world-class programmer. What I do claim to be is someone who can set a goal and make it happen, albeit sloppily, so if my code offends you, please keep the criticism constructive!
First off. this is a small screen sample of the final product:
http://dev.extrabit....l%20Display.png
It does adjust automatically, and on the fly, so you can place more screens and everything remains clickable without rebooting.
This is the configuration file for adding more buttons:
http://dev.extrabit....tons.config.png
You don't have to hard-code any coordinates, it will generate the button and keep track of its position for you.
The syntax here is Label: server event|state
The label is what you see on the screen, the server optional but it's where you want to send the command to with the channel number that server listens on in a separate config, and with an optional 't' before the servers name if the button is a toggle (can be turned on or off)
The event is the command name to send to that server, for the purposes of differentiation (one server can handle multiple clients which themselves deal directly with machines) and the state is the default starting state of the button.
True and false are pretty obvious, pulse means when the command reaches its client, the redstone pulses on for 1 second, then off (I use it to play music.)
and ~true and ~false are used when you want to have the button show the opposite of the redstone state.
For example, my witch spawner is off by default, but that means the restone is ON to prevent them from spawning. I want the computer to show that they are not spawning with the button being red(off) so I use ~false so that the display will show false but the redstone will be set to true.
For anyone who wants to peek at the code, it's available here:
http://dev.extrabit....nOS/buttons.lua
With the draw code being in my gui file.
If anyone has some ideas as to how I could improve this code, I'd welcome it, and if you would like to try the OS out, PM me and I will gladly share install instructions.
#33
Posted 03 June 2013 - 02:38 PM
PixelToast, on 21 March 2013 - 05:46 AM, said:
> not unreadable to me at least
> not error prone
> more efficient than looping through a table every time you click v_v
> my method is more dynamic
> not error prone
> more efficient than looping through a table every time you click v_v
> my method is more dynamic
I'm a tad confused, if you're using custom statements for your buttons, you still need a loop somewhere to determine which button was clicked, don't you?
Are you placing each one as a possible if...then inside your main program loop?
Also, how is it "more dynamic", what's the advantage of your buttons over the tutorials buttons?
Would you be willing to share a code sample?
#34
Posted 07 June 2013 - 08:24 AM
a video of this tutorial would be very helpful
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











