You are not logged in.

Dear visitor, welcome to Runes of Magic US / AU. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Saturday, April 5th 2014, 8:31pm

question about macros in "General"

Hello guys all this time I've been playing I've only had 1 or 2 macros I used. Well now I'm trying to streamline some things, combining using IsShiftKeyDown() My question is how do you add wait times into that line after using IsShiftKeyDown()

Example:

Source code

1
2
/run if IsShiftKeyDown() then CastSpellByName("Savage Power"); wait = .5; CastSpellByName("Power of the Oak"); end
/run if not IsShiftKeyDown() then TargetUnit("player"); end


This works but It does not wait before using the next skill I have to hit the macro again with the shift key down.

basically Im trying to make one macro to perform my offensive buffs then if shift is down perform defensive ones. Would be cool to add something that will check if I have rage too to use rage buffs if I have it.

---- Not related to my question but was wondering about these ---
Also could someone explain what (i=1,10) and what those numbers mean when doing looping macros?

---- One last thing I want to ask again not related to my original question ---
Would it be possible to open up the pet frame with a certain pet already selected. For instance say i have a crow active Have a macro to summon/dismiss it, But wanted to add the IsShiftKeyDown to open up the pet frame with that pet selected to view its details.
~ Jonesy...Shmonesy... I've got an Oak Walker!

This post has been edited 5 times, last edit by "13lack13ox" (Apr 8th 2014, 2:50am) with the following reason: Seems to be no longer about the wait command and more about general macro syntax.


Noguai

Beginner

Posts: 5

Location: Germany

  • Send private message

2

Saturday, April 5th 2014, 9:07pm

The /run command is a macro command that tells the game to execute the following text as plain Lua code. Lua does not know wait / sleep and thus you are not able to use it. Also you cannot write typical macros in your Lua code, because Lua does not understand such macros.

If you want to understand how to write basic Lua code to be able to use it in your macros I recommend you to read some Lua tutorials. The official Lua manual is mainly directed to programmers, so I think http://lua-users.org/wiki/TutorialDirectory is a better choice for you.

About loops:
You cannot do loops with macro commands, which is the reason why people use /run and do the loop in Lua. In your example "i" is the counter variable in your loop. The start value for it is "1" and the end value is "10", the forth parameter of the for-statement is optional and it defines the step size which defaults to "1". http://lua-users.org/wiki/ControlStructureTutorial

About the pet frame:
That's possible, you would have to look up the functions of the gui that do the trick. I have not tested it, but these functions should be the ones you're interested in: (set i to the slot number you like)

Source code

1
2
PetFrame:Show()
PetFrame_SetSelected(i)

3

Saturday, April 5th 2014, 9:11pm

you cannot /wait inside of a /run.

i=1,10 means increment i from 1 to 10. so first i will be one, then 2, then 3 then...10. (im fairly certain it is inclusive on both ends, but plz correct me if i am wrong)

i have no idea about your pet question.
Darwec R/wd/m :DThe Rogue Guide
EOJs Mems and Shells
The continuous cries for "oh, make things harder on people who don't spend real money" is driving this game into the dirt. This game isn't funded by pay to play players. Its funded by the people who go out and farm all your stats and hard mode gear for you to buy.

4

Saturday, April 5th 2014, 9:14pm

Thank you very much, very informative xD.

Thanks again btw =P. So with the pet frame, here is what I came up with. Combined another macro I saw for summoning/dismissing. Added shift key modifier to open petframe with pet selected.

Source code

1
/run if (IsShiftKeyDown() == true) then PetFrame:Show(); PetFrame_SetSelected(3); elseif (IsShiftKeyDown() == false) and (IsPetSummoned(3) == true) then ReturnPet(3); else SummonPet(3); end


Seems to work just fine. :thumbsup:
~ Jonesy...Shmonesy... I've got an Oak Walker!

This post has been edited 1 times, last edit by "13lack13ox" (Apr 6th 2014, 4:51am)


