Jump to content

setting up cli parameters


Lewis
 Share

Recommended Posts

Hey, im looking to add cli parameters to my script.

im looking for it to withdraw items that are on the cli parameters

such as:

test:log,apple,mind rune

You get the script parameters string using the getParameters() method in the Script class

String parameters = getParameters();
Edited by Explv
Link to comment
Share on other sites

do it? :???:

 

on a more serious note i'm guessing you are looking to find out how to do it? Should probably include a question then :)

        public String getParameterString(int i) {
		String[] parameters = getParameters().split("-");
		return parameters[i].replace("_", " ");
	}

	public int getParameterInteger(int i) {
		String[] parameters = getParameters().split("-");
		return Integer.parseInt(parameters[i]);
	}

Example usage:


-script AIOGodwarsDungeon:bandons-brews-1000
Link to comment
Share on other sites

i thought the thread being in script help would be pretty self explanatory

 

also, what would i add to say, banking method

 

such as: withdraw parameter 1

 

You can withdraw items from the bank using:

getBank().withdraw(String itemName, int amount);

Consider reading the API documentation: http://osbot.org/api/org/osbot/rs07/api/Bank.html#withdraw-java.lang.String-int-

Edited by Explv
Link to comment
Share on other sites

i want to withdraw using parameters lol, i know how to withdraw normally lol

 

such as

bank.withdrawAll(PARAMETER_1);

bank.withdrawAll(PARAMETER_2);

 

I have shown you how to get the parameters String, parse the information you need from that String using whatever format you want.

 

If you don't know what to do after that, I would recommend that you spend some more time learning Java, because this isn't really a scripting help question, it's just basic programming.

Link to comment
Share on other sites

I have shown you how to get the parameters String, parse the information you need from that String using whatever format you want.

 

If you don't know what to do after that, I would recommend that you spend some more time learning Java, because this isn't really a scripting help question, it's just basic programming.

im sure this a help section for a reason lol

Link to comment
Share on other sites

im sure this a help section for a reason lol

 

Yes and I have helped you, this is the scripting help section, not the teaching basics of Java section

 

You get the parameters String using:

String parameters = getParameters();

Parse the information you need from the String, store the results.

 

Then when you want to withdraw from the bank you use

getBank().withdraw(String itemName, int amount);

Using your stored information.

 

I am not going to write down every line of code to do that, because you should be able to do it if you have basic knowledge of Java. Which is why I am recommending, that if you DONT know how to do that, then you should learn some more Java then come back to Scripting.

Edited by Explv
Link to comment
Share on other sites

I have shown you how to get the parameters String, parse the information you need from that String using whatever format you want.

 

If you don't know what to do after that, I would recommend that you spend some more time learning Java, because this isn't really a scripting help question, it's just basic programming.

feel free to link me the appropriate info. Ive been googling it for the past 3 hours

Link to comment
Share on other sites

Yes and I have helped you, this is the scripting help section, not the teaching basics of Java section

 

 

I am not going to write down every line of code to do that, because you should be able to do it if you have basic knowledge of Java. Which is why I am recommending, that if you DONT know how to do that, then you should learn some more Java then come back to Scripting.

 

no need to be a douche about it?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...