Clickable CLI links ?

AlbinoRhino

Active member
Maybe some person cleverer than I has solved this before...

Is there any way to print a clickable link in the CLI which, when clicked, will issue a mafia command without the link being opened in the browser ?
 

Bale

Minion
zarqon did it

It works better than you'd have hoped for. When you click the link, the command (or other words of your choice) appear floating over the cursor for a second and then fade away. A very nice indication to the user that the clicking did something. The words are green if it worked or red if there's an error. Great, eh?
 
Last edited:

AlbinoRhino

Active member
That will work in the CLI somehow ? I actually wrote some javascript for adding links for mafia commands, in the browser, long before I even learned any ASH...so I don't need zarqon's script even for its stated use. So, unless I am not seeing something, this doesn't answer my question. But thanks for the response.
 
Last edited:

Bale

Minion
Oh. I misunderstood. I thought you just wanted links to run in the cli. I didn't realize you wanted them to display in the cli also.

I didn't notice which user was asking the question or else I'd have known you couldn't have missed something so obvious. (Sometimes I miss the name when there's no avatar.) Sorry about that.

I have no idea how to help you.
 

AlbinoRhino

Active member
Yea. You can add sideCommand links to the CLI and they will work fine to issue the command but they also automatically open a browser window. Maybe my question wasn't clear enough.

You CAN build an appropriate string of the script-generated commands, and then use the scriptList or dailyDeedsOptions properties to create clickable buttons for issuing the commands. Since the script list and deeds panel are re-drawn on a change to the prop without needing to log in/out, it can be handy. But I have yet to find a way to just make a link in the CLI to accomplish the same. (If using dailyDeedsOptions, beware of commas, ASH requires them in some functions, but apparently only text deeds will allow them when you add a | after? Luckily there are CLI commands that perform the same for most ASH.)
 

Pazleysox

Member
Since this forum title contains the question I have, I'll just add my question here.

I'm working on a rollover script that I found some time ago which was originally written by Bumcheekascend, then updated by others, and updated again by me.

I continuously forget to use my deck of cards, which is something the script checks for. I added the link to the wiki page to my script.

Code:
print("Link here: http://kol.coldfront.net/thekolwiki/index.php/Deck_of_Every_Card_(Effects_Table) ", "green");	}

is there a way to make the link something I can click and have a window open up on that page?
 

AlbinoRhino

Active member
PHP:
print_html("Link here: <a href=\"http://kol.coldfront.net/thekolwiki/index.php/Deck_of_Every_Card_(Effects_Table)\">Deck effects</a>");
 

Pazleysox

Member
Next question:

