Jump to content


W00dyR's Content

There have been 129 items by W00dyR (Search limited from 29-March 23)


By content type

See this member's


Sort by                Order  

#124318 How to make a player detector logging system using MiscPeripherals?

Posted by W00dyR on 07 June 2013 - 08:34 AM in Ask a Pro

View Posttheoriginalbit, on 07 June 2013 - 07:04 AM, said:

Just to expand on what W00dyR stated, you cannot get the real time, only the Minecraft world time. So use os.day() as well as os.time() so that you know when and on what day.

Yes, I overread that. My bad :P

To expand even more: I think you should even be able to use those two functions, do some math and calculate the real time. Seeing as every minecraft day lasts a certain amount of time, by adding a initial "zero" point (like, todays date) you should be able to calculate it.

This would make things a lot harder though and it would be way easier to just use os.day() and os.time() .



#124298 How to make a player detector logging system using MiscPeripherals?

Posted by W00dyR on 07 June 2013 - 07:00 AM in Ask a Pro

View PostStarburstDude, on 06 June 2013 - 07:16 PM, said:

Also,is it possible to have the usernames logged onto a program?What I mean is like the usernames are saved a "log program" which is just a list of the usernames and the time they joined. It'd be great If I could know,
Star

Yes, it was explained not to long ago, read up on this topic to get started on that part :)



#124008 An appeal - please help Cloudy rescue his daughter

Posted by W00dyR on 06 June 2013 - 07:43 AM in General

Best of luck Cloudy, my thoughts are with you!



#122375 File Reading?

Posted by W00dyR on 31 May 2013 - 03:49 PM in Ask a Pro

View Postjpzg, on 31 May 2013 - 03:35 PM, said:

Snap

Please look at the date of when this was posted. This is well over a year old ;)



#122337 Mining turtle program

Posted by W00dyR on 31 May 2013 - 01:17 PM in Ask a Pro

View Postsaikit555, on 31 May 2013 - 12:55 PM, said:

May i ask why do type local function instead of just function and return end instead of just end?

Its not something like a requirement, I just like using "local function" so that, just incase, it interferes with any other API or anything, it stays local.

Using "return" stops the program and returns to its shell. I use that to abort a program if the input isn't right. For example, in the checks that check if you have the correct set of arguments, if you don't add the "return" it will simply print the syntax, and then continue executing the program. So it will also print the errors that follow due to incorrect input.



#122336 Help me with args

Posted by W00dyR on 31 May 2013 - 01:10 PM in Ask a Pro

In the spoiler the code for setting a mode with the arguments + a set variable that holds how much/how long to mine for.

Spoiler

The os.startTimer() could be used together with the parallel API, you can make two functions, one for mining (with a while loop), and one simple one looking something like:

local function timer()
  os.startTimer(toMine)
end

local function digFunction()
  while true do
	-- whatever happens for the digging here
  end
end

Then using the parallel api something like this would make it run both functions, while waiting for the timer to finish (since the mining never finishes due to the while loop):

parallel.waitForAny(timer, digFunction)

Using an if statement you can determine which mode to use:

if mode == "amount" then
  for i = 1, toMine do
	-- mining stuff
  end
elseif mode == "timer" then
  -- stuff that needs to happen for a certain time (posted above)
else
  return
end



#122330 Help me with args

Posted by W00dyR on 31 May 2013 - 12:49 PM in Ask a Pro

It might be me, but I don't quite get the part of your syntax:

Usage: cobble [A/T] [value]
A = Amount
T = Time

What exactly are you trying to give it as an argument? Like, is your syntax supposed to be something like:

cobble A 50 -- And it will mine 50 cobble
cobble T 10 -- It will mine cobble for 10 seconds

First of all, you never ended your if statement ;) The if loop you posted is pretty much a check for the input, if its incorrect, it will end the loop using "return", but it has nothing further to do with how the arguments work.

Also, I copy pasted this from the topic I linked you to, you should be able to edit what I posted there into your situation:

Quote

The way it works is just like this:

local args = {...} -- Puts the arguments into a table
local variableOne = tonumber(args[1]) -- Calls the first item in the table and changes it to a number
local variableTwo = tonumber(args[2]) -- Calls the second item in the table and changes it to a number

If the syntax for the code to work would be "dig <length> <depth>", then if I type "dig 10 5", in the code above the variableOne = 10, and variableTwo = 5. So the way it works is that it its just like typing variableOne = 10, but instead of that the code reads the users input and sets that to be the variable.



#122324 Help me with args

Posted by W00dyR on 31 May 2013 - 12:38 PM in Ask a Pro

View Posttonkku107, on 31 May 2013 - 12:35 PM, said:

Would you help me do that?
I'll try my own first

In the links I posted its explained pretty well, you should know how to figure it out yourself :) Post your code when you have something and we will help you with your problems :)



#122319 Mining turtle program

Posted by W00dyR on 31 May 2013 - 12:33 PM in Ask a Pro

View Postsaikit555, on 31 May 2013 - 12:24 PM, said:

Can i use functions within a function?

