For questions regarding conversion of scripts from the old, parm style to the new MQ2Data format. Conversion questions only!
Moderator: MacroQuest Developers
-
Fuergrissa
- a grimling bloodguard

- Posts: 607
- Joined: Mon Dec 08, 2003 3:46 pm
- Location: UK
Post
by Fuergrissa » Thu Apr 29, 2004 5:11 pm
trying to convert my fletch mac, i am either close or i have made a right pigs ear of it.
this is what i have so far, feel free to chastise me where needed.
Code: Select all
|===========================================|
| V1.0 |
|___________________________________________|
|fletch.mac MQ2Data Compliant by Fuergrissa |
|___________________________________________|
#Event SkillUp "You have become better at"
#Event nocomp "You are missing"
#Event SkillTrivial "You can no longer advance your skill from making this item"
#Event FullInventory "There was no place to put that"
#Event SkillFailure "You lacked the skills"
#Event SkillSuccess "You have fashioned the items together to create something new"
Sub Main
/declare SkillFailCounter int global
/declare SkillSuccessCounter int global
/declare SuccessRate int global
/declare TotalAttempts int global
/declare ParseSkillLevel int global
/declare ParseSkill int global
/declare PositionStart int global
/declare PositionEnd int global
/varset SkillFailCounter 0
/varset SkillSuccessCounter 0
/varset SuccessRate 0
/varset TotalAttempts 0
:mainloop
/doevents
/call Combine
/goto :mainloop
/end
Sub Combine
/notify COMBW_CombineArea CombineButton leftmouseup
/delay 2
/if (${Cursor.ID}) /autoinv
/return
Sub DisplayStats
/echo Combine Statistics - Successes: ${SkillSuccessCounter}, Failures: ${SkillFailCounter}
/varcalc ${TotalAttempts} ${SkillFailCounter} + ${SkillSuccessCounter}
/varcalc ${SuccessRate} ${SkillSuccessCounter} / ${TotalAttempts} * 100
/echo Success Rate: ${SuccessRate} % out of ${TotalAttempts} attempts
/return
Sub Event_SkillUp(SkillUpText)
/varset PositionStart ${Math.Calc[${String[@SkillUpText].Find[! (]}+3]}
/varset PositionEnd ${String[@SkillUpText].Find[")"]}
/varset ParseSkillLevel ${String[@SkillUpText].Mid[@PositionStart,${Math.Calc[@PositionEnd-@PositionStart]}]}
/varset PositionStart ${Math.Calc[${String[@SkillUpText].Find[at]}+3]}
/varset PositionEnd ${String[@SkillUpText].Find[!]}
/varset ParseSkill ${String[@SkillUpText].Mid[@PositionStart,${Math.Calc[@PositionEnd-@PositionStart]}]}
/popup "@ParseSkill increased - @ParseSkillLevel ..."
/echo "@ParseSkill increased - @ParseSkillLevel ..."
/return
Sub Event_nocomp
/echo "You have run out of Componants. ((Ending Macro)) "
/popup You have run out of Componants. ((Ending Macro))
/if (${Cursor.ID}) /autoinv
/call DisplayStats
/end
Sub Event_SkillTrivial
/echo "You can no longer advance your skill from making this item. ((Ending Macro))"
/popup You can no longer advance your skill from making this item. ((Ending Macro))
/if (${Cursor.ID}) /autoinv
/call DisplayStats
/end
Sub Event_FullInventory
/echo "Your inventory is full, ((( Ending Macro ))) "
/popup Your inventory is full, ((( Ending Macro )))
/call DisplayStats
/end
Sub Event_SkillFailure
/varcalc SkillFailCounter ${SkillFailCounter}+1
/return
Sub Event_SkillSuccess
/varcalc SkillSuccessCounter ${SkillSuccessCounter}+1
/return
i know im not perfect on success rate but skill up is doing my head in and i have not even started it yet.
Code: Select all
Sub Event_SkillUp(SkillUpText)
/varset PositionStart ${Math.Calc[${String[@SkillUpText].Find[! (]}+3]}
/varset PositionEnd ${String[@SkillUpText].Find[")"]}
/varset ParseSkillLevel ${String[@SkillUpText].Mid[@PositionStart,${Math.Calc[@PositionEnd-@PositionStart]}]}
/varset PositionStart ${Math.Calc[${String[@SkillUpText].Find[at]}+3]}
/varset PositionEnd ${String[@SkillUpText].Find[!]}
/varset ParseSkill ${String[@SkillUpText].Mid[@PositionStart,${Math.Calc[@PositionEnd-@PositionStart]}]}
/popup "@ParseSkill increased - @ParseSkillLevel ..."
/echo "@ParseSkill increased - @ParseSkillLevel ..."
/return
-
s16z
- a ghoul

- Posts: 97
- Joined: Thu Apr 01, 2004 12:03 pm
Post
by s16z » Thu Apr 29, 2004 5:37 pm
Don't /declare those as globals, us 'outer' instead.
In your /varcalc statements, don't enclose the receiving variable in the ${}. Plus MQ2 hates whitespace, not sure if it will cause a problem though.
In Event_SkillUp, SkillUpText *is* a string, no need to convert it to a string just to use string functions.
Change the use of @variable to ${variable} in Event_SkillUp.
Just from visual inspection.
-
MrSmallie
- a hill giant

- Posts: 167
- Joined: Fri Oct 11, 2002 11:18 am
Post
by MrSmallie » Thu Apr 29, 2004 5:37 pm
Lose the @s. Use ${blah} instead. Other then that. Cursory glance looks fine.
Me
[img]http://home.comcast.net/~mrsmallie/ches.JPG[/img]
-
Preocts
- a snow griffon

- Posts: 312
- Joined: Thu Jan 29, 2004 1:02 pm
Post
by Preocts » Thu Apr 29, 2004 7:07 pm
Good job. Quick glance doesn't show any glaring errors. Like mentioned don't use the global scoop if you can help it, no need. Outer should be the highest you go unless your macros are sharing information with other macros or a custom UI.
-
Fuergrissa
- a grimling bloodguard

- Posts: 607
- Joined: Mon Dec 08, 2003 3:46 pm
- Location: UK
Post
by Fuergrissa » Fri Apr 30, 2004 5:02 am
the wife wants to know who is this woman "Brackets", that i keep screaming her name in my sleep.
Any help is allways as usuall appreciated.
here is what i have so far, please be gentle. Lax has chastised me more than enough in this one macro.
Code: Select all
/declare ParseSkillLevel int local
/declare ParseSkill int local
/declare PositionStart int local
/declare PositionEnd int local
/varset PositionStart ${Math.Calc[${SkillUpText}].Find[! (]}+3]}
/varset PositionEnd [${SkillUpText}].Find[")"]}
/varset ParseSkillLevel [${SkillUpText}].Mid[${PositionStart}],${Math.Calc[${PositionEnd}]-[${PositionStart}]}
/varset PositionStart ${Math.Calc[${SkillUpText}].Find[at]}+3]}
/varset PositionEnd [${SkillUpText}].Find[!]}
/varset ParseSkill [${SkillUpText}].Mid[${PositionStart}],${Math.Calc[${PositionEnd}]-[${PositionStart}]}]}
/popup "ParseSkill increased - ${ParseSkillLevel} ..."
/echo "ParseSkill increased - ${ParseSkillLevel} ..."
/return
-
ml2517
- a grimling bloodguard

