Nbacon Posted May 29, 2020 Share Posted May 29, 2020 (edited) I just finshed writing 15000 lines of code that implements every method and class once in the osbot api. I want to make something like "OSRS Script Factory" after Im doing writing my implementation of scheme in java. Only problems is I have 15000 lines of untested code. Any and all ideas on how to legitment test every method and class in the api are welcome. And how much memory is too much memory for one bot? I know it caps out at 4 gp but what is max you would goto. Edited May 29, 2020 by Nbacon spell and grammar Quote Link to comment Share on other sites More sharing options...
Protoprize Posted May 29, 2020 Share Posted May 29, 2020 (edited) Can you post an example of what you have done? Just want to get the right idea on what you mean Edited May 29, 2020 by Protoprize Quote Link to comment Share on other sites More sharing options...
Juggles Posted May 29, 2020 Share Posted May 29, 2020 I don't see the point of what you did? You just copy and pasted the API into your IDE? 1 Quote Link to comment Share on other sites More sharing options...
Nbacon Posted May 29, 2020 Author Share Posted May 29, 2020 I hope you can understand this below... Ive been told I suck at explain things. so follow up questions if needed. At the moment im just doing every method 1 at a time and they mostly work on the frist try just need ideas to speed it up. How the program works. So I casted everthing to Object so it can be passed every were and casted back to that object. This is not the best way but it was fastest way implenet the whole api. So there are 2 ways to test the code call the lamba with java or in scheme. The lambdas on the java side are stored in a hashmap <int, 3-arg-lamba> with 1 maped to acceptTrade, 2 maped to ActionFilter, and 3 maped to add... . Calling the hashmaps in java. OSBOT.get(idNumber).run(args, interp, this.name) idNumber every method has a number and there are about 1000 of them. args is a linked list [something ]-> [something] -> ...-> [null] interp is my programing language no osbot methods need it. this.name is the name of the method like EDGEVILLE,equip,open , isopen, caaar, cddddr Calling the method in scheme and how it will run it in java. (equip (getEquipment) (HEADSLOT) "Rune full helm" ) what it turns into on the java side. OSBOT.get( equip id Number).run( [(getEquipment) ] -> [(HEADSLOT) ] ->["Rune full helm" ] ->[null], interp, "equip"); x is the linked list first(x) = [(getEquipment) ] rest(x)= [(HEADSLOT) ] ->["Rune full helm" ] ->[null] [this is a cdr ] x =rest(x) now first(x) =[(HEADSLOT) ] and second(x) = first(rest(x))=["Rune full helm" ] return scemeBot.getEquipment().equip((EquipmentSlot) (HEADSLOT), new String((char[]) ("Rune full helm" ))); examples of scheme code and how it works >(EDGEVILLE)\n returns Banks.EDGEVILLE not matter what is given to it. >EDGEVILLE\n returns {EDGEVILLE} this says its a method and should go in () The line below is example of inside out aways does the inner most right () set and is also infix... (op0 (op1 arg ... ) (op2 arg1 arg2 ) (op3 arg1)) op3 then op2 then op1 then op0 (EDGEVILLE (+ 5 2 (* 5 6) )) turns to (EDGEVILLE (+ 5 2 30 )) turns to (EDGEVILLE (37 )) and is the same thing as (EDGEVILLE) beucase it takes no arges same thing is posible with equip and open bank but in this case they would do something (EDGEVILLE (open (getBank)) (equip (getEquipment) (HEADSLOT) "Rune full helm" ) ) this will put on the rune full helm open the bank then finally Banks.EDGEVILLE Testcases The lines below will fail cases. (equip (getEquipment)) returns FALSE (equip (getEquipment) (HEADSLOT) ) returns FALSE (equip "Rune full helm" (HEADSLOT) ) returns FALSE (equip (HEADSLOT) ) returns FALSE The line below will do the same thing [returns true if the bot puts a rune full helm on] the (getEquipment) is not needed. (equip (getEquipment) (HEADSLOT) "Rune full helm" ) == (equip (getEquipment) (HEADSLOT) 1163 ) ==(equip (HEADSLOT) "Rune full helm" ) == (equip (HEADSLOT) 1163 ) (equip (getEquipment) 9 "equip" ) == (equip 9 "equip" ) *no idea what that means but what ever (Equips an item in the specified inventory slot with the specified action.)* So I think there are 4 Types. static return / do the same thing no mater the args. examples getKeyboard(), getMap().isMinimapLocked(), getBot().isMirrorMode() 1 class many methods with diffent args types examples equip, most RS2Widget methods ... its a long list muiltple classes all with same method that need casting examples use , get, getHeight muiltple classes all with same static/ do the one thing no mater the args examples isopen, close, getInterfaceChildId Type 1. DEF("EDGEVILLE", c, 0, (x, y, z) -> { return Banks.EDGEVILLE; }); Type 2 can take a class but off of context it not needed. Because there are no other methods called that in any other class. Quote DEF("equip", c, 1, (x, y, z) -> { if (first(x) instanceof Equipment) { x = rest(x); } if (first(x) instanceof EquipmentSlot) { if (second(x) instanceof Long || second(x) instanceof Integer) { return scemeBot.getEquipment().equip((EquipmentSlot) first(x), Math.toIntExact(num(second(x)))); } if (second(x) instanceof char[]) { return scemeBot.getEquipment().equip((EquipmentSlot) first(x), new String((char[]) second(x))); } } if (first(x) instanceof Long || first(x) instanceof Integer) { if (second(x) instanceof char[]) { return scemeBot.getEquipment().equip(Math.toIntExact(num(first(x))), new String((char[]) second(x))); } } return FALSE; }); Type 3 need to cast to get make object usable with method type Quote DEF("exists", c, 1, (x, y, z) -> { if (first(x) instanceof Entity) { return ((Entity) first(x)).exists(); } if (first(x) instanceof GroundDecoration) { return ((GroundDecoration) first(x)).exists(); } if (first(x) instanceof GroundItem) { return ((GroundItem) first(x)).exists(); } if (first(x) instanceof InteractableObject) { return ((InteractableObject) first(x)).exists(); } if (first(x) instanceof org.osbot.rs07.api.model.Character) { return ((org.osbot.rs07.api.model.Character) first(x)).exists(); } if (first(x) instanceof WallDecoration) { return ((WallDecoration) first(x)).exists(); } if (first(x) instanceof WallObject) { return ((WallObject) first(x)).exists(); } return FALSE; }); Type 4 alot of method with the same name but no need to cast. Quote DEF("open", c, 0, n, (x, y, z) -> { if (first(x) instanceof Bank) { try { return ((Bank) first(x)).open(); } catch (InterruptedException e) { e.printStackTrace(); } } if (first(x) instanceof DepositBox) { return ((DepositBox) first(x)).open(); } if (first(x) instanceof LogoutTab) { return ((LogoutTab) first(x)).open(); } if (first(x) instanceof Magic) { return ((Magic) first(x)).open(); } if (first(x) instanceof Prayer) { return ((Prayer) first(x)).open(); } if (first(x) instanceof Settings) { return ((Settings) first(x)).open(); } if (first(x) instanceof Skills) { return ((Skills) first(x)).open(); } if (first(x) instanceof Tabs) { if (second(x) instanceof Tab) { if (third(x) instanceof Boolean) { return ((Tabs) first(x)).open((Tab) second(x), (Boolean) third(x)); } return ((Tabs) first(x)).open((Tab) second(x)); } } return null; }); Thanks. Quote Link to comment Share on other sites More sharing options...
Nbacon Posted May 29, 2020 Author Share Posted May 29, 2020 (edited) 1 hour ago, Juggles said: I don't see the point of what you did? You just copy and pasted the API into your IDE? Well the main goal is run-time scripts. Then after I get it debugged this nightmare. Ill slap a gui on and make it look like scatch just for the memes. I do have some methods 100% working and this code below makes uncharged orbs. Quote (define makepart (lambda () (cond ((bankopen?)(closebank)) ((Animation?)(wait)) ((makeall?)(makeall 7)) ((not (use? 1785) )(interact 1785)) (else (interact 567))))) (define bankpart (lambda () (if(not (bankopen?)) (bankopen) (and (getitem? 1785 1)(getitem 567 "all") ) (define loop (lambda () (if (not (invhas? 567 )) (makepart) (bankpart)))) Edited May 29, 2020 by Nbacon 1 Quote Link to comment Share on other sites More sharing options...
Tom Posted May 29, 2020 Share Posted May 29, 2020 dont really have any comment here but looks like some cool stuff keep it up Quote Link to comment Share on other sites More sharing options...