Checking Beach access?

I'm looking for a way to check access to the Desert Beach in ASH. ashref doesn't seem to give me a handy function, although I may have missed something, so I've attempted to write my own.

There are two situations where you have access to the Beach: you have a meatcar, or you've completed the meatcar quest. (Or both, but, y'know...)

Code:
boolean gotBeach()
{
  # Perhaps you have a meatcar?
  if (item_amount($item["bitchin' meatcar"]) > 0)
    return true;
		
  # Or have finished the meatcar quest?
  if ((visit_url("questlog.php?which=2")).contains_text("My Other Car Is Made of Meat"))
    return true;
    
  return false;
}

This definitely works if you've finished the quest; I've got no meatcar-only characters to test on, but I see no reason it shouldn't work there too.

Questions:
1. Have I missed some built-in or simpler way to do this? I can code, but ASH and KolMafia are fairly new to me.

2. If you try to go to the beach without having the quest completed, and without the meatcar, but with all the meatcar parts (i.e. creatable_amount() == 1), does Mafia auto-make the meatcar?

2a. If not, should I just use retrieve_item() instead, to make the meatcar if you can? Are there ever reasons you have the parts and want to get to the beach, but don't want to make the car? It seems unlikely.

3. This function as written hits the quest log every time you call it if you haven't got a meat car. Very Bad Thing, especially since it's unnecessary. Ideally, once it found that the quest had been completed, it would set some boolean ("beach") to true and add an if(beach) return true; to the start of the function. This variable would ideally persist across multiple runnings of the script (although I suppose one page hit per script call wouldn't be too bad) -- would a zlib variable be appropriate? It looks like updatevars() might have to be used to update the value from the script in that case.
 
This requires a server hit every call as well, but it's another option:

if(contains_text(visit_url("main.php"),"map7beach.gif")) return true;
 

mredge73

Member
You may want to try canadv.ash to see how Z does it. I think he hits the server with a visit_url as already mentioned though.

This is how I unlock the shore in my HC inventory control script (consider this pseudo code, it is not a standalone function):
Code:
string BuildMeatCar()
{
    if(QuestStatus["meat car"]==1 && haveItem($item[Degrassi Knoll shopping list]) && creatable_amount($item[bitchin' meatcar])>0)
    {
        print("Creating Bitchin' Meatcar...", "blue");
        create(1,$item[bitchin' meatcar]);
        use(1,$item[Degrassi Knoll shopping list]);
        print("Unlocking Shore...","blue");
        visit_url("guild.php?place=paco");
        print("Untinkering Meat Car...","blue");
        cli_execute("untinker bitchin' meat car");
        return "Built Meat Car, Unlocked Shore, and untinkered Bitchin Meat Car! <br />";
    }
    return "";
}
The shopping list is removed from inventory if you use it while having the meatcar inventory. If you can assume that you used your shopping list and you unlocked the beach while you had your meatcar in inventory, then you could possibly test for having the shopping list in your inventory. But, these are probably too many assumptions if you don't use a script to build your meatcar.

Here is one more suggestion that may help:
Code:
boolean gotBeach()
{

// You havn't built the meatcar yet
if(item_amount($item[Degrassi Knoll shopping list])>0)
use($item[Degrassi Knoll shopping list]);
if(item_amount($item[Degrassi Knoll shopping list])>0)
return false;

  # Perhaps you have a meatcar?
  if (item_amount($item["bitchin' meatcar"]) > 0)
    return true;
        
  # Or have finished the meatcar quest?
  if ((visit_url("questlog.php?which=2")).contains_text("My Other Car Is Made of Meat"))
    return true;
    
  return false;
}
 
Last edited:
Or, heck, I can just import canadv and use it to check South of the Border or something.

That way Zarqon deals with the page hits! And very nicely, too, with an unlockedLocations property to do just the "stop hitting pages once it's unlocked" deal I wanted. It says it right up there at the top of the script... "I did the work so you don't have to."
 
And it is very nice. For one thing, it taught me that ASH has switch statements.

/me narrows eyes at the wiki's "Control Structures" page.
 
Top