- ComputerCraft | Programmable Computers for Minecraft
- → TheOddByte's Content
TheOddByte's Content
There have been 7 items by TheOddByte (Search limited from 10-February 22)
#276919 What are the more infamous viruses?
Posted by
TheOddByte
on 20 April 2018 - 02:59 PM
in
General
Never used it, but I mostly only remember the string exploit that existed in 1.6..?
#276917 reactor safety prpduce
Posted by
TheOddByte
on 20 April 2018 - 02:49 PM
in
Ask a Pro
I'm not 100% sure what you want, but is it this logic you mean?
But from what I understood you only want one reactor active at a time?
Psuedo-code
Do take note that this is for the most part only a psuedo-code and I haven't checked what methods actually are available for the reactors in galacticacraft nor tested the code.--# This will store what reactor we're actively using
local index = nil;
--# Wrap and store the reactors in a table since we'll use the variable above
--# to keep track of which one we're using
local reactors = {
peripheral.wrap( "<name or side of reactor>" );
peripheral.wrap( "<name or side of reactor>" );
}
--# Infinite loop
while true do
--# If the index variable is nil we'll check if there is any reactor active
--# and choose which one we'll keep track of
if not index then
--# We loop through all reactors and check if
--# we find one that's already active
for i, reactor in ipairs( reactors ) do
if reactor.active() then
index = i
break
end
--# If we didn't find any active reactor then
--# We'll choose the first one in the table to use
if not index then
index = 1
reactors[index].activate() --# Here we activate it
end
end
else
--# If the reactor isn't active we'll activate another one
--# so we'll increment the index variable with one to continue
--# to the next reactor
if not reactors[index].active() then
index = index + 1 <= #reactors and index + 1 or 1
reactors[index].activate()
end
end
sleep( 0.5 )
end
But from what I understood you only want one reactor active at a time?
#275595 MS Paint
Posted by
TheOddByte
on 03 March 2018 - 12:39 AM
in
Forum Games
Does this count?

Draw Spongebob with punching gloves doing a K.O on Patrick

Draw Spongebob with punching gloves doing a K.O on Patrick
#276918 Monitor on Turtles
Posted by
TheOddByte
on 20 April 2018 - 02:57 PM
in
Suggestions
I've been meaning to suggest this for a while, but I've forgotten all the time and I've been too lazy. My idea is essentially be to be able to put a monitor on turtles, I think this would be cool since you could create facial expressions for them etc. Got the idea when I saw the robot Cozmo
Spoiler


#271390 ListOut Directory on Monitor?
Posted by
TheOddByte
on 30 October 2017 - 03:13 PM
in
Ask a Pro
Lupus590, on 25 October 2017 - 11:43 AM, said:
There's also the FS API
fs.list returns a table, so if you want to print all the files in the directory you need to loop through the table.
--# Find the monitor using peripheral.find
local monitor = peripheral.find( "monitor" )
local sPath = "/"
--# Setup the monitor
monitor.setTextScale(2)
monitor.setCursorPos(1, 1)
monitor.clear()
--# Redirect all output to the monitor
term.redirect( monitor )
--# Loop through the table and print all the files in the given directory
for _, name in ipairs(fs.list(sPath)) do
print( name )
end
#271513 Help with button clicking program
Posted by
TheOddByte
on 02 November 2017 - 03:35 PM
in
Ask a Pro
1: It works when I try it, can't find anything wrong with it, I have some suggestions though.
Okay, first of all I'd recommend that you use tables to store all your options, something like this for example
assign them a function instead so that they do what you want and so that you can easily add new options without having to get the exact coordinates for each entry.
2: What error are you getting?
3: Load an image using paintutils, draw it, sleep, clear the screen and let the other program handle the rest.
@Luca_S What you posted is the correct way to check the coordinates, but it still shouldn't be a problem for the OP since he's using the x position 1 for the menu entries, which makes me a bit confused on why he can only click the little box, and I tried it myself without any problems.
Okay, first of all I'd recommend that you use tables to store all your options, something like this for example
local choices = {
"TurtleMenu", "Chat", "Calculator", "Notes", "Games", "Comp. Info"
"Options", "Sleep"
}
because it's much easier to manage and looks cleaner, and in your scenario you're using them as buttons, so I'd suggest you declare them as keys in the table andassign them a function instead so that they do what you want and so that you can easily add new options without having to get the exact coordinates for each entry.
local choices = {
["TurtleMenu"] = function()
--# do stuff
end;
}
then instead of drawing them one by one as you've done you can loop through them and draw them all in one swoop.--# Set the starting position local x, y = 1, 4 for key, value in pairs( choices ) do term.setCursorPos( x, y ) term.write( "[ ] " .. key ) y = y + 2 --# Increase the y coordinate with 2 endand then you could do the same thing when checking if it has been clicked
local event, button, cx, cy = os.pullEvent() local x, y = 1, 4 if event == "mouse_click" then for key, value in pairs( choices ) do if x >= cx and cx < x + #key + 4 and cy == y and button == 1 then value() --# Call the function declared in the table, can also be called like this: choices[key]() break --# break out of the loop since we've found the entry that has been clicked end y = y + 2 --# Same thing as before, increase y with 2 so that we get the correct coordinates to check end end
2: What error are you getting?
3: Load an image using paintutils, draw it, sleep, clear the screen and let the other program handle the rest.
--# Clear the screen term.clear() term.setCursorPos( 1, 1 ) --# Load the image local image = paintutils.loadImage( "path here" ) --# Draw the image paintutils.drawImage( image, x, y ) --# Wait a bit before continuing sleep( 2 ) --# Clear the screen and run the desired program term.clear() term.setCursorPos( 1, 1 ) shell.run( "the program you want to run" )
@Luca_S What you posted is the correct way to check the coordinates, but it still shouldn't be a problem for the OP since he's using the x position 1 for the menu entries, which makes me a bit confused on why he can only click the little box, and I tried it myself without any problems.
#271945 Can someone make a Pay for Power program for tekkit classic?
Posted by
TheOddByte
on 18 November 2017 - 03:39 PM
in
General
Luca_S, on 18 November 2017 - 10:01 AM, said:
Amenofisch, on 06 November 2017 - 06:18 PM, said:
It would be nice if anyone of you guys could make a " Pay for Power " program for me! I would really appreciate if anyone could make it for me!
Thanks!
Thanks!
That's not how it works here.
While you are, of course, allowed to ask for someone to write a Program for you, it is very unlikely someone is actually going to do it.
Instead I suggest you learn Lua and the CC APIs and then ask in the "Ask a Pro" Section when you get stuck somewhere.
- ComputerCraft | Programmable Computers for Minecraft
- → TheOddByte's Content