- Posts: 1216
- Joined: Wed Nov 12, 2003 1:12 am
Post
by ml2517 » Fri Apr 30, 2004 5:15 am
This should be correct, or close (I don't have time to log in and try to get a skill up

):
Code: Select all
Sub Event_SkillUp(SkillUpText)
/declare ParseSkillLevel int local
/declare ParseSkill int local
/declare PositionStart int local
/declare PositionEnd int local
/varset PositionStart ${Math.Calc[${String["${SkillUpText}"].Find["! ("]}+3]}
/varset PositionEnd ${String["${SkillUpText}"].Find[")"]}
/varset ParseSkillLevel ${String[${SkillUpText}].Mid[${Math.Calc[${PositionStart}+1]},${Math.Calc[${PositionEnd}-${PositionStart}]}]}
/varset PositionStart ${Math.Calc[${String["${SkillUpText}"].Find["at"]}+3]}
/varset PositionEnd ${String["${SkillUpText}"].Find["!"]}
/varset ParseSkill ${String["${SkillUpText}"].Mid[${Math.Calc[${PositionStart}+1]},${Math.Calc[${PositionEnd}-${PositionStart}]}]}
/popup ${ParseSkill} increased - ${ParseSkillLevel} ...
/echo ${ParseSkill} increased - ${ParseSkillLevel} ...
/return
-
Fuergrissa
- a grimling bloodguard

