
Fiyero wrote:
There are some gobs that do not display their name, like dragonflies, carts, plows or toads, is there a way to dynamically "find them"?
Im assuming the getName() function returns null or empty on these and thus the find function which uses indexOf on the getName method wont work.
void detectObjects(){
synchronized (ark_bot.glob.oc) {
for (Gob gob : ark_bot.glob.oc) {
String[] parts = gob.GetResName().split("/");
if(gob.GetResName().indexOf("herbs/")>=0){
print("Found a "+parts[parts.size()-1]);
println(" to the "+findAdvancedGeneralDirection(gob.getc()));
}
else if(parts[parts.size()-1].equals("")){
String unknownGob = "something..."
if(MapView.tilify(gob.getc())==MapView.tilify(ark_bot.MyCoord())){continue;}//its me...
unknownGob = getLayeredName(gob);
println("["+gob.id+"] I see a "+unknownGob+" nearby..."+findAdvancedGeneralDirection(gob.getc()));
}
}
}
}
public String getLayeredName(Gob gob){
for (GAttrib a : gob.attr.values()){
println(a.toString());
if(a instanceof Layered){
Layered gh = (Layered)gob.getattr(Layered.class);
for(Map.Entry entry : gh.sprites.entrySet()){
String type = entry.getKey().toString().split("/")[1];
if(type.equals("kritter"))
return entry.getKey().toString().split("/")[2];
else if(type.equals("borka"))
return "someone";
break;
}
}
}
return "something..";
}
String findAdvancedGeneralDirection(Coord destCoord){
String dir = "";
Coord dest = MapView.tilify(destCoord);
Coord myPos = MapView.tilify(ark_bot.MyCoord());
//North = +Y, South = -Y; West = -X, East = +X
if(dest.y > myPos.y)
dir += "S";
else
dir += "N";
if(dest.x > myPos.x)
dir += "E";
else
dir += "W";
return dir;
}
Fiyero wrote:With this, your bot can even "see" other things like boars, bears and even heartlings. (So they can stop what they are doing and teleport away)
Fiyero wrote:Still needs work, today while testing, my detector was thinking some chickens were heartlings out to get him.
Myzreal wrote:Generally, I would like to know how to either open the Study Widget, so I can use ark_bot.item_click("transfer") or some other way to insert the given item into the Study interface. Additionally, if it is possible to access a Label in a Widget and that Label's text variable.
Myzreal wrote:Does anyone know how to access the Study Widget? I want to make the bot create cone cows while chopping down trees and putting them in his Study. I found the CharWnd and the variable which holds the Study Widget, but don't know whether it's accessible (no public nor private modifier). It also has a Label which shows the attention used, is that accessible somehow?
Generally, I would like to know how to either open the Study Widget, so I can use ark_bot.item_click("transfer") or some other way to insert the given item into the Study interface. Additionally, if it is possible to access a Label in a Widget and that Label's text variable.
Any help appreciated
Users browsing this forum: Claude [Bot], Google [Bot] and 2 guests