First attempt to create a script...

Discussion in 'Developer Support' started by skrall, Feb 2, 2015.

  1. skrall

    Joined:
    Jul 24, 2014
    Messages:
    537
    Likes Received:
    131
    Well I finally gave developing a shot and I'm determined to release something functional!
    First of all, I tried making a Seren Stone miner based on @SlashnHax 's tutorial power miner.
    I haven't changed much of the code but this is what I got so far:
    Code (Javascript):
    1. package com.runemate.skrall.bots.seren
    2.  
    3. import com.runemate.game.api.hybrid.region.Players;
    4. import com.runemate.game.api.hybrid.entities.GameObject;
    5. import com.runemate.game.api.hybrid.region.GameObjects;
    6. import com.runemate.game.api.script.Execution;
    7. import com.runemate.game.api.script.framework.LoopingScript;
    8. import com.runemate.game.api.hybrid.local.Camera;
    9.  
    10.  
    11. /**
    12. * Seren Stone miner by skrall
    13. * based on Slashnhax's Powerminer
    14. */
    15. public class AFKSerenStones extends LoopingScript {
    16.  
    17.     private enum State {
    18.  
    19.         MINE, WAIT
    20.     }
    21.  
    22.  
    23.     @Override
    24.     public void onLoop() {
    25.         switch(getCurrentState()){
    26.             case MINE:
    27.                 GameObject rocks = GameObjects.newQuery().names("Seren stone").results().nearest();
    28.                 if(rocks != null && rocks.getDefinition() != null) {
    29.                     if(!rocks.isVisible()) {
    30.                         Camera.turnTo(rocks);
    31.                     }
    32.                     if(rocks.interact("Mine", rocks.getDefinition().getName())) {
    33.                         Execution.delayUntil(()->Players.getLocal().getAnimationId() != -1, 500, 5000);
    34.                     }
    35.                 }
    36.                 break;
    37.             case WAIT:
    38.                 break;
    39.             }
    40.         }
    41.     }
    42.  
    43.     @Override
    44.     public void onStop(){
    45.     }
    46.  
    47.     private State getCurrentState(){
    48.         if(Players.getLocal().getAnimationId() == -1 || rocks == null || !rocks.isValid()) {
    49.             return State.MINE;
    50.         } else {
    51.             return State.WAIT;
    52.         }
    53.     }
    54. }

    Now I got some text that is either appearing red, or has been underlined in red:

    Code (Javascript):
    1. package com.runemate.skrall.bots.seren
    Can't resolve symbol 'skrall'. Do I need to add a folder with my username or something?

    Code (Text):
    1. Execution.delayUntil(()->Players.getLocal().getAnimationId() != -1, 500, 5000);
    ',' or ';' expected. The part '()->P is underlined in red. I doublechecked my code and also the code of SNH and I couldn't find anything missing.

    Code (Javascript):
    1. private State getCurrentState(){
    Cannot resolve symbol 'State'. I have no idea what I'm doing wrong here to be honest lol.

    Feedback is very much appreciated! Once I get this working I'll try to finetune the delays some more and maybe I'll add a paint too! :)
     
  2. Baddest Man on Earth

    Joined:
    Nov 26, 2014
    Messages:
    610
    Likes Received:
    242
    Do you even java bro?
     
  3. SlashnHax

    SlashnHax The Chosen One

    Joined:
    Dec 10, 2014
    Messages:
    2,838
    Likes Received:
    786
    You have to add the runemate jar as a library, and you need to understand packaging.
     
  4. skrall

    Joined:
    Jul 24, 2014
    Messages:
    537
    Likes Received:
    131
    Alright, I'll try to hone my skills. I know you guys are too skilled to waste your time teaching a noob how to java ^^
     
  5. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,062
    Likes Received:
    182
    I can help co-newbs out :)

    When you need help I shall attempt to help.
     
  6. skrall

    Joined:
    Jul 24, 2014
    Messages:
    537
    Likes Received:
    131
    I found this printed out copy of C++: How to Program by Deitel & Deitel in my leftovers from school. Does this give me a decent basis for Java?
     
  7. SlashnHax

    SlashnHax The Chosen One

    Joined:
    Dec 10, 2014
    Messages:
    2,838
    Likes Received:
    786
    I'd say the tutorials on the Oracle website would give you a decent basis for Java
     
  8. Baddest Man on Earth

    Joined:
    Nov 26, 2014
    Messages:
    610
    Likes Received:
    242
    If you want to learn java, read a book on java and do some trial and error.

    You can read all the books in the world and take every programming class, and you won't learn anything unless you write the code and attempt to problem solve yourself.
     
  9. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,062
    Likes Received:
    182
    If you have 23 hours I'd suggest https://www.youtube.com/view_play_list?p=84A56BC7F4A1F852

    The professor keeps it interesting & entertaining!
     
    skrall likes this.

Share This Page

Loading...