[guide/help] Macro usefulls

All about the macro plugin can be found in this forum. This forum is intended for the macro plugin only.

Moderator: Moderators

Message
Author
Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

[guide/help] Macro usefulls

#1 Post by Mortimal »

EVAL usefulls

1. Get Char Position

Code: Select all

$x = @eval($::char->{pos}{x})
$y = @eval($::char->{pos}{y})
$x, $y - numbers

2.a. Check if line is Snipable

Code: Select all

$i = @eval (Misc::checkLineSnipable ({x => <your x position>, y => <your y position>}, {x => <target x>, y => <target y>}))
$i - bool

2.b. Check if line is Walkable(have no obstacles)

Code: Select all

$i = @eval (Misc::checkLineWalkable ({x => <your x position>, y => <your y position>}, {x => <target x>, y => <target y>},0))
$i - bool

3. Check if cell is Walkable (and castable)

Code: Select all

$i = @eval($::field->isWalkable(<any x>, <any y>))
$i - bool

4. Get Level of specific Skill

Code: Select all

$i = @eval($::char->getSkillLevel(new Skill(handle => '<skill handle from skillnametable.txt>')))
Image
$i - Skill Level

5. Text to number "array"

Code: Select all

$i = @eval({"<text1>" => <num1>, "<text2>" => <num2>, ..., "<textN>" => <numN>}->{"<textX>"})
$i - number
Example

Code: Select all

$i = @eval({"one" => 1, "two" => 2, "three" => 3}->{"two"})
log $i
result - 2

6. Get Char Stat

Code: Select all

$i = $::char->{<str/agi/dex/int/luc>}
$i - number

7. Check if quest is active

Code: Select all

$i = @eval ($::questList->{'<quest name>'}->{'active'} == 0)
$i - bool
by Tesla27

REGEXP usefulls

1. Not, inside the regexp

Code: Select all

/(?!<not this>)<but this>/
Example:

Code: Select all

console /^(?!You)(.+) finalized the Deal/
Line: "You finalized the deal" - not triggering!
Line: "Player Somebody finalized the deal" - triggering!



That's all for now. To be continued...

P.S.: U can post your usefulls lower and i will put them in head of the topic.
Last edited by Mortimal on 07 Feb 2017, 06:32, edited 5 times in total.
Please use pin function for uploading your file contents!

Dark Airnel
Been there done that!
Been there done that!
Posts: 133
Joined: 09 Oct 2009, 01:43
Noob?: No

Re: [guide/help] Macro usefulls

#2 Post by Dark Airnel »

Let's say I want to list all coordinates or blocks between a linesnipeable coordinate how would I do that in a macro. Would it need a sub-macro? Let's say $myx, $myy and $aggrePx, $aggrePy is my coordinate and my enemies coordinate respectively. Provided the coords are found to be snipeable and walkable, how will I calculate through macro the the exact coord where I will be X steps from $aggrePx, $aggrePy. I tried using Utils::moveAlong but it gives me a fixed result of 2/8. The code looks similar to this:

Code: Select all

eval (@eval (Utils::moveAlong ($myPos, $hisPos, $somedist))
That kind of formula always produces 2/8 instead of a coordinate. Am i doing something wrong or is moveAlong not intended for such task?

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: [guide/help] Macro usefulls

#3 Post by EternalHarvest »

Utils::moveAlong returns a list, which would be stringifyed by macro plugin's @eval (due to macro plugin's internals). Log the result of @eval and check the string format, or use something like this to retrieve coords inside @eval:

Code: Select all

@eval({moveAlong(...)}->{x})

mjbm
Noob
Noob
Posts: 1
Joined: 06 Jun 2011, 07:51
Noob?: Yes

Re: [guide/help] Macro usefulls

#4 Post by mjbm »

help for the eval of getting the specific weight of an item.

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: [guide/help] Macro usefulls

#5 Post by EternalHarvest »

mjbm wrote:help for the eval of getting the specific weight of an item.
Server doesn't send that info, and there's no such data in openkore so far too.

Dark Airnel
Been there done that!
Been there done that!
Posts: 133
Joined: 09 Oct 2009, 01:43
Noob?: No

Re: [guide/help] Macro usefulls

#6 Post by Dark Airnel »

Mortimal wrote:EVAL usefulls

1. Get Char Position

Code: Select all

$x = @eval($::char->{pos}{x})
$y = @eval($::char->{pos}{y})
$x, $y - numbers
I tried getting the direction where I am facing using the same syntax and the code below does the trick:

Code: Select all

$bdir = @eval($::char->{look}{body})
What if I want to check for the same information from a player how will I do that? I'm thinking of a code that looks like this:
This is to get the direction a certain player is facing or maybe your current target be it a monster or a player.

Code: Select all

$playerbdir = @eval($::player->{look}{body})
The above code does not work by the way. Please help me on how to check for player's information using @eval.

Hope I'm making sense.

pokamon2
Noob
Noob
Posts: 5
Joined: 30 Oct 2008, 00:58
Noob?: Yes

Re: [guide/help] Macro usefulls

#7 Post by pokamon2 »

good day, i dont know where to place my question in the forums,

where can i find the functions or keywords to where i can hook plugins::register? i want to learn about scripting with perl. or if there is a list that exist.

or is there a perl documentation of openkore that i can read/use? thank you.


or are some of the keywords that i need are in the Globals.pm? to make my own plugin.

bluemachinery
Noob
Noob
Posts: 1
Joined: 11 May 2013, 04:20
Noob?: Yes

Re: [guide/help] Macro usefulls

#8 Post by bluemachinery »

Hi, Need help.

So here is the thing I wanted to do,

So I am done with my quest and I need to log-in a different account so all in all quest has been done and it would be the relog time already.

I just don't get how the loop works, it was given to me before by ezza but it was gone because of the wipe-out of the whole forum and all and I lost it in my files.

So if someone can help me i'd appreciate it, all I need is the loop.

for example:

config.txt is done with quest needs to switch to config2.txt and up to config60.txt and once I get to config60.txt it will switch back to config.txt to form the loop. Hope you can help me.

kejiaweiren
Noob
Noob
Posts: 8
Joined: 01 Jun 2013, 10:01
Noob?: No

Re: [guide/help] Macro usefulls

#9 Post by kejiaweiren »

thank you ,good job
but i also have some questions
for example ,can i get the number of my agi status or other status?
if can ,how?

Dark Airnel
Been there done that!
Been there done that!
Posts: 133
Joined: 09 Oct 2009, 01:43
Noob?: No

Re: [guide/help] Macro usefulls

#10 Post by Dark Airnel »

Dark Airnel wrote:
Mortimal wrote:EVAL usefulls

1. Get Char Position

Code: Select all

$x = @eval($::char->{pos}{x})
$y = @eval($::char->{pos}{y})
$x, $y - numbers
I tried getting the direction where I am facing using the same syntax and the code below does the trick:

Code: Select all

$bdir = @eval($::char->{look}{body})
What if I want to check for the same information from a player how will I do that? I'm thinking of a code that looks like this:
This is to get the direction a certain player is facing or maybe your current target be it a monster or a player.

Code: Select all

$playerbdir = @eval($::player->{look}{body})
The above code does not work by the way. Please help me on how to check for player's information using @eval.

Hope I'm making sense.
It's because Kore doesn't know which player you are referring to.

Post Reply