- Posts: 607
- Joined: Mon Dec 08, 2003 3:46 pm
- Location: UK
Post
by Fuergrissa » Fri Apr 30, 2004 5:21 am
Thank you ml2517 i will try it later when i get home.
-
Fuergrissa
- a grimling bloodguard

- Posts: 607
- Joined: Mon Dec 08, 2003 3:46 pm
- Location: UK
Post
by Fuergrissa » Fri Apr 30, 2004 5:47 pm
ok no errors but i get this echo when i get an increase.
0 increased - (number-100) ...
ie
0 increased - 57 ...
-
ml2517
- a grimling bloodguard

- Posts: 1216
- Joined: Wed Nov 12, 2003 1:12 am
Post
by ml2517 » Fri Apr 30, 2004 6:08 pm
Ah I see, you had the declare set to int and not string. Try this:
Code: Select all
Sub Event_SkillUp(SkillUpText)
/declare ParseSkillLevel int local
/declare ParseSkill string local
/declare PositionStart int local
/declare PositionEnd int local
/varset PositionStart ${Math.Calc[${String["${SkillUpText}"].Find["! ("]}+3]}
/varset PositionEnd ${String["${SkillUpText}"].Find[")"]}
/varset ParseSkillLevel ${String[${SkillUpText}].Mid[${Math.Calc[${PositionStart}+1]},${Math.Calc[${PositionEnd}-${PositionStart}]}]}
/varset PositionStart ${Math.Calc[${String["${SkillUpText}"].Find["at"]}+3]}
/varset PositionEnd ${String["${SkillUpText}"].Find["!"]}
/varset ParseSkill ${String["${SkillUpText}"].Mid[${Math.Calc[${PositionStart}+1]},${Math.Calc[${PositionEnd}-${PositionStart}]}]}
/popup ${ParseSkill} increased - ${ParseSkillLevel} ...
/echo ${ParseSkill} increased - ${ParseSkillLevel} ...
/return
-
Virtuoso65
- a hill giant

- Posts: 150
- Joined: Wed Oct 15, 2003 2:29 pm
Post
by Virtuoso65 » Fri Apr 30, 2004 7:28 pm
Fuergrissa wrote:
bla bla...
Sub Main
/declare SkillFailCounter int global
/declare SkillSuccessCounter int global
/declare SuccessRate int global
/declare TotalAttempts int global
/declare ParseSkillLevel int global
/declare ParseSkill int global
/declare PositionStart int global
/declare PositionEnd int global
/varset SkillFailCounter 0
/varset SkillSuccessCounter 0
/varset SuccessRate 0
/varset TotalAttempts 0
:mainloop
/doevents
/call Combine
/goto :mainloop
/return
bla bla bla ...
That should help a bit.