Jump to content


spdkils's Content

There have been 49 items by spdkils (Search limited from 30-March 23)


By content type

See this member's


Sort by                Order  

#152328 Turtle Head Lights...

Posted by spdkils on 08 November 2013 - 02:47 PM in Suggestions

Well there are forge mods that add lights, that respond to redstone signals. (Redpwer 2?)

So is the challenge having the light of a turtle control by an internal state, as opposed to globally? Clearly lights in game (forge mods, and otherwise) can be controlled by other states than just redstone. (IC2 has lights in it as well, I thought they checked power, and redstone?)

I don't understand the build of the game well enough to even understand why this is a problem, and if it would be hard/simple.

I just want me some turtles with headlights! (Mostly because my turtles are mining turtles, and being able to see them sure would be nice!)



#152327 Adding Lines for Fully Automated Tree Turtle

Posted by spdkils on 08 November 2013 - 02:27 PM in Ask a Pro

Well from the looks of it...

The tree chopper goes around in a circle, end to end, and chops trees.... Every 30 seconds it sweeps past, and chops any trees.


So really, at the pause, at the start of the loop, every time that runs, it will be on each end of the loop its making...

1st pause it at one end, then it moves to the other end, and pauses, then it moves back. So, you have to double chest. (One at each end.) Or only drop/suck at one end... every other pause.



#152279 How to carry over variables to programs

Posted by spdkils on 07 November 2013 - 11:20 PM in Ask a Pro

local tArgs = {"one","two","three","four"}
shell.run("otherprogram",unpack(tArgs))



#152122 Wireless modem transmit help

Posted by spdkils on 06 November 2013 - 11:20 PM in Ask a Pro

Why are you not just looping redstone.getInput("front")?

why pull the event, and pull the front, and do one with a loop and the other without?

function execute()
if redstone.getInput("front") == true then
  listen()
end
while true do
  r = os.pullEvent()
  if r == "Redstone" then
   if redstone.getInput("front") == true then
		listen()
   end
  end
end
end

Simplify

function execute()
while true do
   if redstone.getInput("front") == true then
		listen()
   end
end
end

or just do it with an event

function execute()
while true do
r = os.pullEvent('redstone') --@ note the lack of a capital R!
if r then
   if redstone.getInput("front") == true then
		listen()
   end
end
end
end

Also, I'm not really sure why have have listen broken out at all. it's only doing 1 thing. I would have both those in 1 loop. and while we're at it? Why not handle the break too?

function execute()
while true do
tEvent = {os.pullEvent()}
if tEvent[1] == 'redstone' then
   if redstone.getInput("front") == true then
		-- nothing we ALWAYS listening.
   end
elseif tEvent[1] == 'modem_message' then
  modem.transmit(1, 1, "Display")
if tEvent[5] == 0 then
  redstone.setOutput("left", true)
  os.sleep(0.5)
  redstone.setOutput("left", false)
end
elseif tEvent[1] == 'key' and tEvent[2] ~= 1 then
return true
end
end
end

Now I didn't check my code, but it seems far easier to just have a single event loop, and do what you need in response to any of the events, just using elseIf.



#151901 Commandblock Api Addition

Posted by spdkils on 04 November 2013 - 08:07 PM in Suggestions

With the addition of the testforbock x y z tile... And command blocks out outputting actual reults to a comparator, as well as text inside the gui, it would be nice to update the commandblock api to eat both those results.

This would enable you to get the block type directly using the command block without doing any sort of a loop.

it prints out 'false' got type block.name grass block.

So if you can get those results, then you can use a command block, to replace replicate an aweful lot of the sensor addon.

Use GPS to tell the command block computer where you're at... Ask it to test the block, get the results as text, and now you know it's grass, or what have you, dig or not dig based on that return. Now you have actual sensors capability on your turtle, just using modems, and command block.



#151891 Command Block Isn't Working Anymore.

Posted by spdkils on 04 November 2013 - 06:39 PM in Ask a Pro

You don't need / in the command block...

That may have been the problem the whole time.

'time set day'



#151889 I need help with ComputerCraft (and reading sticky posts)

Posted by spdkils on 04 November 2013 - 06:35 PM in Ask a Pro

I replied to the other topic. With a sample menu, functiona, that handles responses.



#151878 I need help with ComputerCraft (and reading sticky posts)

Posted by spdkils on 04 November 2013 - 04:39 PM in Ask a Pro