Yes you can call functions within functions, as long as they have been declared. Functions can call themselves to, up to a limit of 256 I think (correct me if I'm wrong) but for a dig function that also checks the mined blocks you could have the inventoryCheck() as one of the first few functions that is declared. Then dig() would be something like:

local function dig()
  inventoryCheck()
  while turtle.detect() do
    turtle.dig()
    sleep(1)
  end
end



#122315 Help me with args

Posted by W00dyR on 31 May 2013 - 12:30 PM in Ask a Pro

Please read this topic. I just explained this person how to use arguments.

You can also do something for a specific time using the os.startTimer() function.



#122309 Mining turtle program

Posted by W00dyR on 31 May 2013 - 12:13 PM in Ask a Pro

View Postsaikit555, on 31 May 2013 - 12:02 PM, said:

Would you happen to know how to add a line that if inventory full it would empty into a chest?

Yes you can make easy use of the turtle.getItemCount() function. If you want it to be checked with every block that has been dug, my advice is to make a simple function that counts the items, if its full inventory it will place a chest and drop its items in there. You can also have it map out where it went, and return to the start but that would make things much more complicated.

For example, I wrote you this quick function (this will need you to put a chest in its 16th slot)

local function inventoryCheck()
  if turtle.getItemCount(15) ~= 0 then -- Checks the 15th inventory slot
	turtle.select(16) -- Selects the 16th slot (which contains a chest)
	turtle.turnRight() -- Turns around
	turtle.turnRight()
	if turtle.detect() then -- Checks if there is a block, if yes, it digs it out
	  turtle.dig()
	end
	turtle.place() -- Places the chest
	for i = 1, 15 do -- For slot 1 till 15, it selects the slot and drops its contents in the chest
	  turtle.select(i)
	  turtle.drop()
	end
	turtle.turnRight() -- Turns back so it faces front
	turtle.turnRight()
	turtle.select(1)
  end
end

Of course this has a few flaws, it will not know what direction it faces, it just turns around to where it came from (I assume) and places a chest, then empties the inventory, and moves on.



#122306 Shell.run() problem

Posted by W00dyR on 31 May 2013 - 12:01 PM in Ask a Pro

 tonkku107, on 31 May 2013 - 11:56 AM, said:

try
shell.run(blacklist)
without ""

The shell.run() function reads strings. The only way this would work if the op declared blacklist = "blacklist" but that would be the exact same as shell.run("blacklist") anyway.

@op: Does the program run fine when it reads a blacklist file that exists before the program is ran? As in does it error "shell.run("blacklist")" when it was not created through the program?



#122288 Mining turtle program

Posted by W00dyR on 31 May 2013 - 11:17 AM in Ask a Pro

View Postsaikit555, on 31 May 2013 - 11:07 AM, said:

Thanks. :) I made the mistake of placing local mining length before the local args but the second argument i would like to make is not the moving length but how many times it runs the whole program. Is that possible?

Of course, you can rename the variable into anything you want, and use that variable throughout your code, or are you requesting the method of making your code run x amount of times? Because that is simply done using a for loop, which you used before in your original code so I assume you know how that works.

The way it works is just like this:

local args = {...}
local variableOne = tonumber(args[1])
local variableTwo = tonumber(args[2])

If the syntax for the code to work would be "dig <length> <depth>", then if I type "dig 10 5", in the code above the variableOne = 10, and variableTwo = 5. So the way it works is that it its just like typing variableOne = 10, but instead of that the code reads the users input and sets that to be the variable.

(Typing this in a hurry, dinner's ready, if you don't understand, please reply, I'll try explain after dinner :P)



#122281 Elevator

Posted by W00dyR on 31 May 2013 - 10:55 AM in Ask a Pro

View Postmash2305, on 30 May 2013 - 03:58 PM, said:

Alright I have been working on a bluelctric elevator and I am using a computer to send redstone pulses to move the elevator. What i need is two program that will start up as soon as the computer does and ask the question "Would you like to go up?" and if the answer is yes it should send 15 redsone pulses to the back of the computer and the same with the question "Would you like to go down"

You are pretty much asking for us to write your code, maybe you could try figure it out yourself (what you request really isn't hard to make!) and then post what you have so far and we can help you if what you made doesn't work :)

Edit: I am a ninja :ph34r:



#122278 Mining turtle program

Posted by W00dyR on 31 May 2013 - 10:52 AM in Ask a Pro

View Postsaikit555, on 31 May 2013 - 10:45 AM, said:

Where in the code should these be placed?

On the first lines, because all the code does is read input, declare variables, and a way of stopping the program if the input is invalid. So instead of the variables you posted in your original code, use the part I posted. You can ofcourse rename the "local length" and "local noOfTimes" to the way you had it before (miningLength and movingLength)



#122271 Mining turtle program

Posted by W00dyR on 31 May 2013 - 10:31 AM in Ask a Pro

local args = {...} -- This reads the arguments, and puts them into a table

if #args ~= 2 then -- This if loop checks the arguments, and if there arent 2 arguments, it will print how to use it / quit the program
  print("Syntax: mine <tunnel length> <no. of times>")
  return
end

local length = tonumber(args[1]) -- These 2 variables read the table and sets them from string to number, these will be your variables for length and # of times
local noOfTimes= tonumber(args[2])

I made a simple code for you as you see, if you enter arguments that cannot be converted to a number, it will error. A simple fix for this is something like:

if not length or noOfTimes then
  print("Syntax: mine <tunnel length> <no. of times>")
  return
end

This check works because "tonumber(args[1])" returns a boolean value, so you check the boolean value pretty much. Good luck :)



#122257 Problem:program don't work "end" expected (solved)

Posted by W00dyR on 31 May 2013 - 09:56 AM in Ask a Pro

You have an "end" to much in there.

At the part where it sais

if event == "mouse_click" then

You ended it twice, so it ended the

if slc == 0 then

loop as well.

Try removing that end and I think it should work fine :P



#120953 Mining turtle. Not digging/attacking mobs

Posted by W00dyR on 26 May 2013 - 12:41 PM in Ask a Pro

Instead of the system you use, just use something like:

attempts = 0
maxAttempts = 10
local function newForward()
  while not turtle.forward() do
	  turtle.dig()
	  turtle.attack()
	  attempts = attempts + 1
	  if attempts == maxAttempts then
	    break -- This break ends the while loop and makes it stop attempting to go forward, you can also change it into "return" which just ends the program.
	  end
      sleep(1)
  end
end



#120724 Elseif problem

Posted by W00dyR on 25 May 2013 - 05:46 PM in Ask a Pro

View PostConvo_bomber34, on 25 May 2013 - 05:08 PM, said:

please can you tell me what the error is?

Lyqyd answered that already, it has to be

if option == "add" or option == "Add" then

Because in Lua you have to declare what it has to be equal to all the time, it will only compare one thing pretty much.



#120381 Monitor-Terminal dupe over rednet?

Posted by W00dyR on 24 May 2013 - 09:48 AM in Ask a Pro

View PostXenthera, on 23 May 2013 - 04:32 PM, said:

Nevermind, if you want to do something right, do it yourself. I figured it out.

Can you post/PM how you've done it? I'm very interested! :)



#120343 [Lua][misc peripherals][interactive sorter] help understanding commands

Posted by W00dyR on 24 May 2013 - 06:01 AM in Ask a Pro

First thing, the interactive sorter doesn't output in tubes, only buildcraft pipes or inventories.

If an item enters it, it emits the event "isort_item" like this:

event, itemID, ammount = os.pullEvent()

So if you then wrap it, and use its functions to sort items, you can sort items that enter it like the following:

s = peripheral.wrap("left") -- or any other side
direction = 1 -- Or any other number, read the miscPeripherals topic for the directions
while true do
  event, itemID, amount = os.pullEvent()
  s.sort(direction, amount)
end
And if you want it to print the information about the item that enters, simply add this into the while loop
print(itemID)
print(amount)


If you want specific directions for certain items to go in, then you can make a table, and have it check the table for matches and stuff, if its a match go direction 1, if not, go direction 5 or something similiar. I have my own system set up which reads items from a website link, depending on its response, it sends it to different directions. Yes, this means that it doesn't know the items name, what kind of item it is, or anything, only the itemID of the item. So if you want specific sort directions, you must have a table or system where it gathers this information from.



#120210 Monitor-Terminal dupe over rednet?

Posted by W00dyR on 23 May 2013 - 03:49 PM in Ask a Pro

You will always have a computer connected to a monitor, because a monitor can't receive rednet messages, a computer can.



#120078 touchscreen on off

Posted by W00dyR on 23 May 2013 - 09:05 AM in Ask a Pro

View PostKev30, on 23 May 2013 - 08:54 AM, said:

what i want : when i click on button the button goes green and the signal is on. When i press it again the signal is off and the button turns red

What it does: green = on for a few seconds then signal is off

Easiest way for displaying this (in my opinion) is to just have a loop, which waits for a touch and sets a variable to a boolean value. In the loop you have a function that checks the variable and displays it/sets the bundled cable output. Then the loop just starts over and it waits for a touch again. If you want the signal to turn off after a certain time, start a timer in the start of the loop if the boolean value is set to false for example. Then the os.pullEvent() will notice the timer triggering instead of the monitor_touch, if its the timer then it will set it to a different boolean value as if you were pressing the button yourself.



#119778 [LUA] adding to a table within a table

Posted by W00dyR on 22 May 2013 - 01:07 PM in Ask a Pro

Pro tip: Using the code tags makes stuff a lot more easy to read!
Also, your pictures link dont work ;)



#119548 [Lua][Question] Parallel Help?

Posted by W00dyR on 21 May 2013 - 06:36 PM in Ask a Pro

I am not sure of this, but I think because you use "shell.run()" to download the file, it will run that program, which overwrites anything else that happens in the code. I got a thing you could do IF what I am saying is correct (I will need a real pro to confirm that though :P).

- Write your own pastebin function using the http://pastebin.com/raw.php?i= API provided by pastebin itself. (You can probably find this somewhere around here)
- Copy the pastebin API and use it as a local function

Again, I am not familiar with this, so if I were you I would wait for other replies that may be more usefull, just thought I would post it anyway, maybe its usefull anyways :P