Jump to content


JoshhT's Content

There have been 62 items by JoshhT (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#64928 Line Finder by JoshhT

Posted by JoshhT on 27 December 2012 - 02:37 PM in Programs

View PostremiX, on 25 December 2012 - 01:45 AM, said:

Can I ask you what this cleanup function is for? Even after I changed
local fileLoc = cleanup()
to
local fileLoc = args[1]
it still found the exact line :)

Also, make it print the usage usage if you just type the program name with no arguments, etc. Indeed, very useful for tekkit players.

Well if you read it, you'd discover it removes any quotation marks from the file location if the user puts any.



#63940 Line Finder by JoshhT

Posted by JoshhT on 24 December 2012 - 10:11 PM in Programs

View PostCodeMachine, on 24 December 2012 - 01:45 PM, said:

Nice program! Find it quite useful... :D
Cheers mate :)

View Postpielover88888, on 24 December 2012 - 02:07 PM, said:

Um, but you don't have to count the lines until you hit pagedown far enough so you're near line 190 o_O
anyway, very useful :)
For tekkit users, CC does not tell you what line you're currently on.
These are the people this program is aimed at.



#62830 Hello, I'm rather new and don't know much. Simple question: how do I...

Posted by JoshhT on 21 December 2012 - 10:20 PM in Ask a Pro

What was it that you typed in exactly?
And what program would you like to download, could you provide a link?



#62332 Problem| Rednet, send redstone pulses via masseges

Posted by JoshhT on 21 December 2012 - 12:36 AM in Ask a Pro

View PostTheOriginalBIT, on 21 December 2012 - 12:32 AM, said:

the receiver code at the very least should be in a while true do loop.

Yes well of course. I just couldn't be bothered typing it out. Hahha.



#62328 Problem| Rednet, send redstone pulses via masseges

Posted by JoshhT on 21 December 2012 - 12:30 AM in Ask a Pro

Here's a simple little thing I put together, to further explain my second suggestion.
With this code, it will only send the message to one specific computer you want, but you still only have to type in numbers 1 - 9 or whatever.
OP should use this if broadcasting interferes with other programs.

--Sender code.
local comps = { 4, 7, 11, 12, 13, 16, 19, 20 }

local x = read()

rednet.send(comps[x], "pulse bitch")

--Receiver code.
local senderID, msg = rednet.receive()

if msg == "pulse bitch" then
  rs.setOutput("back", true)
  sleep(5)
  rs.setOutput("back", false)
end



#62325 Problem| Rednet, send redstone pulses via masseges

Posted by JoshhT on 21 December 2012 - 12:19 AM in Ask a Pro

Or you could go one better, and actually send a message to individual computers, instead of just broadcasting?



#62324 Problem| Rednet, send redstone pulses via masseges

Posted by JoshhT on 21 December 2012 - 12:18 AM in Ask a Pro

Here's what you need, just the very bare and basics of it.
Obviously you still need to open the rednet signal and all that jazz.

Sender code.
while true do
  local x = read()

  rednet.broadcast(x)
  sleep(2)
end

Receiver code.
while true do
  local sender, msg = rednet.receive()

  if msg == "4" then
    rs.setOutput("back", true)
    sleep(5)
    rs.setOutput("back", false)
  end
  sleep(1)
end



#61022 file.readline(number) ?

Posted by JoshhT on 17 December 2012 - 11:09 PM in Ask a Pro

View PostTheOriginalBIT, on 17 December 2012 - 08:35 PM, said:

guy that was better multithreaded and was writing while calculating, or something.
Threads in Java are amazing, and very powerful. The only downside to them is how resource intensive they are.
I love Java.



#60986 file.readline(number) ?

Posted by JoshhT on 17 December 2012 - 08:55 PM in Ask a Pro

I made this a while ago. Perhaps you should look through it.
http://pastebin.com/ui0xdsLy



#59598 Loop thats user defined

Posted by JoshhT on 14 December 2012 - 08:03 PM in Ask a Pro

Can OP please post some more info on what he would like to accomplish?



#59332 Show Current Status help

Posted by JoshhT on 14 December 2012 - 04:18 AM in Ask a Pro

Lol...
print(v)

v being the variable. Will print exactly what the variable states.
Whether it be a boolean value, an integer, or a string.



#54514 [Question] trouble with displaying time

Posted by JoshhT on 26 November 2012 - 10:28 PM in Ask a Pro

Kingdaro pointed out two errors.
I also spotted this.
nTime == os.time()

Should be

nTime = os.time()



#54078 Run a floppy disk during a while loop?

Posted by JoshhT on 25 November 2012 - 09:33 PM in Ask a Pro

You might want to look into the disk API.

Something like this.

driveSide = "left"
while true do
  if disk.isPresent(driveSide) and disk.hasData(driveSide) then
    os.run({}, "program on disk")
    sleep(1)
    disk.eject(driveSide)
  end
