Automated Clan Smiles

Enameless

New member
This is my attempt to make my casting of my smiles on my clan easy. This script uses gift shop items to keep track of what day it's on and casts my 5 smiles on the 5 members for that day. This current incarnation of code does currently get the job done but has a few obvious flaws. My main questions are is there a better way to keep track of what day it is and it there a better way to stop the script other then the abort command?
Code:
//Automated Clan Smiles
//written by Enameless

if ( item_amount( $item[potted cactus] ) = 1 )
{
	cli_execute
	{
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		sell potted cactus
		buy stuffed can of asparagus
		abort End Round 1
	}
}

if ( item_amount( $item[stuffed can of asparagus] ) = 1 )
{
	cli_execute
	{
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		sell stuffed can of asparagus
		buy mugcake
		abort End Round 2
	}
}

if ( item_amount( $item[mugcake] ) = 1 )
{

	

	cli_execute
	{
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		sell mugcake
		buy white balloon
		abort End Round 3
	}
}

if ( item_amount( $item[white balloon] ) = 1 )
{


	cli_execute
	{
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on PlayerName
		cast 1 smile on PlayerName
		cast 1 smile on PlayerName
		sell white balloon
		buy potted cactus
		abort End Round 4
	}
}
 

izchak

Member
Try using some else ifs instead of aborting.
Code:
//Automated Clan Smiles
//written by Enameless

if ( item_amount( $item[potted cactus] ) = 1 )
{
	cli_execute
	{
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		sell potted cactus
		buy stuffed can of asparagus
		print End Round 3
	}
} 

else if ( item_amount( $item[stuffed can of asparagus] ) = 1 )
{
	cli_execute
	{
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		sell stuffed can of asparagus
		buy mugcake
		print End Round 3
	}
}

else if ( item_amount( $item[mugcake] ) = 1 )
{

	

	cli_execute
	{
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on playername
		sell mugcake
		buy white balloon
		print End Round 3
	}
}

else if ( item_amount( $item[white balloon] ) = 1 )
{


	cli_execute
	{
		cast 1 smile on playername
		cast 1 smile on playername
		cast 1 smile on PlayerName
		cast 1 smile on PlayerName
		cast 1 smile on PlayerName
		sell white balloon
		buy potted cactus
		print End Round 4
	}
}
else
{
	print("no smiles were used today!")
}


... Else ifs work in CLI scripts, right?
 

MagiNinjA

New member
Whew. Wow. That was a mess. I tried basically putting what I attached into a code tagged block, but that really messed things up.

Anyways, I'll explain it. And it's really late for me, but I should manage. :p

This is a little special thing mac and I essentially brewed up a while back (well, all this is my code, but our ideas were exactly the same)

The main idea here is to use mafia's property feature, set_property and get_property. Basically, I set a daily marker to a setting which can be checked later on.

void dailyTaskComplete(string property);
This gets your marker for property, whatever you like to name it. "clanSmileBuff" or whatever. This does not count repeatable actions like lucre. An example use of this is to check whether you got your Rumpus Room stuff today or something. If I remember correctly, Smiles are daily and not repeatable upon ascension. If I'm wrong, well then.

void dailyAscensionTaskComplete(string property);
This is the same as above except that it counts ascension as making it repeatable. PvP and lucre would use this feature.

string todayValue();
This returns today's marker value, not counting ascension. This is what is compared later.

string todayAscensionValue();
Same idea as above except repeating on ascension.

boolean isTaskDone(string property);
This gives your if statement you've been looking for. This will return true if you've done your thing already. So yeah, false means DO IT, true means NO DON'T DO IT ZOMG.

boolean isAscensionTaskDone(string property);
Same thing as above but for ascension things.

:)

Whew. @_@
 

Attachments

  • daily_check_library.ash
    1.6 KB · Views: 90

macman104

Member
MN, if you are checking an account that has not ascended some of their strings are different. I didn't check your script cause I'm in class, so I don't have time right now, but if you have a character who hasn't ascended you might want to check that out.
 

MagiNinjA

New member
Oooh, good catch. I missed that.

Here's an updated version that'll work now. :)

Man, I'm really off my game. >.>

There were several more errors and turns out I phail at substring.

But things should be fixed now!

In any case, I wanted to get some tips on this...

Is this good programming practice? Really, the only thing that changed between the 4 checks was which string to check for, so I could've made another function that simply did all of the repeatable stuff in another function, but I feel like that's not the best practice for the most compatible library. In like, you can copy and paste the function(s) you want from it and not have your script throw errors, whereas with using another function, you'll have to take that function with it, and really, that function's pretty useless EXCEPT for that one task. Unless you made it take more parameters like which page to parse and so on. Ramble ramble. I've written something like that though. Hm. But ideally, all you would need to do is import a library to use it. >.<

Anyways, yes, sorry for making so many mistakes the first time. >.<

EDIT: Took out my main method I used to test it.
 

Attachments

  • daily_check_library.ash
    2.3 KB · Views: 98
Top