Downstairs manor status

Veracity

Developer
Staff member
Here is Bale's 20% cooler version with less memory allocation.

Code:
buffer manor(buffer source)
{
    static string check = "<span style='color:green'>&#"+10003+";</span> ";
    static string batsu = "<span style='color:red'>&#"+10007+";</span> ";
	
    buffer info;

    info.append( "<div style='text-align:center;color:blue;font-family:serif'>" );

    if ( item_amount( $item[spookyraven library key] ) > 0 ) {
	info.append( check );
	info.append( "Library open" );
    } else {
	info.append( batsu );
	info.append( "Library locked" );
    }

    info.append( "<br />" );

    if ( item_amount( $item[spookyraven gallery key] ) > 0 ) {
	info.append( check );
	info.append( "Gallery open" );
    } else if ( to_int( get_property( "lastGalleryUnlock" ) ) == my_ascensions() ) {
	info.append( batsu );
	info.append( "Gallery key available in Conservatory" );
    } else {
	info.append( batsu );
	info.append( "Gallery key requires reading at the Library" );
    }

    info.append( "<br />" );

    if ( !source.contains_text( "manor2.php" ) ) {
	info.append( batsu );
	info.append( "Upstairs closed" );
    } else {
	info.append( check );
	info.append( "Upstairs open" );
    }

    info.append( "</div>" );

    return insert( source, index_of( source, "</table>" ) + 8, info );
}

void main()
{
    write( manor( visit_url() ) );
}
 

Bale

Minion
Neat! How about this?

Code:
void check(buffer a, string b)
{
   static string check = "<span style='color:green'>&#"+10003+";</span> ";
   a.append(check);
   a.append(b);
}

void batsu(buffer a, string b)
{
   static string batsu = "<span style='color:red'>&#"+10007+";</span> ";
   a.append(batsu);
   a.append(b);
}

buffer manor(buffer source)
{
   buffer info;
   info.append( "<div style='text-align:center;color:blue;font-family:serif'>" );

   if ( item_amount( $item[spookyraven library key] ) > 0 )
      info.check( "Library open" );
   else
      info.batsu( "Library locked" );

   info.append( "<br />" );

   if ( item_amount( $item[spookyraven gallery key] ) > 0 )
      info.check( "Gallery open" );
   else if ( to_int( get_property( "lastGalleryUnlock" ) ) == my_ascensions() )
      info.batsu( "Gallery key available in Conservatory" );
   else
      info.batsu( "Gallery key requires reading at the Library" );

   info.append( "<br />" );

   if ( !source.contains_text( "manor2.php" ) )
      info.batsu( "Upstairs closed" );
   else
      info.check( "Upstairs open" );

   info.append( "</div>" );

   return insert( source, index_of( source, "</table>" ) + 8, info );
}

void main()
{
   write( manor( visit_url() ) );
}


BTW, I only added strings to create batsu and check because otherwise the forum software would interpret the html entities... In case anyone didn't know. :) Thanks for making them statics to offset the disability.
 

fronobulax

Developer
Staff member
All you have to do is run bccascend for a bit and then switch to manual to get very confused about manor status. I needed this. Thank you.
 

lostcalpolydude

Developer
Staff member
I updated the first post, incorporating a lot of Bale's stuff. I made the text color change based on meeting the condition or not, along with a check mark or cross.
 

Veracity

Developer
Staff member
Would have been nice if you'd have adopted my efficiency suggestions, too.
But, what do I know? I'm not an ash scripter...
 

lostcalpolydude

Developer
Staff member
I just assumed Bale had incorporated it properly and didn't look too closely when I was making all the other changes. It should be in there now, unless I managed to screw it up.
 

Bale

Minion
Would have been nice if you'd have adopted my efficiency suggestions, too.
But, what do I know? I'm not an ash scripter...

He did. He credited you in the script's comments also. He merely failed to mention it in that post, so stop pouting.

Personally I think my last version is nicer than lost's latest release, but it has definitely become 20% cooler and more efficient than the original. Mostly I'm not fond of the stairway image change instead of merely reporting it. I think that changing the link to non-functional (to prevent accidents) is all the alteration I might have done.
 
