Changing Tattoo After Ascending

muffins

Member
I wanted to add this to my current "welcome noob" script.

I would attach it, but, because it seems to be currently broken, I figure it's best to post the code directly.

Here's the idea I had:

Code:
string tattoo_text = visit_url("account_tattoos.php");

if(my_class() == $class[Accordion Thief]) {
	if(contains_text(tattoo_text, "class6hco.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class6hco"); 
	}
	else if(contains_text(tattoo_text, "class6hc.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class6hc"); 
	}
	else {
		visit_url("account_tattoos.php?pwd&newsigil=class6");
	}
}

if(my_class() == $class[Disco Bandit]) {
	if(contains_text(tattoo_text, "class5hco.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class5hco"); 
	}
	else if(contains_text(tattoo_text, "class5hc.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class5hc"); 
	}
	else {
		visit_url("account_tattoos.php?pwd&newsigil=class5");
	}
}

if(my_class() == $class[Pastamancer]) {
	if(contains_text(tattoo_text, "class3hco.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class3hco"); 
	}
	else if(contains_text(tattoo_text, "class3hc.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class3hc"); 
	}
	else {
		visit_url("account_tattoos.php?pwd&newsigil=class3");
	}
}

if(my_class() == $class[Sauceror]) {
	if(contains_text(tattoo_text, "class4hco.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class4hco"); 
	}
	else if(contains_text(tattoo_text, "class4hc.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class4hc"); 
	}
	else {
		visit_url("account_tattoos.php?pwd&newsigil=class4");
	}
}

if(my_class() == $class[Seal Clubber]) {
	if(contains_text(tattoo_text, "class1hco.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class1hco"); 
	}
	else if(contains_text(tattoo_text, "class1hc.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class1hc"); 
	}
	else {
		visit_url("account_tattoos.php?pwd&newsigil=class1");
	}
}

if(my_class() == $class[Turtle Tamer]) {
	if(contains_text(tattoo_text, "class2hco.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class2hco"); 
	}
	else if(contains_text(tattoo_text, "class2hc.gif")) { 
		visit_url("account_tattoos.php?pwd&newsigil=class2hc"); 
	}
	else {
		visit_url("account_tattoos.php?pwd&newsigil=class2");
	}
}

This code would be inserted shortly after the opening of the letter/goodies sack.

Right now, when I try to run it as a separate file, I get

No available namespace with function

As seems to be the norm with all of my posts, I will ask: Is this a bug, or did I screw something up? :D

Thanks in advance guys!

Edited to include HCO tat check for additional e-peen and sad default class tattoo fallback in case I hadn't gotten the HCO/HC class tats yet (and didn't want to use my previous class tat)... though I might change my own version to simply default to the HC 11+... once I actually GET the 11+ tat ;)
 

Nightmist

Member
Hmm I did some debugging (as in ripping bits out of the script until I isolated what I think is the problem) and it turns out my_class() is what is causing it. Broken? (Not too sure since I tested offline so maybe its just screwy with returning $class[none])

Edit: Okay nevermind... weird... this is creepy sometimes it works and othertimes it doesn't...
Oh and its "No available namespace with function <if>", the if doesn't show in the GCLI but you can still see it in the main window. Heh yay for non-parsing of HTML-ish stuff, the <>'s make me think of HTML for some reason... (For me anyway... but im on 9.7)
Edit2: Creepy... I have 2 files which are exactly the same (opened in hex editor and they are literally exactly the same there) but one has the error and the other doesn't...


Edit3: I'm a idiot... .txt and .ash... ZOMG... (So you sure you saved it as a .ash instead of a .txt, heh I had to upload it before I noticed! Uploads removed >>)
 

suraimu

New member
This script works fine for me. Are you sure you're not trying to run this on its own, without putting it into a main() function?
 

Veracity

Developer
Staff member
[quote author=suraimu link=topic=589.msg2842#msg2842 date=1164412048]
This script works fine for me.  Are you sure you're not trying to run this on its own, without putting it into a main() function?[/quote]
I never put a main() function in little stand-alone scripts I write. Global variables didn't used to have their initializers run, but I fixed that a long time ago (like 6 months ago or so), and there should be no functional difference between having code at top level and inside a main().

If this code works for you inside a main() function and not for the original poster at top level, there's a bug.

Edit:

I just ran this as top-level code in a .ash file. ASH reported "script failed" - but it actually worked just fine. It "failed" because the last if statement returned false.

By making it into an if/else if/else if/... chain, I get "Script succeeded" - which is what you'd get if it were inside a void main() function, as well, since the main() wouldn't care what the if() returned. For what's worth, it's also more efficient to make it into the if/else if chain, since you can be in no more than one class...

I don't get the "namespace" error reported by the original poster.

Edit 2:

Here's a simplified version of the same script that works fine for me:

Code:
string [class] classfile;
classfile[ $class[Seal Clubber] ] = "class1";
classfile[ $class[Turtle Tamer] ] = "class2";
classfile[ $class[Pastamancer] ] = "class3";
classfile[ $class[Sauceror] ] = "class4";
classfile[ $class[Disco Bandit] ] = "class5";
classfile[ $class[Accordion Thief] ] = "class6";

string tattoo_text = visit_url("account_tattoos.php");
string name = classfile[ my_class() ];

if ( contains_text( tattoo_text, name + "hco.gif" ) )
   name = name + "hco";
else if ( contains_text(tattoo_text, name + "hc.gif") )
   name = name + "hc";

visit_url( "account_tattoos.php?pwd&newsigil=" + name );

print( "Yowza!");

Without the last line, the gCLI shows the HTML string returned by visit_url(), which is not what you probably want...
 

Nightmist

Member
Hmm well the only way I can get a namespace error is with having it run as a non-ash file (not .ash) but since you say you did have it saved as a .ash then weird...
 

suraimu

New member
[quote author=Veracity link=topic=589.msg2843#msg2843 date=1164424002]
By making it into an if/else if/else if/... chain, I get "Script succeeded" - which is what you'd get if it were inside a void main() function, as well, since the main() wouldn't care what the if() returned. For what's worth, it's also more efficient to make it into the if/else if chain, since you can be in no more than one class...[/quote]

Actually, I do also get "Script failed!" even when it's in a main(). But I digress.
 
Top