ok it's saying it can't find property/variable "ui" because TECHNICALLY ui is a variable in all widgets and i when i did my mods i had a variable called "ui" which was the latest UI instance (like all widgets have) for you this would be weird to do since you're not technically part of one java class, you're in your own script world and idk if it has some static ui variable out there, but there's another solution. I was hoping that Pan's client would have a UI instance static variable at use in the UI.java but whoever code he pulled from he didn't seem to add that so we'll have to go through ui through a widget.
When i say widget i mean anything UI related, Items (in inventory), windows, etc. So you're going to want to get a copy of a widget in a variable say 'x' (i'm not sure how you do that in art_bot but i assume there's some easy method...). Now that we have 'x' we can access UI through the ui variable that all widgets contain:
- Code: Select all
x.ui.mainview.wdgmsg("itemact", new Coord (1,1),well_c,wellId,well_c);
The above should work, also as i'm looking through Pan's ark_bot.java ->
https://github.com/PanAeon/Hearth-Haven ... k_bot.javait contains a static reference to the UI class so you should be able to :
- Code: Select all
ark_bot.ui.mainview.wdgmsg("itemact", new Coord (1,1),well_c,wellId,well_c);
the last method should work and i would recommend that over the widget example actually.
Bucket-Barrel problem :
http://paste.lisp.org/display/124383#3The above link is a section of code from my hunger bot actually you can try to translate that to ark_bot stuff, but i'm not sure if ark_bot provides all the functions i used.
Here's a explanation of the process though:
1) Get a EMPTY bucket found within your inventory
::(ekets (get_inv_items_name "gfx/invobjs/buckete" PLAYER_INV))
ekets = my variable which will end up being type ArrayList<Widget>
get_inv_items_name is a function used to get a widget from in inventory X[Player's for this] with the RES name of "gfx/invobjs/buckete" which is empty bucket resource
2) Find our barrel
::(barrels (getobjs "gfx/terobjs/barrel")) [NOTE: this code wasn't part of the above pasted so you won't see it there]
barrels => variable name for my ArrayList<Gob> Remember these are Gobs, not widgets since they are Ocache objects
getobjs => refers to my function for finding Ocache objects within the current draw distance via their RES name "gfx/terobjs/barrel" for barrels
3) Take the first empty bucket found
::(let ((eket (jcall "get" ekets 0)))
this is just dealing with my arraylist of empty buckets, i want the first one in there (you probably won't need this)
4)OPTIONAL[see 6)] Right click the barrel
::(right_click_obj barrel)
right_click_obj => Right clicks a ocache object (Gob); [wdgmsg("click"...)']
5) Sleep your program, 2 seconds is good enough assuming your bot is within 1 tile of the barrle
::(jsleep 2000) [in millis for me]
6)OPTIONAL: Error checking, make sure the barrel has water and has > 0 L. I don't think this is possible with ark_bot without alot of hacking around to be honest so you probably can just ignore this.
::(if (> (get_barrel_depth) 0)
7) Put the bucket back in inventory slot found at
::(let ((cx (jcall "coord_x" eket))
::(cy (jcall "coord_y" eket)))
this is basically just getting the coordinates of the bucket widget when it back still in your inventory, cx,cy are of type Coord
-----------------------
At this point is where we actually get the water
-----------------------
8) Pick your bucket up
::(take_item eket)
take_item => refering to wdgmsg("take") for a Item widget, ark_bot should have a function for doing this and i think you were using it earlier
9) Sleep your program in case of lag, 1 sec will do
10) Interact the bucket with the barrel
::(interact_hold_gob barrel)
interact_hold_gob => Right clicks a ocache object (Gob); [NOTE: this is a wdgmsg("itemact",....) call to MapView.java also known as (ui.mainview)]
11) Sleep your program again once again in case of lag, time depends on how far this barrel will be from you
12) Final step: put the bucket back in inventory
::(put_hold_item cx cy PLAYER_INV))
put_hold_item => refers to a function that puts the current item being held back into Inventory X (player for us) at coordinates cx,cy which is where the bucket was originally. I think ark_bot has a function to do this as well.
That's basically how you do bucket -> barrel stuff. You really don't need the optional stuff unless you think it could happen, for me i had to use it so that my hungerbot would know to go to the next barrel when the old one was empty.