Zapping test statement problems...

grazepoop

New member
Is there no way for mafia to tell if you've used your wand yet today?

I'm trying to use visit_url to grab the wand text to see if it's been used once already today.
I don't ever intend to zap more than once, so if I found the string for the first warm message, my script could know to not zap.

My problem, though, is that when I print the output of the visit_url, (to test it,) It seems to be the html for the homepage of kol.

Here's what I've done so far. My wand is a pine wand, so you'd need to change the "1268" to whichever item ID goes with your wand...
 

grazepoop

New member
Thanks! It worked!

Here's the statement that determines if your wand has been used today already. Add whatever you want to an else statement for whatever you want zapped.
 

zarqon

Well-known member
Look what I found!

Here's an old script I wrote (which is somehow still called in all of my daily routine scripts) which will zap something from a prioritized list of items if you haven't zapped yet today. When I wrote this I wanted to zap any tiny plastic item that wasn't a bat, ha.
 

Attachments

  • zapsummat.ash
    1.6 KB · Views: 73

Bale

Minion
That's genius zarqon! Just genius! Adding most of that to my breakfast script! Finally I can do away with a property in my preferences file to tell me when I last zapped!
 
Last edited:

matt.chugg

Moderator
ok as I got bored at home on my day off heres a function I wrote to get the actual wand status as opposed to just a value saying whether its been used or not.

zarquon, I borrowed your for loop to determine if we have a wand and which one, hope you don't mind:

Code:
// -1   No wand found in inventory
//  0   wand hasn't been used at all
//  1   feels warm to the touch (level 1)
//  2   You should probably be careful. (level 2)
//  3   You should definitely be careful. (level 3)
//  4	You should seriously be careful.  (level4)
//  5   should never be seen in visit_url, because I think at this point the wand is gone

int wandstatus() {
	int whichwand=0;
	int retstatus;

  	for i from 1268 to 1272 {
		if (item_amount(to_item(i)) > 0) whichwand = i;
	}
      	
	if (whichwand == 0) {
		retstatus = -1;
	} else {
		// we have a wand so can't be -1 preset to 0 then if its still 0
		// after below checks then it really should be zero.
		// does ash have elseif ?

		retstatus = 0;
		string wanddescription = visit_url("wand.php?whichwand="+whichwand);
		
		if (contains_text(wanddescription, "feels warm")) {
			retstatus = 1;
		} 
		
		if (contains_text(wanddescription, "probably be careful")) {
			retstatus = 2;
		}
		
		if (contains_text(wanddescription, "definitely be careful")) {
			retstatus = 3;
		}

		if (contains_text(wanddescription, "seriously be careful")) {
			retstatus = 4;
		}
	}
	return retstatus;
}

PLEASE NOTE: I haven't managed to fully test it, my wand blew up on second attempt today, so only status -1, 0 and 1 are tested, so beware, I may have typos in the contains_text comparison!
 
Last edited:

zarqon

Well-known member
Matt, I am outraged that you borrowed my for loop, which I clearly trademarked in my above post. I hate other people using my code to improve their knowledge or gameplay experience. As the clear originator of the for loop, I demand compensation for theft of intellectual property. PM me to work out a settlement, otherwise I assure you that you will be hearing from my lawyers.
 

Camber

Member
As the clear originator of the for loop

Wow! Zarqon, you are older than I thought! And still writing excellent code. So that's what the "Senior" member means. The FOR statement was invented in the 1950's I believe?

Matt, there should be some prior knowledge online to debunk his claim. Ha!
 

Veracity

Developer
Staff member
For what it's worth, here's how I would tweak that function. Unlike others, I rather like having more than one exit from a function...

Code:
int wandstatus()
{
  	for i from 1268 to 1272
	{
		if ( item_amount( to_item( i ) ) > 0 )
                {
                        string text = visit_url( "wand.php?whichwand=" + whichwand );

                        if ( contains_text( text, "feels warm" ) )
                                return 1;
		
                        if ( contains_text( text, "probably be careful" ) )
                                return 2;
		
                        if ( contains_text( text, "definitely be careful" ) )
                                return 3;

                        if ( contains_text( text, "seriously be careful" ) )
                                return 4;

                        return 0;
                }
	}

      	return -1;
}
 

matt.chugg

Moderator
Matt, I am outraged that you borrowed my for loop, which I clearly trademarked in my above post. I hate other people using my code to improve their knowledge or gameplay experience. As the clear originator of the for loop, I demand compensation for theft of intellectual property. PM me to work out a settlement, otherwise I assure you that you will be hearing from my lawyers.