I did a really annoying conveluted method of calling functions for ya... My way around no select case in Lua.

http://pastebin/Pf3w7ZdZ

I didn't write the command block commands nessisary, as you will have to craft the water tank, the lava pit, and the free fall tunnel before you teleport them to their death. I also didn't check to ensure they stayed on the menu, etc etc. Just sloppy, but it outlines how it can work.



#151490 How To Use Arrow Keys To Scroll Through Menu?

Posted by spdkils on 01 November 2013 - 12:17 AM in Ask a Pro

Or start the while loop only after the login... I suppose.



#151487 How To Use Arrow Keys To Scroll Through Menu?

Posted by spdkils on 31 October 2013 - 11:46 PM in Ask a Pro

If you're going to write some type of menu system, I did it by having a while true loop pulling events.

This you have to react to each and every keystroke. I just had one IF that pulled chars, and another for key events, so you can capture the arrow keys, and react...

So, for the password stuff. You're going to need to prompt, assume any keystrokes are for that, check, then draw your menu, then redraw on arrow keystroks... etc.



#151419 How To Code This Grid Into A Mining Turtle.

Posted by spdkils on 31 October 2013 - 10:27 AM in Ask a Pro

Generally
1) record what row you're on. (Change for loop to while loop, with manual counter)
2) record what hole you're on. (Duplicate the array, remove each command as they are executed.)
3) upon startup check those values, to see if it's a resume. (That is why we have to use a while loop.)
4) if you finish, delete the files that save that state.

Not TOO hard. But you may get stuck in strange places if you don't account for turning. So you would have to also record facing... So maybe change the computer label every turn, so you relable, and then turn. OR fire those methods at the same time. IF you're really paranoid about losing state.

^^ Or that API, that looks pretty cool, and you just override the turtle, and refuel functions... maybe easier!



#151370 String.find() Return Single Number

Posted by spdkils on 30 October 2013 - 11:09 PM in Ask a Pro

deleted.... I tried it in demo mode, and didn't work

http://www.lua.org/cgi-bin/demo



#151357 String.find() Return Single Number

Posted by spdkils on 30 October 2013 - 07:54 PM in Ask a Pro

well, you could convert it to a string, cut the length in 1/2, pull the 1/2 and convert it back tonumber all in one big ugly line!!!!



#151342 How To Code This Grid Into A Mining Turtle.

Posted by spdkils on 30 October 2013 - 05:57 PM in Ask a Pro

Well, everything works in the code I wrote. I've tested it... It's slow... very slow... Because turtle.select() is kinda slow. It makes lots of checks because it is spinning.

If you were to cut every 3rd layer, and turtle compare top/bottom at the same time, you would need 1/2 the selects, but more moves. Calling the drop, and how it works out, it isn't the fastest thing I've ever worked on, but it works completly.

I never thought of using the enderchest addon, to give the turtle infinite storage. I always just speed things up by making MORE turtles!!!! (I have 16 of them that I run in mass with wireless controlling to do my "big" jobs.)

You could speed it up by 'sewing' dig down, move across dig up, move dig down, move dig up. etc.... So you could cut up and down thru the job to prevent a lot of wasted movements. 40 down, 40 up (wasted), 40 down, 40 up (wasted).

There are lots of patterns to use.

I just think it's fun to write code, and solve problems. So I'll probably tweak this some more. See if I can come up with a faster way of doing the compares. (I typically just dig, and discard, but that leaves a BIG hole)



#151335 Help With Write

Posted by spdkils on 30 October 2013 - 05:31 PM in Ask a Pro

I wrote a rudementry OS for turtles, and I had to basically run the program with an event loop, and just respond to events the whole time.

So, keystrokes can be caught and handled, or you can just take 'normal' textual input, and move the program along based on input strings.



#151328 Turtle Head Lights...

Posted by spdkils on 30 October 2013 - 05:03 PM in Suggestions

