Choice selection help

GODdamnNOOB

New member
Hi there, I'm new to the whole writing scripts stuff and would like some guidance on some of the problems I'm facing.

Let's say adventuring somewhere gets me into a choice. How do i write a function which reads and returns what text is on each button?
Also after the selection, how do I get my script to select the choice I have decided on?

I'm currently using notepad++, is there a better IDE to write in which I can set to maybe change the colour of the function texts and stuff?

Thanks in advance.
 

Theraze

Active member
1) Generally you just know which choice you're on. I suppose you could parse the choice from visit_url.
2) The run_choice command will click the button for you, usually. Unless it's a get request rather than a post, in which case you'll probably want to look at some of the witchess scripts.
3) I suggest adding the ASH language to Notepad++ to add the highlighting. Ultimately it's a matter of personal preference.
 

GODdamnNOOB

New member
I see, thanks for clearing up some of the confusion.

I've tried reading through some other people's scripts to try and maybe learn some stuff, but I am getting confused over some parts. For example, the script for auto-ing the LTT telegrams. There are some variables like questLTTQuestByWire and lttQuestStageCount, are these variables only created when you install the script, or already there originally? If they are originally inside the settings prefs, how do I go about discovering how each var corresponds to each adv choice or location.

Also I'm confused, what does string[string] do? I've read the wiki but cant really understand what it means.

Hopefully I can clear up some of my confusion and start understand how to write some scripts
 

heeheehee

Developer
Staff member
I've tried reading through some other people's scripts to try and maybe learn some stuff, but I am getting confused over some parts. For example, the script for auto-ing the LTT telegrams. There are some variables like questLTTQuestByWire and lttQuestStageCount, are these variables only created when you install the script, or already there originally? If they are originally inside the settings prefs, how do I go about discovering how each var corresponds to each adv choice or location.
get_property(string pref) returns the value of that preference.
set_property(string pref, string val) sets that preference.

Some preferences are handled automatically by Mafia. Usually you can try to guess what the preference is called, then filter through the preferences via prefref, or you can just look for a script that does something similar. (or just look at the relevant changelogs)

Choice adventure preferences are of the form choiceAdventureX, where X is simply the choice adventure number as KoL knows it (there are a number of ways to find this).

Also I'm confused, what does string[string] do? I've read the wiki but cant really understand what it means.
That's a map. Maps associate keys with values; you can think of them as generalized lookup tables.
 

Theraze

Active member
Sorry, an addendum to my earlier entry. Working on choice adventure names, you could parse the noncombat queue to see if it's the expected adventure you were waiting for. I believe that the first adventure (0) in the queue is the newest, but here are the oldest and newest both.
> ash my_location().noncombat_queue.split_string(";")[my_location().noncombat_queue.split_string(";").count()-1]

Returned: Another Errand I Mean Quest

> ash my_location().noncombat_queue.split_string(";")[0]

Returned: Last Egg Gets Al
You could throw the choice adventure name into a switch to pick what to do when, or... whatever.
 

GODdamnNOOB

New member
Hmm Sorry for the late reply, had to head out of state for some stuff.

Thank you for enlightening me on regarding the functions and preferences.

I think I should have grasped most of the issues when it comes to choice selection, But somehow I'm facing a little problem scripting my GAP pants activation.
I've tried this:
visit_url("choice.php?whichchoice=508&option=2&pwd="+my_hash())
but somehow its still not letting me cast the GAP pants. I've checked that I am wearing the GAP and that I still have available skill casts from it.
The wiki says that the choice adv for the GAP is 508, after checking everything through, I have no idea on what I'm doing wrong.
 

theo1001

Member
GAP pants are an item, right?

Have you tried using them first?

Something like:
Code:
use(1, $item[GAP pants]);
run_choice(2);
 
Last edited:

heeheehee

Developer
Staff member
Code:
> help greatest

gap [skill|structure|vision|speed|accuracy] - get a Greatest American Pants buff.
> ashq cli_execute("gap vision");
 
Top