Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Murlocking

Newbie Requesting 2 Simple Programs and one Extra

Question

Hello, I'm really new to Lua and I've tried to figure things out by myself but it's a lot more complicated then I expected at first so any help is greatly appreciated!
 
FIRST REQUEST
Okay so here's my setup and what I want to achieve in my first request

I have Essence Berry bushes from Tinker's Construct (the xp one) and I want to have a robot water the plant with the Watering Can (Reinforced) from Extra Utilities. In my testing, the Watering Can will only work if you are close enough to a block (3 blocks max distance).

So from what I understand, this is the function I have to use :

robot.use([side: number[, sneaky: boolean[, duration: number]]]): boolean[, string
 
I tried running robot.use() through the lua console but it will only use the Watering Can once and it's not very helpful for me :)
I tried robot.use(3, 100) next and that didn't work either.... I thought that would mean "Use Watering Can on sides.front for duration:100" but I was mistaken...

Can someone help me write a simple program to loop the use of the Watering Can on a block the robot is facing or below it (Both are fine for me).
 
I think it goes something like this....

while true do 
robot.use(3) 

end

Is that right? Never created a program before so I don't know if there's anything else I need to add to it.
This program is pretty simple..
 
SECOND REQUEST
Okay for the second request, here's the idea.

Whiles the other robots are watering the essences bushes,
I want to have a second robot to break the Concentrated Essence Berry pumped inside his inventory by right-clicking them
as a player would do (again the simple robot.use() command works for that, I already tested it) 
 

The Robots would be auto-filed with Concentrated Essence Berry by Item Conduits (Pumped in) and the robots would 
use;
 A) All the slots and cycle though them will using the robot.use() function until the slot is empty
 B) I would fill the other slots with cobblestones and the robots would only use the first slot for Input and right-click from this slot.

Again, as for the above program, I would love to have this constantly running.
If possible, have this program hook to a redstone signal to switch it On an Off but that's not necessary but would be pretty cool since I could hook the redstone signal to Mob Essence system. 

 

CONCLUSION

As I said above, I really appreciate any help, even if you can't create a program that would do exactly what I want,

any help given will give me more knowledge of Lua and it's usage.

Both of the my requested programs should be "loop" or able to be turned On/Off via redstone signal.

Please provide the full program as I should paste it in the "edit name.lua" file that I will create.
I'm really new to this whole thing!

 

Thank you! And Have a Good Day if you read this ;)

EXTRA

If possible for a last request, this one is not really that important for now, mostly because I might be able to figure it out after you help me with the above but anyway here's the idea!

I want to have robot to collect the Concentrated Essence Berry from the bushes,  instead of the MFR Harvester.
Reason behind that is I want to use something new and unique. And robots are freaking cool!

The robot would be place over a chest, planted into the ground and a charger would be behind it.
The robot would be facing air blocks and on the left and right side of it, a bush. 
It would look left, right-click the bush, turn right twice to face the right bush and right-click it then turn left again and move foward once to the next bushes. When it reaches the end of a row of bushes it would do a turn-around (180 degree) and go up once to collect another row..... after collecting the essences it would go back to the chest and charger and drop his inventory into the chest while being recharged.

Here's a text graphic example where D represent the chest and is placed one block lower and C is the Charger block, O is the Robot, and X are the bushes and they are all on the same height levels. (except for the stack of bushes but the robot would start over the chest next to the charger) 

   XXXXX <--- Stacked 4 times in height 
D(OC)     <--- Robot over the chest with a charger behind it, nothing above or in front of it, bushes on each sides, stacked 4 high. 

   XXXXX <--- Stacked 4 times in height


It would collect in a row of 5 for this example so it would go 4 times forward in theory and those bushes would be superposed 4 times so It would go up once repeat the collections method from above go up again, repeat collect, go up again and repeat collection on the last row, that would make the robot on the exact position for the chest and the charger, so it could just drop down 3 blocks and turn around to face the air block path, drop his content in the inventory below it and recharge a little. 

To make sure the robot always got inventory space left on it, it should check if the Inventory is Empty before it repeat the program.


Thanks again! :)

 

 

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I can help with the first request and with the second.

 

First:

 

When you call a method, you must give all params in order, up to the one that you need to modify. robot.use(3,100) would not work, as you are missing the sneaking or not boolean between those two.. It should be robot.use(3,false,100). There is a sides library that allows for direct side naming in english, E.g.:

sides = require("sides")

robot.use(sides.front,false,100)

If you want to keep doing that, just put all the action code in an eternal while loop:

sides = require("sides")

while true do --run forever
  robot.use(sides.front,false,100)
end

Note that you should never put requires into loops, as that uses up memory unnecessarily. I'm also not sure if ExtraUtils breaks the watering can in robots, I'll have to test that. If so, the idea won't work unless you use a reinforced watering can.

 

Second:

 

 

I want to have a second robot to break the Concentrated Essence Berry pumped inside his inventory by right-clicking them

 

As far as I know, you can't directly use item pipes to pipe into robots, instead you must have robots pull from inventories with robot.suck().

 

Quickly writing the whole program, I came up with something to this degree, you'll need an inventory controller upgrade:

sides = require("sides")
robot = require("robot")
component = require("component")
controller = component.inventory_controller

while true do --keep on running
  while robot.suckDown() do --pull all berries into inventory, from inventory directly below the robot, eg chest
    robot.suckDown()
  end
  for i = 1,robot.inventorySize() do --switch between slots
    robot.select(i)
    controller.equip() --equip the berry
    for p = 0, 65 do --right click the berry until slot empty
      robot.use() --since use only uses the item in the tool slot, equipping it is necessary
    end
  end
end

You don't need to use duration when clicking berries, as they instantly use. By the way, I used idea A, so the robot will fill it's inventory then use them all, repeat, etc.

 

I'll let you figure out how to make it redstone controlled so you can learn. (Hint: A redstone card is needed in the robot, give that a google, it provides the redstone api which you need)

 

 

Happy to help. (I've become sort-of the low tier support guy, I'm usually around to answer questions.) Be sure to check out the program showcase part of the forums, I have a few programs there that are meant for average joe players, and are easy to set up and use.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.