Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

How to Properly use .activate();

Joined
May 6, 2015
Messages
16
I'm trying to change the spell being used with the following.
Powers.Magic.FIRE_WAVE.activate();
Instead of switching the spell it goes to the magic book and goes to the teleport category.
 
Joined
Dec 10, 2014
Messages
3,255
Based on how hard I am wrestling with this API I would think it more likely my implementation.
Possibly, but something like this would indicate a logic flaw more than a misunderstanding. Is there anywhere in your code where the teleport category would be opened?

.activate() activates the spell if the category is open, or if it is not open, then it opens the category, which allows the next loop to select the spell.
 
Joined
May 6, 2015
Messages
16
Code:
public class ahrim extends Task {
    @Override
    public boolean validate() {
        return true;
    }
    @Override
    public void execute() {
        Powers.Magic.FIRE_WAVE.activate();
    }
}

Not that I can see.
 
Joined
Dec 10, 2014
Messages
3,255
Code:
public class ahrim extends Task {
    @Override
    public boolean validate() {
        return true;
    }
    @Override
    public void execute() {
        Powers.Magic.FIRE_WAVE.activate();
    }
}

Not that I can see.
Hmmm, true.

Also, check up on the Java Conventions pls :p
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,046
Add some debugging to make sure this is where in the code it's going. If you confirm then this is a problem to elevate to @Cloud.
 
Joined
May 6, 2015
Messages
16
Hmmm, true.

Also, check up on the Java Conventions pls :p

I come from a mostly embedded background. I know AVR and ARM assembly as well as C, but other than some Python this is my first crack at an OOL. So, please bear with me as I learn the ropes. Is there something, in particular, that's bugging you and is there a convention paper I should check out?



Add some debugging to make sure this is where in the code it's going. If you confirm then this is a problem to elevate to @Cloud.

Sure, is there a preferred way of doing that?
 
The Pip Collector
Joined
Sep 14, 2014
Messages
445
I come from a mostly embedded background. I know AVR and ARM assembly as well as C, but other than some Python this is my first crack at an OOL. So, please bear with me as I learn the ropes. Is there something, in particular, that's bugging you and is there a convention paper I should check out?





Sure, is there a preferred way of doing that?
You use ahrim - By java conventions, Class names are mixed case, beginning with a capital character followed by lowercase until another verb/name is hit. So it would should be public class Ahrim or public class ActivatePrayer
 
Joined
Dec 10, 2014
Messages
3,255
I come from a mostly embedded background. I know AVR and ARM assembly as well as C, but other than some Python this is my first crack at an OOL. So, please bear with me as I learn the ropes. Is there something, in particular, that's bugging you and is there a convention paper I should check out?
Class names are PascalCase, variables are camelCase, constants are ALL_CAPS, resources and package names are lower_case :p
Conventions are just a pet peeve of mine xD
 
Joined
May 6, 2015
Messages
16
Fair enough. I went forward with development, but I still haven't gotten this to work properly. What debug information would be helpful to solving this?
 
Joined
Dec 10, 2014
Messages
3,255
Fair enough. I went forward with development, but I still haven't gotten this to work properly. What debug information would be helpful to solving this?
just a system out confirming that the code block is being entered, and maybe also the value that the method returns
 
Joined
May 6, 2015
Messages
16
Here is a stripped down main class that exhibits the same behavior
Code:
package com.designdecay.barrows;

import com.runemate.game.api.script.framework.task.TaskScript;
import com.designdecay.barrows.Ahrim;

public class Barrows extends TaskScript {
    @Override
    public void onStart(String... args){
        add(new Ahrim());
    }
}

Here is the referenced class
Code:
package com.designdecay.barrows;

import com.runemate.game.api.script.framework.task.Task;
import com.runemate.game.api.rs3.local.hud.Powers;

public class Ahrim extends Task {
    @Override
    public boolean validate() {
        return true;
    }
    @Override
    public void execute() {
        Powers.Magic.FIRE_BOLT.activate();
        System.out.println("Ahrim");
    }
}

It reaches the code block properly, but it doesn't select the spell. I still think this is a failure on my part, but I can't for the life of me figure out how to use it properly.
 
Joined
Dec 10, 2014
Messages
3,255
Here is a stripped down main class that exhibits the same behavior
Code:
package com.designdecay.barrows;

import com.runemate.game.api.script.framework.task.TaskScript;
import com.designdecay.barrows.Ahrim;

public class Barrows extends TaskScript {
    @Override
    public void onStart(String... args){
        add(new Ahrim());
    }
}

Here is the referenced class
Code:
package com.designdecay.barrows;

import com.runemate.game.api.script.framework.task.Task;
import com.runemate.game.api.rs3.local.hud.Powers;

public class Ahrim extends Task {
    @Override
    public boolean validate() {
        return true;
    }
    @Override
    public void execute() {
        Powers.Magic.FIRE_BOLT.activate();
        System.out.println("Ahrim");
    }
}

It reaches the code block properly, but it doesn't select the spell. I still think this is a failure on my part, but I can't for the life of me figure out how to use it properly.
Pretty sure it's a problem within the API, I had a similar problem with Magic Imbue a while back
 
Joined
May 6, 2015
Messages
16
Possibly related. I can't seem to get prayer to work either.
Code:
Powers.Prayer.PROTECT_FROM_MELEE.toggle();
This opens the prayer tab and then doesn't activate the prayer.
 
Joined
Dec 10, 2014
Messages
3,255
Possibly related. I can't seem to get prayer to work either.
Code:
Powers.Prayer.PROTECT_FROM_MELEE.toggle();
This opens the prayer tab and then doesn't activate the prayer.

Hmmm, it sounds like it's doing half of the expected behaviour.
Each call it either activates the prayer if it's not open, or it opens the tab if it's not.
Try chucking the prayer on your action bar and see if that changes any thing
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
Looks like to some extent this is my fault. One of the checks I was doing was checking interface mode instead of combat mode which resulted in some odd behavior. I'm working on making it work in modern combat mode on legacy interfaces as I type this.

Edit: Should now work fine :)
 
Last edited:
Joined
May 6, 2015
Messages
16
Looks like to some extent this is my fault. One of the checks I was doing was checking interface mode instead of combat mode which resulted in some odd behavior. I'm working on making it work in modern combat mode on legacy interfaces as I type this.

Edit: Should now work fine :)

Thank you. Magic is working properly, however prayer is still malfunctioning. I am testing using a modern interface and a legacy combat mode. Also, is there a preferred way of handling a duel wield wand and book? Currently, it attempts to change the spell, but doesn't select main hand or off hand.
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
Thank you. Magic is working properly, however prayer is still malfunctioning. I am testing using a modern interface and a legacy combat mode. Also, is there a preferred way of handling a duel wield wand and book? Currently, it attempts to change the spell, but doesn't select main hand or off hand.
Prayers are working fine for me on that setup, you are using the normal spellbook correct? Also I'm not familiar with what you're talking about in your last sentence.
 
Top