ghostwolf82

Professional

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

5

Sunday, April 6th 2014, 4:28pm

As for using a "wait" in your lua code, you can set up a timer of sorts to keep count and then fire off again after a certain number of seconds have passed, or to loop back to something in the code after X seconds.

AddOn: DIY Combat Engine v2 AddOn: Auto Ding
Reni - Malkira
Warlock Guide
Retired from RoM with patch 6.1.0

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

6

Sunday, April 6th 2014, 5:36pm

Thank you very much, very informative xD.

Thanks again btw =P. So with the pet frame, here is what I came up with. Combined another macro I saw for summoning/dismissing. Added shift key modifier to open petframe with pet selected.

Source code

1
/run if (IsShiftKeyDown() == true) then PetFrame:Show(); PetFrame_SetSelected(3); elseif (IsShiftKeyDown() == false) and (IsPetSummoned(3) == true) then ReturnPet(3); else SummonPet(3); end


Seems to work just fine. :thumbsup:
Thought I'd comment on a couple of things about this macro. There isn't anything wrong with it per-se, just that you can reduce the size and remove a few redundant things.

First, you can remove the == true and the parentheses in the if part since IsShiftKeyDown() returns a true/false value

Source code

1
... if IsShiftKeyDown() then ...


The elseif doesn't need to check IsShiftKeyDown() at all since the only way to get to this part is if IsShiftKeyDown() returned false in the if part in the first place. Further, we can do the same this as above for the call to IsPetSummoned(). So the elseif becomes

Source code

1
... elseif IsPetSummoned(3) then ...


Lastly, Lua doesn't need to have the semi-colons at the end of lines. It just allows it (though you may want to keep them to show where individual commands end).

So with these changes, the macro becomes:

Source code

1
/run if IsShiftKeyDown() then PetFrame:Show() PetFrame_SetSelected(3) elseif IsPetSummoned(3) then ReturnPet(3) else SummonPet(3) end
2013... The year from hell....

7

Sunday, April 6th 2014, 5:51pm

Nice thx, I'm slowly getting my head around all the more advanced things you can do in this game. Also I guess if you have lot's of pets (^.^) you can make it summon 2 different ones.

Source code

1
/run if IsShiftKeyDown() then if IsPetSummoned(3) then ReturnPet(3); else SummonPet(3); end elseif IsPetSummoned(1) then ReturnPet(1); else SummonPet(1); end
~ Jonesy...Shmonesy... I've got an Oak Walker!

This post has been edited 1 times, last edit by "13lack13ox" (Apr 6th 2014, 6:03pm)


Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

8

Sunday, April 6th 2014, 6:47pm

Nice thx, I'm slowly getting my head around all the more advanced things you can do in this game. Also I guess if you have lot's of pets (^.^) you can make it summon 2 different ones.

Source code

1
/run if IsShiftKeyDown() then if IsPetSummoned(3) then ReturnPet(3); else SummonPet(3); end elseif IsPetSummoned(1) then ReturnPet(1); else SummonPet(1); end
You can also check the Ctrl and Alt key with IsCtrlKeyDown() and IsAltKeyDown() for even more options. Can even make a table of pets to summon based on this.

For example, lets do four pets, (this is going to use some funky Lua trickery, see my guide on using Lua logic operators for details on this stuff)

Source code

1
2
/run _pet = 1 + (IsAltKeyDown() and 1 or 0) + (IsCtrlKeyDown() and 2 or 0)
/run if IsShiftKeyDown() then ReturnPet(_pet) else SummonPet(_pet) end

