How to use an alias within an alias?

Zyro

Member
I have an alias called 'inferno' that goes to the volcano and chooses the -1 drunkenness option. I want to put this alias inside of another one called 'consume' that does my daily consumptions, but it gives an error saying that it doesn't recognize the command. It actually used to work in the past, but at some point that changed. Here is what the two commands look like:

Code:
inferno => outfit inferno; ashq visit_url("place.php?whichplace=airport_hot&action=airport4_zone1"); visit_url("choice.php?whichchoice=1090&option=5")

consume => use milk o; eat 3 spooky hi; cast 2 ode; drink 6 perf dark; [B]inferno[/B]; drink 2 cold one; chew 3 powdered gold; use mojo f; chew powdered g

Any help is much appreciated
 

xKiv

Active member
You might want to use scripts instead. Just
1) place files named "inferno" and "consume" anywhere in mafias scripts/ folder (they can be in a subfolder, I do that for all my private scripts)
2) place the commands you had in those aliases into the appropriate script files (you can even place one per line!)
3) remove the aliases

This will also decouple your code from mafia, so you have even lower chance of it getting corrupted when mafia gets corrupted.


(I might remember wrong, but aliases *might* have been made to not work in places other than start of line, for safety reasons)
 

heeheehee

Developer
Staff member
(I might remember wrong, but aliases *might* have been made to not work in places other than start of line, for safety reasons)
The code (persistence/Aliases.java) seems to agree with you. I didn't look at the blame, so I can't verify the reasoning.

Also, it is possible to do this via cli_execute shenanigans, but I agree with xKiv that you're probably better suited just writing a script and/or composing them.
Code:
 > alias bar => echo 1
String successfully aliased.
bar => echo 1

 > alias foo => echo 2; cli_execute bar
String successfully aliased.
foo => echo 2; cli_execute bar

 > foo
2
1

I absolutely do not endorse writing code in this fashion...
 

lostcalpolydude

Developer
Staff member
Hmm, I don't remember any change to make aliases only work at the start of the line. I do remember a bug report from maybe a year ago that was actually due to an alias the user had forgotten.

To ensure that an alias will only run at the start of the line, you can do
Code:
alias bar %% => whatever here

That's obviously the opposite of what the thread asked for, but I would agree that all that code probably belongs in a script instead.
 

heeheehee

Developer
Staff member
Hmm, I don't remember any change to make aliases only work at the start of the line. I do remember a bug report from maybe a year ago that was actually due to an alias the user had forgotten.

Ah, right you are. I'd only skimmed the code briefly. It looks like the root cause is that we only resolve one layer of aliases via the invocation to Aliases.apply in KoLmafiaCLI.java.
 
Top