I found this script somewhere (I don't remember where), so it's been mostly written by others, and updated by someone else, then updated again by me.

There's a bunch of checks in the script already , but I want to add a new check, and don't know where to get the information from.

PHP:
	if(get_property("_witchessBuff") == "false")
	{	print("You can still get your Witchess Puzzle Buff", "red");	}
	if(contains_text(body,"telescope")&&!to_boolean(get_property("telescopeLookedHigh"))) 
	{	print("You can still use your telescope buff today", "red");	}
	if(contains_text(body,"_free.gif"))
        {	print("You haven't used all of your free disco rests", "red");	}

I just pulled a few random checks from the script, the above commands do work, and there is a visit_url in place to point the script in the correct direction to find these items. (written by others)

I wanted to put in a check for "License to Chill", I understand what the commands are doing, and HOW they work, but don't know how, or where to find the information on how to check if the license has been used, or not used.
 

AlbinoRhino

Active member
Next question:

I found this script somewhere (I don't remember where), so it's been mostly written by others, and updated by someone else, then updated again by me.

There's a bunch of checks in the script already , but I want to add a new check, and don't know where to get the information from.

PHP:
    if(get_property("_witchessBuff") == "false")
    {    print("You can still get your Witchess Puzzle Buff", "red");    }
    if(contains_text(body,"telescope")&&!to_boolean(get_property("telescopeLookedHigh"))) 
    {    print("You can still use your telescope buff today", "red");    }
    if(contains_text(body,"_free.gif"))
        {    print("You haven't used all of your free disco rests", "red");    }

I just pulled a few random checks from the script, the above commands do work, and there is a visit_url in place to point the script in the correct direction to find these items. (written by others)

I wanted to put in a check for "License to Chill", I understand what the commands are doing, and HOW they work, but don't know how, or where to find the information on how to check if the license has been used, or not used.


PHP:
if ( !get_property("_licenseToChillUsed").to_boolean() ) { ??? }

I suspect that many of the checks in that old script can be replaced by checks of mafia properties rather than visiting pages and looking for text. Most once per day activities have an associated mafia property that can be checked like the above. To find the property name you want, use the "prefref" command in the CLI. For instance, "prefref chill".
 

Pazleysox

Member
PHP:
if ( !get_property("_licenseToChillUsed").to_boolean() ) { ??? }

I suspect that many of the checks in that old script can be replaced by checks of mafia properties rather than visiting pages and looking for text. Most once per day activities have an associated mafia property that can be checked like the above. To find the property name you want, use the "prefref" command in the CLI. For instance, "prefref chill".

Looking at the script, this is correct. I was testing out my new found knowledge of the PREFREF today, and it's very useful! Is there a BIG advantage to updating the whole script from this:
PHP:
	string body = visit_url("clan_viplounge.php?action=pooltable");
	if(is_unrestricted("pool table") && contains_text(body,"You approach the pool table")&&!contains_text(body,"quite a bit")) 
	{	print_html("You can still <font color=FF0000>Play Pool</font> today");	}
to this:
PHP:
	if ( get_property ("_poolGames") <= 2 )
	{	print_html("You can still <font color=FF0000>Play Pool</font> today");	}

I'm going to update the script to the new way regardless, because I like it, and I need something to do (lol), but I'm thirsty for knowledge.

Also, I'm trying to figure out how to do a check for clovers.

Here's how the script does it now. I've been looking at the prefref command for clovers, before and after the hermit has been visited...

PHP:
	string body = visit_url("/hermit.php");
	
	if(contains_text(body,"left in stock")) {
		print_html("You can still get <font color=FF0000>Clovers</font> from the Hermit today");
	}
 

Darzil

Developer
The BIG advantage is that you get the result without requesting a server update, so fewer hits against KoL and faster speed.

The disadvantage is it would potentially get out of sync with KoL and be wrong (though that'd usually be a mafia bug to be reported or because you visited outside mafia or with a text changing effect active).
 

AlbinoRhino

Active member
I think you'll have to stick with the page visit to check the hermit. Even if mafia collects them all during breakfast, it is possible that a hermit script has been used afterward and there is another clover available at the end of the day.

Also, get_property() returns a string. To compare against an int you would want to use:

if ( get_property ("_poolGames").to_int() <= 2 )

or

if ( to_int(get_property ("_poolGames")) <= 2 )

whichever you prefer.
 

Pazleysox

Member
Also, get_property() returns a string. To compare against an int you would want to use:

if ( get_property ("_poolGames").to_int() <= 2 )

or

if ( to_int(get_property ("_poolGames")) <= 2 )

whichever you prefer.

I coded the
if ( get_property ("_poolGames").to_int() <= 2 ) with, and without the .to_int(), and I get the same results either way. Is this supposed to happen? What is the down side of not using the .to_int()? :confused:
EDIT: It seems that the .to_init() only works when a number is returned...

Also, I'm trying to figure out a way to see if the spacegate has been used yet or not. I'm running into a ton of trouble getting it coded properly.

Here's a few things I've tried:
PHP:
	if (get_property("spacegatehazards").to_int == "toxic atmosphere" || get_property("spacegatehazards") == "high gravity" || get_property("spacegatehazards") == "magnetic storms" || get_property("spacegatehazards") == "irradiated" || get_property("spacegatehazards") == "high winds")
	{ print("spacegate open"); }

	if (get_property("spacegatehazards") == "toxic atmosphere")
	{ print("spacegate open"); }
	if (get_property("spacegatehazards").to_int == "toxic atmosphere")
	{ print("spacegate open"); }
	if (get_property("spacegatehazards") == "")
	{ print("spacegate not open"); } //this worked...  wait a second!  I think I have it now!
ok. Typing this all out lead me to this:
PHP:
	if (get_property("_spacegateHazards") == "") 
	{	print ("your space gate is not open");	}
	else if (get_property("_spacegateTurnsLeft") >= 20)
	{	print ("your space gate is open, and you have turns left");	}
Which seems to have worked, though my gate is open.

EDIT2: It seems mafia does track turns, but only after the terminal's URL has been accessed. I know how I can work with this now.
 
Last edited:

Pazleysox

Member
How can I pull the information from a get_property, and then display it in a print("");?

IE:
else if (get_property("_spacegateTurnsLeft") >= 20)
{ print ("your space gate is open, and you have " + spacegateTurnsLeft + " turns left"); }
 
Top