
Draw Spongebob with punching gloves doing a K.O on Patrick
There have been 7 items by TheOddByte (Search limited from 10-February 22)
Posted by
TheOddByte
on 03 March 2018 - 12:39 AM
in
Forum Games

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:
Posted by
TheOddByte
on 02 November 2017 - 03:35 PM
in
Ask a Pro
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 andlocal 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
--# 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" )
Posted by
TheOddByte
on 20 April 2018 - 02:59 PM
in
General
Posted by
TheOddByte
on 30 October 2017 - 03:13 PM
in
Ask a Pro
Lupus590, on 25 October 2017 - 11:43 AM, said:
--# 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
Posted by
TheOddByte
on 20 April 2018 - 02:49 PM
in
Ask a Pro
--# 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
Posted by
TheOddByte
on 20 April 2018 - 02:57 PM
in
Suggestions

