How do I get the script to ask me for an input?

I've looked at bounty.ash for some inspiration, and have come across this following bit of code. I'm supposing its at least in part responsible for the little popup box that asks you what you want to do. Still very confused. Could someone give me a pointer to a resource or just a pointer in general? Ultimately what I want to do is set up a script that will call other scripts based on what you input into the little box. While not particularly useful, I think it'll be cool and a good learning experience.


Code:
void main(string param) {
   if (count(bounty) == 0) vprint("Bounty hunt already completed today.",-3);
    else if (initiallucre != item_amount($item[filthy lucre])) vprint("You just turned in your bounty.",-3);
    else switch (param) {
      case "list": return;
      case "cancel":
      case "abort": if (count(bounty) == 1 && cancel_bounty()) vprint("Bounty hunt canceled.",2); return;
      case "hard":
      case "best": accept_best_bounty(false); return;
      case "smallest":
      case "small": accept_best_bounty(true); return;
      case "go":
      case "*": if (hunt_bounty()) vprint("Bounty hunt successful.",3);
         else vprint("Bounty hunt failed.",-2); return;
      default: print_html("<b>Usage:</b><p>bounty.ash {go|*}<br>bounty.ash list<br>bounty.ash {best|small|hard}<br>bounty.ash {abort|cancel}");
 
Hmmmmm....


void main(string param)
{
cli_execute( Azazel + azazel.ash);
}

Like that? Seems like it would call different scripts in order... I'm a little confused. Would you mind clarifying?
 

lostcalpolydude

Developer
Staff member
param is the name of the input variable.

void main(string param)
{
cli_execute( param + "blah.ash" );
}

A prompt will come up asking for input. Maybe you type in "taco" as the input. It will fill in "taco" where param is used later, turning it into
cli_execute( "tacoblah.ash" );
 

Ethelred

Member
I get it now. Is it possible to write a code that will type and enter an input for you?

Maybe it's just me being dense, but that question doesn't make a lot of sense to me. If you know what you want entered, why are you asking in the first place? Maybe if you could describe the problem you are trying to solve, it would be easier to help provide a solution.
 
I have a script that calls my diet script, queen cookie script, etc. It also calls bounty.ash, which pops up and asks me how I want to bounty. I just type in "go" every time and "70" for the cookie script. I'd rather not have to type those in...because I'm lazy.
 

Ethelred

Member
I have a script that calls my diet script, queen cookie script, etc. It also calls bounty.ash, which pops up and asks me how I want to bounty. I just type in "go" every time and "70" for the cookie script. I'd rather not have to type those in...because I'm lazy.

Ok, to me it sounds like you want the exact opposite of what you asked for. You want the scripts to not ask you for input. Try posting your script here so we can see what it's doing and how it's structured. If it's an ash script, changing the bounty call to

Code:
bouunty("go");

should do the job. If it's a cli script, I need to see what you're calling. The queen cookie script would be handled in a similar fashion.
 

roippi

Developer
Just type it as an argument after you call the script.

"call foo.ash bar" is the same as "call foo.ash" and then typing bar into the input field.

edit: extremely ninja'd.
 

slyz

Developer
If your script is a CLI script, call bounty.ash like this:
Code:
call bounty.ash go

If your script is an ASH script, call bounty.ash like this:
PHP:
cli_execute( "call bounty.ash go" );

EDIT: not as ninja'd as I was.

EDIT 2:
Code:
bouunty("go");
should do the job.
Nope. In the main() he posted, it looks like hunt_bounty() is called when the parameter is "go" or "*". Calling bounty(go) will call a bounty( string ) function, which probably doesn't exist either in his script or in bounty.ash.
 
Last edited:
Thank you guys, and slyz and roippi got it. I should have clarified my wants, which switched from how do I make a script ask for an input to how do I make a script automatically do the input for me.


Okay uh...yea...last question. This isn't practical, but its for the learning. I'd rather not have to remember the name of each script, so how could I have the script call my castefarming script when I type in "Farm the castle" or have it call my diet script when I type in "Eat"? I already have a login script that does this for me, but it would be nice to have a central control per seay when it comes to doing mundane not-daily tasks. It would be more efficient than searching through the preposterous amount of scripts that make up my folder.
 

Bale

Minion
I'd rather not have to remember the name of each scrip

Just select the script from the drop-down menu at the top of the mafia window. If you don't like that option, then change the name of the script to whatever you actually can remember. It will work just fine under a different name as long as there isn't another script that imports it for some reason.
 

Bale

Minion
You lost me. How to do what? Are you actually asking how to rename a script? Just... change the name of the file. The method will differ based on whether you use a mac, windows or linux. What is it you don't understand. Exactly.
 
Here's what I want to do:

I want to write a script that will, when ran, pop up a prompt into which I type something. I want specific phrases to correspond with different scripts. Simple as that.

Why? I just want to know how. I don't want an alternative.
 

lostcalpolydude

Developer
Staff member
Code:
if ( param == "thing1" )
{
	cli_execute("call script1");
	cli_execute("call otherscript2");
}
else if ( param = "thing2" )
{
	cli_execute("call script3");
	cli_execute("call yetanotherscript");
}

Hopefully that's useful.
 
Last edited:
Top