Is there a way to use a variable to add an entire line of code? I don't want it to do something like "use(1, variable)", but I was hoping to do something such as "while (complicatedVariable)". Is this even possible?
I wrote a bunch of auto-adventuring scripts for myself. Right now I'm trying to make the code simpler... or at least make the scripts shorter.
The main thing I am looking at is how I set up the script to handle adventuring. Here's an example:
The thing I am trying to shorten is everything after "while". I have 7+ lines every time I need to adventure somewhere. There has to be a way to handle this repetitive function, other than to write it every time I need to adventure...
The thing I'm looking at right now is to make a map (for some reason, maps just started to click with me, and only now am I starting to use them). Here's what I have so far (not tested yet):
In the regular scripts:
and in a new script/function, the following code:
Nice and relatively simple. In the scripts I have now, I would reduce those 7+ lines down to 4+ lines, and have a function written only once to handle all my adventuring! And there was much rejoicing.
Except... The problem that I'm having is when I'm adventuring in areas for reasons other than to get items. Granted, the times that it happens is few and far between, but I would still like for my new adventuring logic to handle it. For example, in the beginning of the game when I'm adventuring in the haunted pantry to unlock spookyraven manor, my "goal" is:
I don't know how to translate that for a function that has it's goals set with variables. Is there a way to make something like this work?:
I wrote a bunch of auto-adventuring scripts for myself. Right now I'm trying to make the code simpler... or at least make the scripts shorter.
The main thing I am looking at is how I set up the script to handle adventuring. Here's an example:
PHP:
nextMonster = $monster[Hellion] ;
nextLocation = $location[Dark Neck of the Woods] ;
while (available_amount($item[dodecagram]) < 1)
{
if (my_adventures() == 0)
abort ("ran out of adventures") ;
if (have_effect($effect[on the trail]) < 1 )
use_familiar(stasisFam) ;
else if (my_mp() < my_maxmp()*.5)
use_familiar(stasisFam) ;
else (use_familiar(itemFam) ) ;
adventure(1, nextLocation);
}
The thing I am trying to shorten is everything after "while". I have 7+ lines every time I need to adventure somewhere. There has to be a way to handle this repetitive function, other than to write it every time I need to adventure...
The thing I'm looking at right now is to make a map (for some reason, maps just started to click with me, and only now am I starting to use them). Here's what I have so far (not tested yet):
In the regular scripts:
PHP:
nextMonster = $monster[Hellion] ;
nextLocation = $location[Dark Neck of the Woods] ;
int [item] itemgoals ;
itemgoals $item[dodecagram] = 1
and in a new script/function, the following code:
PHP:
foreach item in itemGoals
while (available_amount(goals[item]) < goals[int])
{
if (my_adventures() == 0)
abort ("ran out of adventures") ;
if ((nextLocation == $location[dark neck of the woods] || nextLocation == $location[pandamonium slums]) && my_maxmp() > 39 ) //etc
if (have_effect($effect[on the trail]) < 1 )
use_familiar(stasisFam) ;
if (my_mp() < my_maxmp()*.5)
use_familiar(stasisFam) ;
else if (wantMoreItems == True)
use_familiar(itemFam) ;
else
use_familiar (statFam) ;
adventure(1, nextLocation);
}
clear itemGoals ;
Nice and relatively simple. In the scripts I have now, I would reduce those 7+ lines down to 4+ lines, and have a function written only once to handle all my adventuring! And there was much rejoicing.
Except... The problem that I'm having is when I'm adventuring in areas for reasons other than to get items. Granted, the times that it happens is few and far between, but I would still like for my new adventuring logic to handle it. For example, in the beginning of the game when I'm adventuring in the haunted pantry to unlock spookyraven manor, my "goal" is:
PHP:
while (contains_text(visit_url("town_right.php"), "Haunted Pantry") )
I don't know how to translate that for a function that has it's goals set with variables. Is there a way to make something like this work?:
PHP:
string complicatedGoal = "contains_text(visit_url(\"town_right.php\"), \"Haunted Pantry\") "
while (complicatedGoal)
Last edited: