INI to Chat mac

shadewalker

Lifetimer
Joined
Feb 13, 2007
Messages
407
Reaction score
0
Points
16
For whoever was asking about it in the chatbox. Will go through the specified section of Strats.ini, and spew all the lines to /rsay. Valid syntax is this:
Code:
/mac Strats.mac UberStrat

Here's Strats.mac:
Code:
Sub Main
 /declare x int 1
 :loop
 /delay 2s
 /if (${Ini[Strats.ini,${Param0},${x}].Equal[NULL]}) /return
 /rsay ${Ini[Strat.ini,${Param0},${x}]}
 /varcalc x ${x}+1
/goto :loop

And Strats.ini:
Code:
[UberStrat]
1=Everybody STFU and listen!
2=Mob casts AoE Stupidity, so watch it
3=If you get hit with stupidity, the wizzies will TL you home.
4=When he hits 80%, he spawns 6 LeetHaxxorz. They all cast a10000 point DD every -2 seconds.
5=If you die, dont complain, or we WILL bind you immeadiately following rez.
6=Also, I get all the phat lootz

All untested, but I'm 99% sure it will work.
 
Tried this out and just changed rsay to say. All it did was kept saying NULL in a never ending loop. I believe that it does not like using 1 as a variable so not finding that object. Is there a way to get around that?
 
Oh... it's a typo error. I misnamed the INI in the /rsay line from Strats to Strat. That's why it was spitting out NULLs. Corrected code is:
Code:
Sub Main
 /declare x int 1
 :loop
 /delay 2s
 /if (${Ini[Strats.ini,${Param0},${x}].Equal[NULL]}) /return
 /rsay ${Ini[Strats.ini,${Param0},${x}]}
 /varcalc x ${x}+1
/goto :loop
 
How do you make it stop once it has said all the tells? It tells all the strats then continues to tell NULL. I mean other then /mac stop. Is there a way for the macro to stop in the code? I thought that is what the /return was doing
 
So did I. I don't know why it's not. I'm logging on in a sec, so I'll try to figure it out. Here's another attempt at it, just add Lines=6 to that INI section.
Code:
Sub Main
 /declare x int
 /for x 1 to ${Ini[Strats.ini,${Param0},Lines]}
  /rsay ${Ini[Strats.ini,${Param0},${x}]}
  /delay 2s
 /next x
/return
 
You can do something like this to make the linecount dynamic (ie. so you don't have to manually define how many lines are in a section).

Tested and working

Code:
Sub Main(string Strategy)
    | The inifile used to store the strategies...
    /declare INIFile string local Strategies.ini

    | Check if a strategy was actually requested...
    /if (!${Defined[Strategy]}) {
        /echo Error!
        /echo No strategy was requested...
        /echo Usage: /macro ${Macro.Name} "strategy wanted"
        /echo Replace "strategy wanted" with the name of the strategy you wish played back.
        /endmacro
    }

    | Check if the requested strategy actually exists...
    /if (${Ini[${INIFile}, ${Strategy}].Equal[NULL]}) {
        /echo Error!
        /echo The requested strategy wasn't found...
        /echo Usage: /macro ${Macro.Name} "strategy wanted"
        /echo Replace "strategy wanted" with the name of the strategy you wish played back.
        /endmacro
    }

    | Figure out how many lines there are by reading all keys/lines in the requested section/strategy
    /declare Keys string local ${Ini[${INIFile}, ${Strategy}]}
    :TrimKeys
        /if (${Keys.Right[1].Equal[|]}) /varset Keys ${Keys.Left[${Math.Calc[${Keys.Length}-1]}]}
    /if (${Keys.Right[1].Equal[|]}) /goto :TrimKeys

    | Spit out the lines from the requested section
    /declare i int local
    /for i 1 to ${Math.Calc[${Keys.Count[|]}+1]}
        /rsay ${Ini[${INIFile}, ${Strategy}, ${Keys.Arg[${i},|]}]}
    /next i
/return
 

Attachments

  • strat.mac
    1.2 KB · Views: 5