Jump to content


TheOddByte's Content

There have been 7 items by TheOddByte (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#271390 ListOut Directory on Monitor?

Posted by TheOddByte on 30 October 2017 - 03:13 PM in Ask a Pro

View PostLupus590, on 25 October 2017 - 11:43 AM, said:

There's also the FS API
And to extend this: http://www.computerc...fo/wiki/Fs.list
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
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 and
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.
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
end
and 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

View PostLuca_S, on 18 November 2017 - 10:01 AM, said:

View PostAmenofisch, 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!

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.
And even if someone is willing to do it I atleast think OP could give them some Krist or something for their work.



#275595 MS Paint

Posted by TheOddByte on 03 March 2018 - 12:39 AM in Forum Games

Does this count?
Posted Image
Draw Spongebob with punching gloves doing a K.O on Patrick



#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?
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.
But from what I understood you only want one reactor active at a time?



#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



#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..?