After your above statment I decided to consult my own lawyers. They have informed me that as you haven't declared explicit copyright in your post, I am free to use your posting in any way! Furthermore they have deemed your threat of legal action as preposterous and have advised me to contact Adriaan van Wijngaarden's ghost for confirmation on the copyright status of the for loop syntax implmented in Algol68 which according to their sources (I suspect wikipedia) is the first implimentation of a for loop (as opposed to a do loop) .

I hope this resolves the issue, however if you do with to take it further please let me know by PM so I can arrange a seance with Adriaan.
 

matt.chugg

Moderator
For what it's worth, here's how I would tweak that function. Unlike others, I rather like having more than one exit from a function...

Code:
int wandstatus()
{
  	for i from 1268 to 1272
	{
		if ( item_amount( to_item( i ) ) > 0 )
                {
                        string text = visit_url( "wand.php?whichwand=" + whichwand );

                        if ( contains_text( text, "feels warm" ) )
                                return 1;
		
                        if ( contains_text( text, "probably be careful" ) )
                                return 2;
		
                        if ( contains_text( text, "definitely be careful" ) )
                                return 3;

                        if ( contains_text( text, "seriously be careful" ) )
                                return 4;

                        return 0;
                }
	}

      	return -1;
}

thats much tidier! although I see I was using far to many curly parenthesis! That sample actually clears up a few things in my mind too. Does ash only read the following line of code to a conditional statment if there is no {} I've always been putting them in!
 

Veracity

Developer
Staff member
It's perfectly fine to have braces around a single statement. In fact, it makes it easier to add additional statements later, if you want to.

conditionals (if, else) and loops (while, for, foreach, repeat) take a "block". That is either a single statement ending with a semicolon, or any number of statements surrounded by curly braces.
 

zarqon

Well-known member
Matt, you really don't know what you're dealing with here. I've been around for quite a long time, under various pseudonyms. My work on this planet is to develop its technology to the point of publicly available interstellar transportation, and over the centuries that has occasionally necessitated the invention of a control operator or two.

Your research into one of my past aliases verifies rather than debunks my claim. I am satisfied with your giving of credit where it is due and will not be pursuing further action.
 

matt.chugg

Moderator
It's perfectly fine to have braces around a single statement. In fact, it makes it easier to add additional statements later, if you want to.

conditionals (if, else) and loops (while, for, foreach, repeat) take a "block". That is either a single statement ending with a semicolon, or any number of statements surrounded by curly braces.

Thanks, That all makes sense now.
 

matt.chugg

Moderator
Matt, you really don't know what you're dealing with here. I've been around for quite a long time, under various pseudonyms. My work on this planet is to develop its technology to the point of publicly available interstellar transportation, and over the centuries that has occasionally necessitated the invention of a control operator or two.

Your research into one of my past aliases verifies rather than debunks my claim. I am satisfied with your giving of credit where it is due and will not be pursuing further action.

Very well. I thank you for agreeing not persue this matter any further. I will of course be sure to assign credit to you in code comments every time I use a for loop.

I do however feel the need to ask the question: "How long can it take to develop technology to the point of interstellar transportation?" you say you have been around for centuries yet to my knowledge (limited to what is publicly available on the internet) there have been very few if any public interstellar daytrips out side of our own galaxy.
 

Bale

Minion
I do however feel the need to ask the question: "How long can it take to develop technology to the point of interstellar transportation?" you say you have been around for centuries yet to my knowledge (limited to what is publicly available on the internet) there have been very few if any public interstellar daytrips out side of our own galaxy.
It takes a lot less than centuries to simply build the hardware. He's talking about developing a culture's technology which is limited by the speed with which a culture can adopt fresh ideas and accept new paradigms. That can take quite a lot of time and the exact length of time necessary is specific to each species.
 

matt.chugg

Moderator
It takes a lot less than centuries to simply build the hardware. He's talking about developing a culture's technology which is limited by the speed with which a culture can adopt fresh ideas and accept new paradigms. That can take quite a lot of time and the exact length of time necessary is specific to each species.

My sense of humour has failed me, I have no witty retort.

/me looks suitably embarrassed.
 

Bale

Minion
Advancing a planet to the level of interstellar spaceflight is serious business, but you should still never allow your sense of humor to fail you or the human race may never get there. Intelligent species that lose their sense of humor frequently crave extinction after facing the endlessly black bleakness of the universe. In a good way.
 
Top