Page 1 of 1

Aliases and Spells

Posted: 04 Nov 2013 20:42
by Amorana
Hey,

This may just be something to do with how I am creating aliases, but currently the way aliases work is a little troublesome for spell casters, in my opinion. For example if I have a spell called "superawesomeheal" and I alias it through the client to be "heal" = "cast superawesomeheal", when I use the command:

heal eowulthealmostdeadwizard

the alias simply spits out "cast superawesomeheal" and drops eowulthealmostdeadwizard.

This essentially makes it so that through the client I can't alias a spell that I want to be able to cast on someone else. It's able to be worked around right now by just aliasing it in game but not the client, but it seems as though it would be ideal to be able to have all aliasing through the client.

Re: Aliases and Spells

Posted: 04 Nov 2013 22:35
by Eowul
Try 'cast superawesomeheal $*'
Those $<something> get replaced by the arguments passed to your alias.
Where $* returns the text as is, $0 the arguments without quotes, and $1 - $num the specific argument.

Re: Aliases and Spells

Posted: 04 Nov 2013 22:48
by Amorana
Hmm, I assume you mean this would have to be a JS alias then?

Could you give me sort of a written out example to go by (both pattern and return portions), because as I am reading it and putting it in, I am getting errors about expected declarations and what not.

This still gets back to my initial point though - my thought is that we should strive to make "raw command" aliases work as they do in the in-game system. Someone shouldn't have to be a JS wiz to be able to write an alias to cast a spell. Why not do something along the lines of (just as a diagram of sorts, more pseudo code than anything below):

alias {args[]}
{
if args.length == 0
{
send alias
}

if args.length > 0
{
String aliasandargs=alias;
for(i=0; i < args.length; i++)
{
aliasandargs=aliasandargs+args;
}

send aliasandargs;
}
}


Just seems like if we had something similar to the logic above built into the alias section, raw command aliases would work exactly as aliases do in the game code.

Re: Aliases and Spells

Posted: 05 Nov 2013 08:33
by Eowul
While I was apparently wrong about $* (will need to check that), you can do all this without having to make a javascript alias. Just set pattern to 'heal', then using raw commands you can type 'cast superdupaheal $1'

The $1 will be replaced by your first argument. For 'heal eowul', $1 would be replaced by 'eowul'. I see however, that the case where you type no arguments is not covered by that, so that's something that I should address.

Re: Aliases and Spells

Posted: 05 Nov 2013 13:35
by Yanus
.

Re: Aliases and Spells

Posted: 05 Nov 2013 18:06
by Amorana
Yanus wrote:Type: javascript
Body:

Code: Select all

if (args[1] === undefined ) {
  gwc.output.append("  -> Whom you want to heal?  <-");
} else {
  gwc.connection.send("cast whateveryouwish $1",true);
}
There will be a problem with healing unintroduced ones, as they are related to by more than one description. But I didn't want to obfuscate the code.

Close! I have one small edit to what you wrote above for when there is an argument, and then I fixed the first half to make it work the way I'd like it to. See below:

Code: Select all

if (args[1] === undefined ) {
  gwc.connection.send("cast whateryouwish",true);
} else {
  gwc.connection.send("cast whateveryouwish " + $1,true);
}
With the above, you can put in no argument to have the spell that is being cast effect only yourself, and put in a singular argument to have it effect someone else.

Re: Aliases and Spells

Posted: 07 Nov 2013 14:53
by Snowrose
yeah i was trying to figure the client wildcard also

i had an alias comp that was compare first $1 with second $1 then typed comp sword.
i tried %1, $1, $* ect for wildcard.

if it works now ill be thrilled as i dont like messing with java when i dont have to.

Re: Aliases and Spells

Posted: 07 Nov 2013 22:24
by cotillion
Snowrose wrote:yeah i was trying to figure the client wildcard also

i had an alias comp that was compare first $1 with second $1 then typed comp sword.
i tried %1, $1, $* ect for wildcard.

if it works now ill be thrilled as i dont like messing with java when i dont have to.
What you want is something like:
comp $0 with second $0

$0 is the entire argument
It's perfectly fine to use the same substitution several times