Scorncial Posted March 16, 2015 Share Posted March 16, 2015 (edited) Hi, so I'm getting into Java scripting (but I know a decent amount of PHP) and as always, I learn best by actually doing stuff. So therefore I'd like to learn some really basic stuff by making a very simple script. The script I'd like to make should talk against Wyson the gardener at the Falador garden and buy Woad leaves from him. This is what I have so far: import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "Luigi", info = "Buys Woad leaves from Wyson the gardener in Falador Park", name = "Woad Leaf Buyer", version = 0.1, logo = "") public class main extends Script { @Override public void onStart() { log("Woad Leaf Buyer has started."); } private enum State { TALK, WAIT }; private State getState() { if (condition 1 is true) return State.TALK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case TALK: NPC gardener = objects.closest("Wyson the gardener"); if (stall != null) { stall.interact("Talk-to"); } break; case WAIT: sleep(random(500, 700)); break; } return random(200, 300); } @Override public void onExit() { log("Thanks for running my first script"); @Override public void onPaint(Graphics2D g) { } } I'm making this script based upon this beginners tutorial. Eclipse gives me an error on line 20, 30, 31 and 32. What am I doing wrong? Also how can I check if the user has more than 20 coins in his inventory and exit the script, if that ain't the case? Thanks for helping a starting noob like me Edited March 16, 2015 by Scorncial Quote Link to comment Share on other sites More sharing options...
Scorncial Posted March 16, 2015 Author Share Posted March 16, 2015 It's a little difficult to read. If you could alter the resolution the SDN scripters might be able to assist you more efficiently I would like to do that But could you tell me how? Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 16, 2015 Share Posted March 16, 2015 (edited) Hi, so I'm getting into Java scripting (but I know a decent amount of PHP) and as always, I learn best by actually doing stuff. So therefore I'd like to learn some really basic stuff by making a very simple script. The script I'd like to make should talk against Wyson the gardener at the Falador garden and buy Woad leaves from him. This is what I have so far: import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "Luigi", info = "Buys Woad leaves from Wyson the gardener in Falador Park", name = "Woad Leaf Buyer", version = 0.1, logo = "") public class main extends Script { @Override public void onStart() { log("Woad Leaf Buyer has started."); } private enum State { TALK, WAIT }; private State getState() { if (condition 1 is true) return State.TALK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case TALK: NPC gardener = objects.closest("Wyson the gardener"); if (stall != null) { stall.interact("Talk-to"); } break; case WAIT: sleep(random(500, 700)); break; } return random(200, 300); } @Override public void onExit() { log("Thanks for running my first script"); @Override public void onPaint(Graphics2D g) { } } I'm making this script based upon this beginners tutorial. Eclipse gives me an error on line 20, 30, 31 and 32. What am I doing wrong? Also how can I check if the user has more than 20 coins in his inventory and exit the script, if that ain't the case? Thanks for helping a starting noob like me Line 30: You want to get to the NPC but you try to define it as an object. Line 31: You try to interact with a variable called stall but that's never made. Line 32: Same as 31. For the coin thing: if(!(inventory.getAmount(COINID) < 20)) { stop(); } Edited March 16, 2015 by Rudie Quote Link to comment Share on other sites More sharing options...
Scorncial Posted March 16, 2015 Author Share Posted March 16, 2015 Line 30: You want to get to the NPC but you try to define it as an object. Line 31: You try to interact with a variable called stall but that's never made. Line 32: Same as 31. For the coin thing: if(!(inventory.getAmount(COINID) < 20)) { stop(); } Thanks, your comments helped a lot Would you have an idea on how to solve the error on line 20? Also, if I can't define the NPC as an object as what should I define it? The coin thing should this be put between line 27 and 28? Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 16, 2015 Share Posted March 16, 2015 Thanks, your comments helped a lot Would you have an idea on how to solve the error on line 20? Also, if I can't define the NPC as an object as what should I define it? The coin thing should this be put between line 27 and 28? Yes put the coin thing at the beginning of your loop. To define the npc: NPC gardener = npcs.closest("Wyson the gardener"); (Also make sure you import NPC). Line 20 you forgot the brackets at the if statement it should be: if(code here) { } Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 16, 2015 Share Posted March 16, 2015 (edited) Sorry double posted Edited March 16, 2015 by Rudie Quote Link to comment Share on other sites More sharing options...
Scorncial Posted March 16, 2015 Author Share Posted March 16, 2015 (edited) Yes put the coin thing at the beginning of your loop. To define the npc: NPC gardener = npcs.closest("Wyson the gardener"); (Also make sure you import NPC). Line 20 you forgot the brackets at the if statement it should be: if(code here) { } Thanks a lot, but I'm still getting an error on line 21, Eclipse says the following: Multiple markers at this line: - condition cannot be resolved to a variable - syntax error on tokens, delete these tokens And how can I find the Id for coins? This is my script now: import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "Luigi", info = "Buys Woad leaves from Wyson the gardener in Falador Park", name = "Woad Leaf Buyer", version = 0.1, logo = "") public class main extends Script { @Override public void onStart() { log("Woad Leaf Buyer has started."); } private enum State { TALK, WAIT }; private State getState() { if (condition 1 is true) { return State.TALK; } else { return State.WAIT; } } @Override public int onLoop() throws InterruptedException { if(!(inventory.getAmount(COINID) < 20)) { stop(); } switch (getState()) { case TALK: NPC gardener = npcs.closest("Wyson the gardener"); if (gardener != null) { gardener.interact("Talk-to"); } break; case WAIT: sleep(random(500, 700)); break; } return random(200, 300); } @Override public void onExit() { log("Thanks for running my first script"); } @Override public void onPaint(Graphics2D g) { } } Edited March 16, 2015 by Scorncial Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 16, 2015 Share Posted March 16, 2015 Thanks a lot, but I'm still getting an error on line 21, Eclipse says the following: And how can I find the Id for coins? This is my script now: import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "Luigi", info = "Buys Woad leaves from Wyson the gardener in Falador Park", name = "Woad Leaf Buyer", version = 0.1, logo = "") public class main extends Script { @Override public void onStart() { log("Woad Leaf Buyer has started."); } private enum State { TALK, WAIT }; private State getState() { if (condition 1 is true) { return State.TALK; } else { return State.WAIT; } } @Override public int onLoop() throws InterruptedException { if(!(inventory.getAmount(COINID) < 20)) { stop(); } switch (getState()) { case TALK: NPC gardener = npcs.closest("Wyson the gardener"); if (gardener != null) { gardener.interact("Talk-to"); } break; case WAIT: sleep(random(500, 700)); break; } return random(200, 300); } @Override public void onExit() { log("Thanks for running my first script"); } @Override public void onPaint(Graphics2D g) { } } Well you try to see if a boolean is true but you dont check a variable, when programming you can't just put plain text like you have in line 20 in the if statement. And for the coin id it should be 995 if I remember correctly Quote Link to comment Share on other sites More sharing options...
Scorncial Posted March 16, 2015 Author Share Posted March 16, 2015 Well you try to see if a boolean is true but you dont check a variable, when programming you can't just put plain text like you have in line 20 in the if statement. And for the coin id it should be 995 if I remember correctly Thanks I see, that was very stupid of me Do you have any idea how I can check if the player is currently talking to the gardener? Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 16, 2015 Share Posted March 16, 2015 Thanks I see, that was very stupid of me Do you have any idea how I can check if the player is currently talking to the gardener? Let me try something, hold on. Quote Link to comment Share on other sites More sharing options...
Scorncial Posted March 16, 2015 Author Share Posted March 16, 2015 Let me try something, hold on. No problem, take your time I just saw you're The Netherlands, I'm from Belgium, so we both speak Dutch Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 16, 2015 Share Posted March 16, 2015 (edited) No problem, take your time I just saw you're The Netherlands, I'm from Belgium, so we both speak Dutch if(myPlayer().isInteracting(gardener)) { } Kan je dat proberen, geen idee of het werkt heb het snel even gemaakt Edited March 16, 2015 by Rudie Quote Link to comment Share on other sites More sharing options...
Scorncial Posted March 16, 2015 Author Share Posted March 16, 2015 if(myPlayer().isInteracting(gardener)) { } Kan je dat proberen, geen idee of het werkt heb het snel even gemaakt Super bedankt But I'll keep writing in english so other people can still understand ;) So I did look a bit into the api and when talking to the gardener I'll need to use the "dialogues" class and use "clickContinue()" to talk to him, but how can I make the bot chose a specific option when he gets offered one? for example the gardener will ask how much he wants to pay for the Woad leaf, and you have 4 options: 5, 10, 15 and 20 gp, how do I make the bot to chose for the 20 gp option? Quote Link to comment Share on other sites More sharing options...
Rudie Posted March 16, 2015 Share Posted March 16, 2015 (edited) Super bedankt But I'll keep writing in english so other people can still understand ;) So I did look a bit into the api and when talking to the gardener I'll need to use the "dialogues" class and use "clickContinue()" to talk to him, but how can I make the bot chose a specific option when he gets offered one? for example the gardener will ask how much he wants to pay for the Woad leaf, and you have 4 options: 5, 10, 15 and 20 gp, how do I make the bot to chose for the 20 gp option?Isn't there a method in the API to select a specific option? I can't make an example method right now cause I shut down my PC cause I'm going to bed in a few minutes. Edited March 16, 2015 by Rudie Quote Link to comment Share on other sites More sharing options...
Scorncial Posted March 17, 2015 Author Share Posted March 17, 2015 Isn't there a method in the API to select a specific option? I can't make an example method right now cause I shut down my PC cause I'm going to bed in a few minutes. I'm stille getting used to the API, so it's kinda hard to find ... Also, you gold me the coin id, bit how could I find such things myself? Quote Link to comment Share on other sites More sharing options...