This may be a dumb question

Need help running MacroQuest2? Ask your questions about how to get things to work on your computer.

Moderator: MacroQuest Developers

NobodyImportant
a lesser mummy
a lesser mummy
Posts: 46
Joined: Sun Nov 02, 2003 8:42 pm

This may be a dumb question

Post by NobodyImportant » Sat Apr 24, 2004 12:06 am

Well, this may be a dumb question, but I cant find the answer, and since I dont know the answer Im not sure what to look for, ok, now for the problem, the idea is to able able to cast any spell VIA chat, this is how the old code looked

Code: Select all


/if "$left(5,"@Param2")"=="buff:" {
  /if "$char(book,"$right($int($strlen("@Param2")-5),"@Param2")")"=="NULL" {
  /1 You ASS, i have no such spell.
  /return
  }
  /target @Param1
  /call cast "$right($int($strlen("@Param2")-5),"@Param2")"
/if "$return"=="CAST_toopower" /1 The spell you want me to cast on the intended Target is to powerful, pick a lower level spell.
/return
}

/if "$left(5,"@Param2")"=="cast:" {
  /if "$char(book,"$right($int($strlen("@Param2")-5),"@Param2")")"=="NULL" {
  /1 You ASS, i have no such spell.
  /return
  }
/targ @Param1
  /assist @Param1
/delay 5
  /call cast "$right($int($strlen("@Param2")-5),"@Param2")"
/if "$return"=="CAST_toopower" /1 The spell you want me to cast on the intended Target is to powerful, pick a lower level spell.
/return
}

I realize its a bit sloppy, and of course it requires editing spellcast.inc a little bit to get the correct $Return, but this code worked successfully with MQ2Parm, now here is the code converted to MQ2Data as best as i could

Code: Select all


/if (${String[@ChatText].Left[5].Equal[buff:]}) {
  /if ("${Me.Book[${String["@ChatText"].Right[${Math.Calc[${String[@ChatText].Length}-5]}]}]}"=="NULL") {
  /1 You ASS, i have no such spell.
  /return
  }
  /target @Sender
  /call cast "${String[@ChatText].Right[${Math.Calc[${String[@ChatText].Length}-5]}]})"
  /if (${Macro.Return.Equal["CAST_toopower"]}) /1 The spell you want me to cast on the intended Target is to powerful, pick a lower level spell.
/return
}

/if (${String[@ChatText].Left[5].Equal[Cast:]}) {
 /if ("${Me.Book[${String[@ChatText].Right[${Math.Calc[${String[@ChatText].Length}-5]}]}]}"=="NULL") {
  /1 You ASS, i have no such spell.
  /return
  }
/targ @Sender
  /assist @Sender
/delay 5
  /call cast "${String[@ChatText].Right[${Math.Calc[${String["@ChatText"].Length}-5]}]})"
  /if (${Macro.Return.Equal[CAST_toopower]}) /1 The spell you want me to cast on the intended Target is to powerful, pick a lower level spell.
/return
}

Now, after i've converted it and realize the problem, i run accross Lax's post here: http://macroquest2.com/phpBB2/viewtopic ... =eventchat

The problem is that CALCULATE can only handle NUMBERS. How do you calculate "gfdlkgjdlfgkldfglkdf" The answer is you dont
So, the ultimate problem is how I get everything out of a String except the 1st 5 characters in a string that has an unspecified number of characters, without using a ${Math.Calc[]}

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Sat Apr 24, 2004 12:15 am

You can actually do it with Mid. Use a number for the length portion that's higher than the actual length, and it will just get you the rest of the string:

${String[@ChatText].Mid[5,9999]}

:)

I can also make members to get all but the left/right n characters
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sat Apr 24, 2004 12:27 am

This should do the trick:

Code: Select all

/if (${String[@ChatText].Left[5].Equal[buff:]}) { 
  /if (!${Me.Book[${String["@ChatText"].Right[${Math.Calc[${String[@ChatText].Length}-5]}]}]}) { 
  /1 You ASS, i have no such spell. 
  /return 
  } 
  /target @Sender 
  /call cast "${String[@ChatText].Right[${Math.Calc[${String[@ChatText].Length}-5]}]}"
  /if (${Macro.Return.Equal["CAST_toopower"]}) /1 The spell you want me to cast on the intended Target is to powerful, pick a lower level spell. 
/return 
} 

/if (${String[@ChatText].Left[5].Equal[Cast:]}) { 
/if (!${Me.Book[${String[@ChatText].Right[${Math.Calc[${String[@ChatText].Length}-5]}]}]}) { 
  /1 You ASS, i have no such spell. 
  /return 
  } 
/target @Sender 
  /assist @Sender 
/delay 5 
  /call cast "${String[@ChatText].Right[${Math.Calc[${String["@ChatText"].Length}-5]}]}" 
  /if (${Macro.Return.Equal[CAST_toopower]}) /1 The spell you want me to cast on the intended Target is to powerful, pick a lower level spell. 
/return 
} 

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Sat Apr 24, 2004 12:33 am

I added functionality to string.Left and string.Right for next zip.

string string.Left[-length]: The left ("all but" length) of the string.. Left[-1] of "Left" will be "Lef"
string string.Right[-length]: The right ("all but" length) of the string.. Right[-1] of "Left" will be "eft"
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sat Apr 24, 2004 12:35 am

Very nice. That will make things alot easier.