Yeah, that is why I asked about modifying the modem, and was met with real disagreemnt, like I was killing a sacred cow. (I really didn't understand the aversion.)

The other option, seems to be a new turtle type, that is a turtle mod, not a periprial, that would be a turtle with addtional methods. Even a new block ID. However, I don't really understand the workings of Turtles forge, the api, or any of it... I'm clueless. Another one was suggested already, skinning turtles, so you can color/badge them, and add lighting to that. (But again, I have NO CLUE how the blocks are built, how the light is controled, skinning, meta, any of that stuff.)

So, anything that gets lights on turtles == GOOD!

Now that colored glass is in 1.7.2, create monitors with color screens, (back to skinning) anyway, I don't want to go too far off topic. LIGHTS ON TURTLES FTW!



#151317 How To Code This Grid Into A Mining Turtle.

Posted by spdkils on 30 October 2013 - 03:37 PM in Ask a Pro

You can dump it, but that takes a slot, or you can just toss it into the ender chest... If you're not in sand, you could just replace slot 4 with cobble... then it deals with it. So have cobble, dirt, gravel, stone. Then you keep sand! (Great unless you're in a desert.)



#151309 Topic Hijack Rednet Question

Posted by spdkils on 30 October 2013 - 02:59 PM in Ask a Pro

You can't listen to multiple channels unless you abandon rednet, and move to a peripherial. Then you use the wrap function to nab the modem.

If you're talking a turtle... modem is on the right.

local modem = periphrial.wrap('right')
modem.open(channel)
modem.transmit(channel,rchannel,message)

http://computercraft...heral_%28API%29

http://computercraft...Modem_%28API%29



#151308 How To Code This Grid Into A Mining Turtle.

Posted by spdkils on 30 October 2013 - 02:55 PM in Ask a Pro

http://pastebin.com/CwTEk33r

Added a check for bed rock, functioned the search...

Still need to discard cobble, and a few other things, and optimize code for speed!


I'd rewrite a lot of this, because it's grown organically it makes it hard to hack in new code. Also, I'd function so much stuff, so the loop would be insanely clean.



#151304 How To Code This Grid Into A Mining Turtle.

Posted by spdkils on 30 October 2013 - 02:06 PM in Ask a Pro

Always assume it will fail. :D

So I would check all the time. Also unless you're digging "flat" ground, you're going ot run into the issue of not being tall enough. So, there are still some assumptions we make while running this code.
If you cut thru a hill, then you've got that issue. But we can just swiss cheeze the hill, and cut forward every turtle forward, to ensure it's clean. at least it will be a flat plane of empty.

The program still ends far corner because we're doing 25 wide, if we move it 26 it will at least end on the same side as the start. (even cuts, I almost always use them.)

Let me hack in a few more things.

Same pastebin as always.



#151295 How To Code This Grid Into A Mining Turtle.

Posted by spdkils on 30 October 2013 - 01:36 PM in Ask a Pro

Also, I keep updating the code in that pastebin. I have an account, so I keep updating it with all the fixes we're making. So, if you keep looking @ that, I keep all the changes up to date in there.



#151294 How To Code This Grid Into A Mining Turtle.

Posted by spdkils on 30 October 2013 - 01:26 PM in Ask a Pro

Oh the other issue I have is with that y coord of 100, you have no idea if you'll hit bedrock, so a step counter on decent would be needed. So instead of running y 100 times... use a while loop, count as you dig down, when you can't move down, can turtle detect, but can't dig... you know you've hit bedrock... Then loop back up.

Also the dig down, isn't bias, it just digs down... So when you loop the inventory slots of 1-4, you should discard anything above 1, so that you don't fill on dirt/cobble on accident.



#151293 How To Code This Grid Into A Mining Turtle.

Posted by spdkils on 30 October 2013 - 01:20 PM in Ask a Pro

I updated it, fixed a typo I made. also, you must have an ender chest mod, because when you break the default ender chest it just turns into obsidian... :( so I don't have that mod loaded, so testing the refuel isn't easy without adding that mod. Also when you break an ender chest, doesn't it lose the color code, so you won't be able to have 2 ender chests? Or am I thinking about it wrong?

http://pastebin.com/CwTEk33r



#151286 How To Code This Grid Into A Mining Turtle.

Posted by spdkils on 30 October 2013 - 12:44 PM in Ask a Pro

you have one forward in TD that doesn't deadlock.

replace the tf with a simple move function.

local function tf() while not turtle.forward() turtle.attack() end

that will fix that issue.

you can just replace any turtle.forward() with tf()



#151282 How To Code This Grid Into A Mining Turtle.

Posted by spdkils on 30 October 2013 - 12:31 PM in Ask a Pro

while not turtle.forward() do
turtle.dig()
turtle.attack()
end

here is a simple way to deadlock until you CAN move forward.