bismuth
New member
The import command works wonders in keeping my .ash code from being duplicated, but it raises a new problem: repeated includes (imports)!
Suppose I have one function library for some generic item handling called "func.ash"
now I make some functions for drinking my fill, checking drunkennes, etc. I call it "drinking.ash" and because it handles items it starts with the line:
import <func.ash>;
I also have some functions for eating, found in "eating.ash" these functions also handle items so the file also starts with the same import line.
All is well, code duplication is minimized, whoohoo!
But now I want to make a new script that does all the stuff I do at the start of a day, i.e.:
- Eat
- Drink
- Buff
- maybe plant some mushrooms
- etc.
because I want to eat and drink in these functions I start with:
import <eating.ash>
import <drinking.ash>
and this is where it all falls down, because here kolmafia complains: "function "[first function in func.ash]" already defined at line X in file "func.ash". debug log printed.
Now in C I'd simply wrap all files in an
#ifndef SOME_UNIQUE_NAME
#defint SOME_UNIQUE_NAME
..
file contents
..
#endif
i.e. a conditional import.
Is there an equivalent for .ash files and if so, what is it?
Suppose I have one function library for some generic item handling called "func.ash"
now I make some functions for drinking my fill, checking drunkennes, etc. I call it "drinking.ash" and because it handles items it starts with the line:
import <func.ash>;
I also have some functions for eating, found in "eating.ash" these functions also handle items so the file also starts with the same import line.
All is well, code duplication is minimized, whoohoo!
But now I want to make a new script that does all the stuff I do at the start of a day, i.e.:
- Eat
- Drink
- Buff
- maybe plant some mushrooms
- etc.
because I want to eat and drink in these functions I start with:
import <eating.ash>
import <drinking.ash>
and this is where it all falls down, because here kolmafia complains: "function "[first function in func.ash]" already defined at line X in file "func.ash". debug log printed.
Now in C I'd simply wrap all files in an
#ifndef SOME_UNIQUE_NAME
#defint SOME_UNIQUE_NAME
..
file contents
..
#endif
i.e. a conditional import.
Is there an equivalent for .ash files and if so, what is it?