sleep(2)
end



#41954 [Lua] [Question] Program is ignoring if-statement when it's not supposed to.

Posted by JoshhT on 19 October 2012 - 03:39 AM in Ask a Pro

View PostKingdaro, on 19 October 2012 - 03:03 AM, said:

io.read, or just read(), returns a string (text), regardless of whether you entered a number or not. It will never equal 5148 because 5148 isn't a string, it's a number.

You would either have to convert your pass variable to a number with tonumber(), or put quotes around 5148.

Also, that second example you've given wouldn't work, due to the fact that it's not actually returning to anything because it isn't inside a function (unless I'm mistaken and scripts are loaded inside a function.) Plus, true and false have to be lowercase, otherwise Lua mistakes them as variables and returns nil since they haven't been set.

Couldn't have said it any better myself friend.



#41607 turtle:10: Expected number

Posted by JoshhT on 18 October 2012 - 12:32 PM in Ask a Pro

View PostDoyle3694, on 18 October 2012 - 12:23 PM, said:

why tonumber a number?

Topic title : Expected number.
Error @ line 10 : until a == x

It must be passing x as a string and not a number.
I had this issue a few days ago.

Edit: It IS passing x as a string. I just made a test file with the following.

args = {...}

if args[1] == true then
  print("True")
elseif args[1] == false then
  print("False")
elseif args[1] == 1 then
  print("One")
elseif tonumber(args[1]) == 2 then
  print("Two")
else
  print("Invalid")
end

Go on, run it. Everything you type will return invalid unless you type 2.



#41605 turtle:10: Expected number

Posted by JoshhT on 18 October 2012 - 12:22 PM in Ask a Pro

Use this instead.

until a == tonumber(x)



#41604 turtle.detect() help

Posted by JoshhT on 18 October 2012 - 12:19 PM in Ask a Pro

View Postprotexxi, on 18 October 2012 - 11:34 AM, said:

if turtle.detect() then

end
else

end

Why have I seen this same mistake three times in the last 12 hours? O_o
'sabit weird...



#41165 A less Than or Greater than a variable?

Posted by JoshhT on 17 October 2012 - 06:13 AM in Ask a Pro

Well, let me break it down for you, because I think you might be a little confused here.

Your code is used to alert you to when a stack is getting low.
So in my mind, you'd want to get the number of items in the slot, not the number of items needed for that slot to be full.

The way you're doing it:
Q = like, say 50?
getItemSpace(), meaning, how many items/blocks until that stack is full. would need to be higher than 50, to return you a low stack.

The way I would do it.
Q = 10
getItemCount(). if that is lower than Q, the stack is low.

It's much easier to understand to be honest.

Ohh, and Zoinky noticed something I missed. Good job mate.



#41157 A less Than or Greater than a variable?

Posted by JoshhT on 17 October 2012 - 05:41 AM in Ask a Pro

Change:
local Q = read()

-- Change to
local Q =tonumber(read())

Also, from the wiki.
turtle.getItemSpace( slotNum ) - Counts how many remaining items you need to fill the stack in the given Slot			
turtle.getItemCount( slotNum ) - Counts how many items are in the given Slot			

It would seem you might want to be using .getItemCount() instead.



#40506 Logout -> Login, Programm stops

Posted by JoshhT on 15 October 2012 - 12:50 PM in Ask a Pro

I hope you're not talking about single player right? Lol.
You mean you start your turtle then log out of the server yes?



#40488 Retrieving items

Posted by JoshhT on 15 October 2012 - 11:13 AM in Ask a Pro

The error is in the itemSorter file, not startup :D/>



#40485 [Question] Starting a timer in the middle of code.

Posted by JoshhT on 15 October 2012 - 10:57 AM in Ask a Pro

Lua > Java.

Back on topic though, the read() function waits for user input, which results in your timer stopping.



#40483 [Question] Starting a timer in the middle of code.

Posted by JoshhT on 15 October 2012 - 10:52 AM in Ask a Pro

View PostDoyle3694, on 15 October 2012 - 10:50 AM, said:

tostring()
Without the use of such methods.

Can you do something like,
local errmahhgerrd = 9001

print(errmahhgerrd)

errmahhgerrd = "It's over 9000!")

print(errmahhgerrd)



#40481 [Question] Starting a timer in the middle of code.

Posted by JoshhT on 15 October 2012 - 10:48 AM in Ask a Pro

Well,
password2 = 1
-- Further down...
password2 = read("*")

Someone please, by all means, correct me if I'm wrong.
I don't think you can change a variable from an integer to a string?
And if you can, that's kind of cool.

But in regards to your problem.
I believe the read() method actually waits for user input.
I haven't looked at the exact code, but I assume it utilizes a while loop or something of the sort.



#40447 [LUA][Question] Reading variables from a file

Posted by JoshhT on 15 October 2012 - 06:56 AM in Ask a Pro

Yeah that should work perfectly :D/>