Inline ASH?

heeheehee

Developer
Staff member
So I've been attempting to experiment with this function, and either I'm using it completely wrong, or something else. I dunno.

Basically, I've been trying the following just as a test (entering it into the gCLI):
<inline-ash-script> print("Test."); </inline-ash-script>
But it's been giving me "Unexpected error, debug log printed. Unterminated inline ASH script."

Any idea why I'm getting this result? (If my syntax is totally wrong, I apologize in advance.)
 

Bale

Minion
I don't think that will work in the gCLI, only in a CLI script.

To use ash on the command line, you need to preface it with the word ash.

ash print("Test.");
 

jasonharper

Developer
Anything on the line after "<inline-ash-script>" is ignored, and "</inline-ash-script>" has to be an entire line by itself (it can't even have leading or trailing spaces). It won't work from the CLI, anyway, since the entire body of the ASH script is immediately read, there's no provision for waiting for additional lines to be typed.
 

heeheehee

Developer
Staff member
Would generating a CLI script using ASH, say, using "<inline-ash-script> \n print("Test."); \n </inline-ash-script>" work, then? (I'm really clueless when it comes to CLI-scripting.) Or would there be any way to do something of this sort?

Alternatively: I know of the ash function, but is there a way to terminate it (i.e. return to inputting CLI), aside from adding in a cli_execute(string)?
 

Bale

Minion
Why do you need to do that? If you explained your need, perhaps someone could help by explaining a better way to service your problem.

Anyway, once you type ash on a line, the only way to insert CLI is with cli_execute, but that is basically never useful since ash functions exist for (almost) all CLI commands.
 

heeheehee

Developer
Staff member
[[Exposition]]
I've been attempting to make an addon to aqualectrix's PriceAdvisor, and the whole negative number thing just doesn't really work when creating or acquiring items. Since PA's outputs are meant to be CLI-executable, and CLI doesn't have an equivalent of the item_amount(item) function, I hit a snag when trying to throw ASH in the middle of a CLI script.
[[/Exposition]]

So yeah, that's that.
 

Bale

Minion
Well, CLI does have something similar to item_amount(). It has * which means all, or else you can use a negative number which means all except for that number. Generally one of those will do the job.
 

heeheehee

Developer
Staff member
Mmft, yeah, I know about the negative numbers (and *, which is functionally identical to 0, which I've been using), and I've been able to get it to work for autoselling/mallselling/smashing items, but it gets a bit glitchy for making/acquiring items.

Basically, on execution, it converts the current number of an item to part of the string. What I want is to subtract that current number from the amount acquired of a different but somewhat related item. For instance, PA suggests the following for a spooky nugget:
acquire 1 linoleum sword; make 1 shuddersword; mallsell 1 shuddersword

I want to take the exact number of spooky nuggets I'd wind up with, say, from smashing 20 lupine swords, and use that to replace every instance of "1" in the string. I have an idea as to how this would work in ASH, but I'm completely lost as to how to get this into a CLI-executable form. [[Basically: use string concatenation such that
string str = "item_amount($item[spooky nuggets]) - " + item_amount($item[spooky nuggets]); would obtain this number, which I'd use at a later time. The problem with tossing in an ash in front of this is that I can't just go right back to CLI-style input when it's time to move on to the next command. I guess it'd all be so much nicer if it were presented in ASH form, but then it wouldn't really be consistent with the rest of PA. It'd probably also break the script.
 
Last edited:

jasonharper

Developer
<inline-ash-script> is definitely not going to do anything useful in a cli_execute()...

The following might do the job:
ash cli_execute("acquire 1 linoleum sword; make 1 shuddersword; mallsell 1 shuddersword".replace_string(" 1 ", " "+(item_amount($item[spooky nuggets])-5)+" "))
...where that '5' at the end was the amount of spooky nuggets at the time you generated the command, prior to the pulverize.
 

heeheehee

Developer
Staff member
Sorry if I'm being a pain, but I thought of this, and the problem that I saw was that if I wanted to chain additional commands to the end of this, there's no way to get back to just plain CLI.

I suppose I could just do nested ash/cli_execute() commands, and have a counter going (so that I know how many cli_executes to close at the end of the command).

Basically, what I'm saying: ash cli_execute("[insert command here] ash cli_execute("... ad infinitum. The counter would be used in a foreach loop to add a ") to close each cli_execute. I just didn't want to do this unless necessary, but I guess it can't be avoided.

Thanks for the help!
 
Top