The first line will selects a pet (1 to 4) based on the states of the Alt and Ctrl keys. 1 = no modifiers, 2 = Alt held, 3 = Ctrl held, 4 = Ctrl+Alt
The second line summons or returns the pet based on the state of the Shift key. (obviously, you'd need to know which pet # you have out, but this is just an example after all)

Note, if you go too crazy with this stuff, it becomes easier to just make a custom slash commands. See my macro guide for this last.
2013... The year from hell....

9

Monday, April 7th 2014, 1:04am

Amazing! xD As a Pet-O-Holic I'm gonna enjoy using that one! Very nice! *Saved*

Might have a hand at trying this with mounts, and if shift is down use Galloping Gale and call partner. Though this is a bit more complicated, cus PartnerFrame_CallPartner(2, x) need two variables. but for purposes of mounts it's only really 1 As for the use item if shift+key then call the partner based on which key + shift is used. Well Im wrapping my head around that one for a bit. :dash:

Holy Moly, I think I just now wrapped it! I'll post up a result soon... Eh my test failed.. still trying... :dash:

Well the best I could come up with is this

Source code

1
2
/run _mnt = 1 + (IsAltKeyDown() and 1 or 0) + (IsCtrlKeyDown() and 2 or 0)
/run if IsShiftKeyDown() then UseItemByName("Potion: Galloping Gale") else PartnerFrame_CallPartner(2, _mnt) end


cant use waits inline

Really you did all the hard work and supplied the "trickery" thx again. Will be using for the Greater Good. ^^
~ Jonesy...Shmonesy... I've got an Oak Walker!

This post has been edited 4 times, last edit by "13lack13ox" (Apr 7th 2014, 5:24am)


Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

10

Monday, April 7th 2014, 2:32pm

Amazing! xD As a Pet-O-Holic I'm gonna enjoy using that one! Very nice! *Saved*

Might have a hand at trying this with mounts, and if shift is down use Galloping Gale and call partner. Though this is a bit more complicated, cus PartnerFrame_CallPartner(2, x) need two variables. but for purposes of mounts it's only really 1 As for the use item if shift+key then call the partner based on which key + shift is used. Well Im wrapping my head around that one for a bit. :dash:

Holy Moly, I think I just now wrapped it! I'll post up a result soon... Eh my test failed.. still trying... :dash:

Well the best I could come up with is this

Source code

1
2
/run _mnt = 1 + (IsAltKeyDown() and 1 or 0) + (IsCtrlKeyDown() and 2 or 0)
/run if IsShiftKeyDown() then UseItemByName("Potion: Galloping Gale") else PartnerFrame_CallPartner(2, _mnt) end


cant use waits inline

Really you did all the hard work and supplied the "trickery" thx again. Will be using for the Greater Good. ^^
As it stands, your macro will either use the item if the shift key is held down, or summon a mount if it isn't. Since you mention that you want it to use the item then summon, the if is rather redundant. Instead, you could do something like:

Source code

1
2
3
4
/run _mnt = 1 + (IsAltKeyDown() and 1 or 0) + (IsCtrlKeyDown() and 2 or 0) + (IsShiftKeyDown() and 4 or 0)
/use Potion: Galloping Gale
/wait 0.5
/run PartnerFrame_CallPartner(2, _mnt)

This then selects one of up to 8 mounts (I added the shift key to the mount selection part), uses the potion, waits 0.5 seconds (change to whatever you need), then summons the mount.

Though you can't use /wait in the middle of a Lua line, there is nothing stopping you from using it between /run commands.
2013... The year from hell....

11

Monday, April 7th 2014, 6:42pm

Speechless, just speechless.

Removed my useless nonsense (it's embarrsing!). Thanks again for the links and information! You guys are helpful!
~ Jonesy...Shmonesy... I've got an Oak Walker!

This post has been edited 2 times, last edit by "13lack13ox" (Apr 10th 2014, 1:33am)


Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

12

Tuesday, April 8th 2014, 12:58am

Essentially, the IsAltKeyDown() and 1 or 0 essentially works like and if-else statement. So think of it as if IsAltKeyDown() then 1 else 0 end but it can be used directly in an equation (though you do need the parentheses around the thing).

So

Source code

1
2
3
4
_mnt = 1 +  
  	(either 1 or 0 based on the Alt key state) +
  	(either 2 or 0 based on the Ctrl key state) +
  	(either 4 or 0 based on the Shift key state)

The amount added for each modifier key is just a binary progression (doubles each time).

As to the ins and outs of how that little Lua trick works, see my guide on Lua logic operators.
2013... The year from hell....

13

Tuesday, April 8th 2014, 1:42am

Yeah that's what I was thinking how it was working (or so I thought!).

Removed my useless nonsense (it's embarrsing!). Thanks again for the links and information! You guys are helpful!

I usually just stick to artwork lol. :whistling:
~ Jonesy...Shmonesy... I've got an Oak Walker!

This post has been edited 1 times, last edit by "13lack13ox" (Apr 10th 2014, 1:34am)


14

Tuesday, April 8th 2014, 2:46am

Removed, I feel like I'm making myself look dumber and dumber with every post lol. I'm done messing around with it. Gonna just enjoy the game. xD. Sticking to easy(er) things for a bit.
~ Jonesy...Shmonesy... I've got an Oak Walker!

This post has been edited 6 times, last edit by "13lack13ox" (Apr 8th 2014, 7:51am)


15

Wednesday, April 9th 2014, 1:14am

Basically I was trying to make an optimized version of this...

Source code

1
2
3
/run if IsShiftKeyDown() then CastSpellByName("Summon Spirit of the Oak") elseif IsCtrlKeyDown() then CastSpellByName("Summon Nature Crystal") else CastSpellByName("Summon Oak Walker") end
/wait 2.5
/run TargetUnit("pet") if UnitName("target")=="Nature Crystal" then UsePetAction(5, true) UsePetAction(6, true) else UsePetAction(5, true) end


Removed my useless nonsense (it's embarrsing!). Thanks again for the links and information! You guys are helpful!
~ Jonesy...Shmonesy... I've got an Oak Walker!

This post has been edited 13 times, last edit by "13lack13ox" (Apr 10th 2014, 1:35am)


16

Wednesday, April 9th 2014, 8:20pm

Removed my useless nonsense (it's embarrsing!). Thanks again for the links and information! You guys are helpful!

So sorry for editing all my posts, I kept the good stuff :love: Again please don't mind me I am just trying to get a grasp on all the cool things that are opening up to me. Now that I relapse... (stupid spell checker) REALIZE what all you can achieve with lua in this game. Heading off to learn (HAHA! If that's even possible!) and read all the useful information that was given to me here in this thread. Again thx everyone for helping me get a grasp on the potential of lua. It's amazing!
~ Jonesy...Shmonesy... I've got an Oak Walker!

This post has been edited 1 times, last edit by "13lack13ox" (Apr 10th 2014, 1:42am)


ghostwolf82

Professional

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

17

Thursday, April 10th 2014, 5:39am

Just as a side note here, and not trying to derail anything here, but...

I was not able to see anything you did in this thread before you edited it all to be gone. For me, that might just be horrible. Let me explain, sometimes I will see someones nonsense/rambling/bad code and be able to turn it into something useful. I have done it before, because sometimes what someone might see as embarrassing or useless, might just be the thing that triggers an idea in my mind and I can take a general idea and run with it creating something rather useful out of it all. So to you, and anyone who reads this, please PLEASE don't go erasing the process that took you from point A to point B. That process to people like me is ALWAYS useful to be able to see in its full form. There was a LOT of stuff lost from the forums at one point, and I used to go back and reference old posts full of those kinds of ramblings to create new things from, just look at the original DIYCE thread and you can see how it happened there multiple times for an example (those ramblings led to the creation of DIYCE2 which peryl had a huge hand in developing back in the day with me and a few others, I was just the one who put it all together in an easy to access format :gamer: ).

AddOn: DIY Combat Engine v2 AddOn: Auto Ding
Reni - Malkira
Warlock Guide
Retired from RoM with patch 6.1.0