WARNING!! Serious revamp IS LIVE!!

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

WARNING!! Serious revamp IS LIVE!!

Post by Plazmic » Thu Oct 02, 2003 3:40 am

Status: Code tested, time for everyone else to test it
It's in CVS and the zip. DKAA trumped me on letting people test it first ;)

I'm almost finished with what will probably be the single largest change ever (96k diff).
ALL $l/$v/$p/$t/$a() variables will be REMOVED!
Why you might ask?

They will be replaced with new variables, with REAL names (not #define'd)
Unlimited number of globals, locals, and timers
Multiple arrays of unlimited size, single dimensional or two dimensional
(Also tossed in are unlimited alert lists, but that's beside the point)
Variables will be referenced with the at sign (@) to seperate them from EQ variables
Subroutines will have named parameters (or if unnamed "Param0", "Param1", etc)

Old vars:

Code: Select all

#define AVAR v1
Sub Main
   /varset AVAR $p0
   /echo $AVAR was passed into the macro
   /if "$p1"!="" /echo A second value was passed in too.
/return
New vars:

Code: Select all

Sub Main(FirstArg)
   /declare VarName global
   /varset VarName @FirstArg
   /echo @VarName was passed into the macro
   /if $defined(Param1) /echo A second value was passed in too.
/return
Please give feedback on what you think of this change.
Last edited by Plazmic on Fri Oct 03, 2003 1:57 am, edited 3 times in total.
- Plazmic

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Thu Oct 02, 2003 4:38 am

I've been really wanting something like this for a really long time. Thanks for all the hard work plaz.
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

Random()
a lesser mummy
a lesser mummy
Posts: 38
Joined: Fri Aug 29, 2003 11:31 am

Post by Random() » Thu Oct 02, 2003 6:11 am

Good change, will be nicer to work with. Might want to post simple examples in the Macro:Help forum though before that forum gets turned upside down.

Ohmz
Developer
Developer
Posts: 97
Joined: Tue Feb 04, 2003 12:54 pm

Amazing work

Post by Ohmz » Thu Oct 02, 2003 6:40 am

May god have mercy on SOE...

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Post by Amadeus » Thu Oct 02, 2003 10:34 am

I bet someone could write a script or simple application that could convert old scripts to this new format. Or, at least get close ;)

User avatar
Slice
a hill giant
a hill giant
Posts: 189
Joined: Wed Oct 30, 2002 2:52 pm

Post by Slice » Thu Oct 02, 2003 11:22 am

When this happens I would suggest renaming the Macro Depot to Unconverted Macros (OLD).

Create a new macro depot where the authors can create new threads for the migrated macro and slowly lock the threads in the old folder.

Slice

FlashG
Contributing Member
Contributing Member
Posts: 104
Joined: Thu Jul 11, 2002 6:38 pm

great

Post by FlashG » Thu Oct 02, 2003 12:44 pm

/em bows to the lead deveoper and his minions

The work to convert macros will be worth it. Not to be picky but maybe we can DELARE our varibles and if not declared the interperter flag it as a error. I dont want to say how may times I have /varseted a varible and then missspelled it when I went to use it.

Flash - o fYi inc $

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

convert

Post by grimjack » Thu Oct 02, 2003 1:08 pm

I would like to start converting my bot macro and a few others asap so they are ready when this hits CVS. The only problem I have is not knowing what the exact syntax will be. Will #define still be present for instances where we would like to replace text? And last is there anything I need to know about creating array's. Do I declare them different?

Thanks for your time

GrimJack
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

Zxeses
a ghoul
a ghoul
Posts: 103
Joined: Tue Jan 07, 2003 4:17 pm

Post by Zxeses » Thu Oct 02, 2003 1:16 pm

This change MUST be documented. Please dont commit this to CVS unless the end-users know exactly what we need to do.

Scrime
a ghoul
a ghoul
Posts: 86
Joined: Sun Sep 21, 2003 5:48 pm
Contact:

Post by Scrime » Thu Oct 02, 2003 1:46 pm

Very, very nice Plaz. Looking forward to this change. But as mentioned by a previous poster, please provide some documentation so that we know exactly what we need to do to convert our macros.

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

Post by Plazmic » Thu Oct 02, 2003 1:54 pm

#define isn't being touched (#define MERCHANTNAME "Granger" will still work)

All variables will need to be /declare'd

Code: Select all

Usage: /declare <varname> <global|local|timer|array|array2>
Globals are the old $v#
Locals are the old $l#
Timers are the old $t#
Array is the new single dimensional array
Array2 is the new two dimensional array

Setting values is just like it was before

Code: Select all

/declare MyVar global
/declare MyTimer timer
/varcalc MyVar 100/2
/varset MyTimer 10s
/varsub MyVar 30
Variables are accessed via @<varname>
Variable existance can be checked via $defined(<varname>)

Code: Select all

/if $defined(MyVar)==TRUE /echo My variable is @MyVar
Array usage:

Code: Select all

/declare SmallArray array
/declare TwoDimArray array2
/varset SmallArray(2) 100
/varset TwoDimArray(50,96345) 33
/echo Array test: $calc(@SmallArray(2)/@TwoDimArray(50,96345))
Sub parameters:
For conversions sake, I default unnamed parameters to "Param#" which can be a quick search and replace for all $p# variables

Code: Select all

Old:
Sub Main
   /echo $p0
/return

New:
Sub Main
   /echo @Param0
/return
Parameters can also be named: (This is test.mac in HugeChange.zip)

Code: Select all

#chat tell 
Sub Main(paramBotOwner) 
   /if $defined(paramBotOwner)==FALSE {
      /echo Please pass in the owner's name
      /return
   }
   /declare gBotOwner global 
   /declare gShouldQuit global 
   /declare UselessTimer timer 
   /echo @paramBotOwner
   /varset gBotOwner @paramBotOwner 
   /varset gShouldQuit FALSE 
   /varset UselessTimer 3s 
   /echo My master is @gBotOwner
   :EventLoop 
      /doevents
   /if FALSE==@gShouldQuit  /goto :EventLoop 
/return 

Sub Event_Chat(ChatType,Sender,ChatText) 
   /if @Sender!=@gBotOwner /return 
   /echo @Sender sent me a @ChatType, '@ChatText' 
   /if "@ChatText"=="quit" /varset gShouldQuit TRUE
/return 

Sub Event_Timer(Timer,OriginalValue) 
   | Timer contains the NAME of the Timer variable 
   /echo @Timer went off. 
   /varset @Timer @OriginalValue 
/return
Last edited by Plazmic on Thu Oct 02, 2003 10:58 pm, edited 2 times in total.
- Plazmic

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Thu Oct 02, 2003 2:39 pm

Mail the diff to all the devs so that we can test too.

This is going to cause a lot of squealing from idiots.

Overall, I like this change. I never liked the FORTRAN-like implicit declarations -- too easy to screw up.

Will "/define $p0 @param0" work?

User avatar
Slice
a hill giant
a hill giant
Posts: 189
Joined: Wed Oct 30, 2002 2:52 pm

Post by Slice » Thu Oct 02, 2003 2:46 pm

I would also suggest considering any other retooling that you've thought of doing at the same time. If we're going to go through a period of macro conversion due to language changes, do as much of it at once.

Slice

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

Post by Plazmic » Thu Oct 02, 2003 5:26 pm

dont_know_at_all wrote:Mail the diff to all the devs so that we can test too.

This is going to cause a lot of squealing from idiots.

Overall, I like this change. I never liked the FORTRAN-like implicit declarations -- too easy to screw up.

Will "/define $p0 @param0" work?
I will diff against a specific SRC-xxxx.zip and put it in the downloads directory.

"#define $p0 @Param0" could work for parameters, but you'd still have to modify all the $v/$t/etc, or #define and /declare each one...

Time to test it for the *FIRST* time... It'll either work great, or I'll have a stupid minor bug in a 5th level function that will blow everything up ;)
- Plazmic

User avatar
ap50
a snow griffon
a snow griffon
Posts: 425
Joined: Sun Aug 18, 2002 2:29 pm

Post by ap50 » Thu Oct 02, 2003 6:21 pm

Hold me, I'm scared.
[color=yellow][size=92][b]Just because you're paranoid, it doesn't mean everyone isn't out to get you![/b][/size][/color]