Question about looping if multi-using item doesn't make anything interesting.

dibbin

New member
Hi All.

If this has already been addressed, I apologize and will spend the next four days wearing a shirt that says, 'I can haz meat?' :)

Onward..
I have an Ash script that I created to help me test what items are created via multi-use.

For instance, I have around 200 duct tape and i want to see what I can make with them.
I have a loop that tries to use 1, then 2, then 3, etc... but the ASH script seems to abort as soon as multi-using the items doesn't make anything interesting.

Is that an expected behavior or am I just missing something?

I've been coding in ASH for a couple of years now and am a computer programmer by trade so hopefully I'm not just making a noob error.

Here is a rough idea of what Im trying to do just for example. This never makes it past using 1 duct tape because using 1 duct tape doesn't make anything interesting..


int ItemCount;
int i =1;
string ItemName = "duct tape";

ItemCount = item_amount(to_item(ItemName));

while(i<ItemCount && item_amount(to_item(ItemName)) >= i){
use (i, to_item(ItemName));
print("You now have " + item_amount(to_item(ItemName)) + " " + to_item(ItemName) + " remaining.");
i +=1;
}

Thanks for your help!
 

roippi

Developer
If you're using this as a didactic tool for learning ash, that's cool. Otherwise, you know you can just parse concoctions.txt to get the information you want?
 

Theraze

Active member
Depends on if this is designed for trying to find new concoctions or if the goal is to check for existing ones.

Personally, I'm a fan of using crafting_ideas to automatically build them for me, if I have the ingredients anyways... :)
 

dibbin

New member
A little bit of both, Theraze. One of my favorite things about this game is finding new items and concoctions that I didn't know existed and being able to write code to do it is just icing on the cake for me.
 

slyz

Developer
For discovering multi-use recipes, I would use visit_url() and parse the results myself.

If you use use(), you should take into account the fact that, if Mafia doesn't know about the concoction, it won't decrement the number of ItemName from your inventory. It will, however, log the "You Acquire" message, and print info on the new item.

The only way I can see to check whether you acquired a new item would be to check get_inventory().count() after each usage. That would allow you to decrement ItemCount yourself, if a new item is acquired.
 

slyz

Developer
I was thinking of simply checking contains_text( page, "You acquire" ) to see if the multi-use was successful.

I had completely forgotten about extract_items() though, that would make logging the result better.
 

Catch-22

Active member
If the premise is that mafia doesn't know about the concoction then it probably doesn't know about the item, right?

extract_items() probably wouldn't work, in that case.
 

Bale

Minion
If the premise is that mafia doesn't know about the concoction then it probably doesn't know about the item, right?

extract_items() probably wouldn't work, in that case.

Actually, I believe that will teach mafia about the item. I'm not positive though.
 

Theraze

Active member
Only if you know what the item is already, since from the wiki page at least, you're looking for a specific item... or is our wiki wrong? Or am I misreading it? Looks like it's asking for extract_items("text") and looks for that text. Meh, reading comprehension.
 

slyz

Developer
Mafia will learn about the item as soon as you obtain it (probably before you run extract_items()).
 
Top