Last edited:

lostcalpolydude

Developer
Staff member
I changed the posted version after Veracity's post. She wasn't listed in the comments when she made that post.

I can see how the way you did some things could be preferable, and it's mostly a matter of style. Centered text looked weird to me when things were drastically different lengths.

I intentionally didn't make the staircase unclickable. If mafia or someone's settings get out of synch somehow, I don't want to prevent them from going upstairs, especially since it only costs 4 HP or so if you click there when upstairs isn't open.
 

Bale

Minion
No reason to defend your style. As I said your is definitely 20% cooler than the original. My preference is personal, but that's why I'm glad I know how to modify it for my own taste.


I intentionally didn't make the staircase unclickable. If mafia or someone's settings get out of synch somehow, I don't want to prevent them from going upstairs, especially since it only costs 4 HP or so if you click there when upstairs isn't open.

Tch. Now you're being foolish. Read your own code and you'll see why you are mistaken. It ignores mafia's settings entirely to determine if you can go up stairs and simply looks at the page text to see if it contains manor2.php for the answer.
 

Catch-22

Active member
On the topic of optimizations, there's unnecessary integer conversion and string concatenation going on here:
static string check = "<span style='color:green'>&#"+10003+";</span> ";
static string batsu = "<span style='color:red'>&#"+10007+";</span> ";


This is better:
static string check = "<span style='color:green'>&#10003;</span> ";
static string batsu = "<span style='color:red'>&#10007;</span> ";


and if you really cared about optimization, you could put "<br />" at the end of the conditional appends to save yourself 2 extra calls to append().
Code:
	if ( item_amount( $item[spookyraven library key] ) > 0 )
	{
		info.append( check ).append( "<span style='color:blue'>Library open</span><br />" );
	}
	else
	{
		info.append( batsu ).append( "Library locked<br />" );
	}
 
Last edited:

Bale

Minion
On the topic of optimizations, there's unnecessary integer conversion and string concatenation going on here:
static string check = "<span style='color:green'>&#"+10003+";</span> ";
static string batsu = "<span style='color:red'>&#"+10007+";</span> ";


This is better: (Edit: Can't figure out how to write it without it showing the character entity.)
static string check = "<span style='color:green'>✓</span> ";
static string batsu = "<span style='color:red'>✗</span> ";

That's the reason that I added the unnecessary integer conversion and string concatenation. It isn't in my local copy. Though lost can fix that since it doesn't happen to an attached file.
 

Veracity

Developer
Staff member
I changed the posted version after Veracity's post. She wasn't listed in the comments when she made that post.
Thanks!

When I posted that note, I had just downloaded your updated script to look at it and I was surprised that you'd not used a buffer to concatenate, since that was the important efficiency thing I'd contributed.

As it turns out, my browser had been "nice" to me by not overwriting the script in my download folder, instead naming it "manor-1.ash". So, when I opened "manor.ash", it sure didn't look different, and, rather than investigate farther, I posted my note. Had I looked at the correct file, I wouldn't have said a word; I did not give a damn about "credit", although it was nice of you to add it.

My mistake. Sorry!
 

Bale

Minion
Dunno if someone cares, but here is my final version. I added a couple of interesting enhancements, like adding ballroom status for a full manor readout in a single place. I even found a way to satisfy my desire for centered text while still keeping it left aligned.
 

Attachments

  • manor.ash
    2 KB · Views: 48

lostcalpolydude

Developer
Staff member
I initially wrote this script to save myself some time, and I stopped working on it as soon as it was "good enough". I'm glad I shared it so other people could get something they didn't know they needed, even if the preferred format was created by someone else.

I would almost consider adding this to mafia, but the gallery status being shown when I'm not a muscle class kind of bugs me. It could be hidden when I'm not a muscle class, but then I might want to open it anyway for a bugbear run. But then I might be using a fax and copies to skip the gallery. There's no way I want to figure out the "best" way to push it out to everyone.
 

Theraze

Active member
But if speed ascending, you might not want the continual reminder that an area you don't care about isn't available.

I think this functions very well as a relay script under the control of its users rather than built into mafia itself.
 
Top