Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Solve Geni Lamp


    abouhanafy87

    Recommended Posts

    hi every one .

    i hope this script help .

     

    public void SolveGeniLamp(Skill skill){
        Item item = Inventory.get(it-> it.getName().equals("Lamp") && it.hasAction("Rub"));
        if(item != null ){
            if(item.interact("Rub")){
                Sleep.sleep(1000,1500);
                Widget choiseSkill = Widgets.getWidget(240);
                if(choiseSkill != null && choiseSkill.isVisible()){
                    switch (skill){
                        case ATTACK:
                            wig = Widgets.getChildWidget(240,2);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case STRENGTH:
                            wig = Widgets.getChildWidget(240,3);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case RANGED:
                            wig = Widgets.getChildWidget(240,4);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case MAGIC:
                            wig = Widgets.getChildWidget(240,5);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case DEFENCE:
                            wig = Widgets.getChildWidget(240,6);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case HITPOINTS:
                            wig = Widgets.getChildWidget(240,7);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case PRAYER:
                            wig = Widgets.getChildWidget(240,8);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case AGILITY:
                            wig = Widgets.getChildWidget(240,9);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case HERBLORE:
                            wig = Widgets.getChildWidget(240,10);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case THIEVING:
                            wig = Widgets.getChildWidget(240,11);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case CRAFTING:
                            wig = Widgets.getChildWidget(240,12);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case RUNECRAFTING:
                            wig = Widgets.getChildWidget(240,13);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case SLAYER:
                            wig = Widgets.getChildWidget(240,14);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case FARMING:
                            wig = Widgets.getChildWidget(240,15);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case MINING:
                            wig = Widgets.getChildWidget(240,16);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case SMITHING:
                            wig = Widgets.getChildWidget(240,17);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case FISHING:
                            wig = Widgets.getChildWidget(240,18);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case COOKING:
                            wig = Widgets.getChildWidget(240,19);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case FIREMAKING:
                            wig = Widgets.getChildWidget(240,20);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case WOODCUTTING:
                            wig = Widgets.getChildWidget(240,21);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case FLETCHING:
                            wig = Widgets.getChildWidget(240,22);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case CONSTRUCTION:
                            wig = Widgets.getChildWidget(240,23);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        case HUNTER:
                            wig = Widgets.getChildWidget(240,24);
                            widg = Widgets.getChildWidget(240,26);
                            if(wig != null && wig.isVisible()){
                                if(wig.interact()){
                                    Sleep.sleep(500,1200);
                                    widg.interact();
                                }
                            }else Widgets.closeAll();
                            break;
                        default:
                            Logger.log("ther is no widgit like this");
                            choiseSkill.close();
                    }
                }
            }
        }
    }
    Link to comment
    Share on other sites

    Nice first attempt.

    There is a huge amount of repeated code in there, each case of the switch statement is basically the same code. One way you could simplify this is by storing a map of Skills & their corresponding WidgetChild Ids, then you can grab the child widget id as a variable and pass it into the widget interaction block.

     

        static Map<Skill, Integer> SKILL_WIDGETID_MAP = new HashMap<>(){{
            put(Skill.ATTACK, 2);
            put(Skill.STRENGTH, 3);
            put(Skill.RANGED, 4);
            //TODO: Add all other skills here
        }};
    
    
        public void SolveGeniLamp(Skill skill) {
            Item item = Inventory.get(it-> it.getName().equals("Lamp") && it.hasAction("Rub"));
            if (item == null) {
                return; // Return early, nothing to do.
            }
            if (item.interact("Rub")) {
                Sleep.sleep(1000, 1500); /
                Widget chooseSkillWidget = Widgets.getWidget(240);
                if (chooseSkillWidget != null && chooseSkillWidget.isVisible()){
                    Integer childId = SKILL_WIDGETID_MAP.get(skill);
                    if (childId == null) {
                        Logger.error("Unknown Child Widget id for Skill " + skill.toString());
                        return;
                    }
                    WidgetChild wig = Widgets.getChildWidget(240, childId);
                    WidgetChild widg = Widgets.getChildWidget(240, 26);
                    if (wig != null && wig.isVisible()) {
                        if (wig.interact()) {
                            Sleep.sleep(500,1200);
                            widg.interact();
                        }
                    } else {
                        Widgets.closeAll();
                    }
                }
            }
        }

     

     

     

    Edited by hashbang
    Link to comment
    Share on other sites

    20 hours ago, hashbang said:

    Nice first attempt.

    There is a huge amount of repeated code in there, each case of the switch statement is basically the same code. One way you could simplify this is by storing a map of Skills & their corresponding WidgetChild Ids, then you can grab the child widget id as a variable and pass it into the widget interaction block.

     

        static Map<Skill, Integer> SKILL_WIDGETID_MAP = new HashMap<>(){{
            put(Skill.ATTACK, 2);
            put(Skill.STRENGTH, 3);
            put(Skill.RANGED, 4);
            //TODO: Add all other skills here
        }};
    
    
        public void SolveGeniLamp(Skill skill) {
            Item item = Inventory.get(it-> it.getName().equals("Lamp") && it.hasAction("Rub"));
            if (item == null) {
                return; // Return early, nothing to do.
            }
            if (item.interact("Rub")) {
                Sleep.sleep(1000, 1500); /
                Widget chooseSkillWidget = Widgets.getWidget(240);
                if (chooseSkillWidget != null && chooseSkillWidget.isVisible()){
                    Integer childId = SKILL_WIDGETID_MAP.get(skill);
                    if (childId == null) {
                        Logger.error("Unknown Child Widget id for Skill " + skill.toString());
                        return;
                    }
                    WidgetChild wig = Widgets.getChildWidget(240, childId);
                    WidgetChild widg = Widgets.getChildWidget(240, 26);
                    if (wig != null && wig.isVisible()) {
                        if (wig.interact()) {
                            Sleep.sleep(500,1200);
                            widg.interact();
                        }
                    } else {
                        Widgets.closeAll();
                    }
                }
            }
        }

     

     

     

    good job man 👏

     

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.