variable usage

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

Moderator: Moderators

Message
Author
kamirie
Plain Yogurt
Plain Yogurt
Posts: 96
Joined: 22 Jul 2009, 23:19
Noob?: Yes

variable usage

#1 Post by kamirie »

Good Day, I want to make a macro that will use @rand as variable assignments. How can I properly construct this?

The bot will try to detect a player within 6 cells , and if someone comes in within 6 cells , it will trigger the macro and the bot will execute the seq in which chosen by @rand .

Code: Select all

automacro check {
player (.*) 6
call mymacro
}

macro mymacro {
@rand (1,4)
$var = @rand
if (($var == 1) call seq1 1 { )
if (($var == 2) call seq2 1 { )
if (($var == 3) call seq3 1 { )
if (($var == 4) call seq4 1 { )
}

macro seq1 {
do blah blah 
do put command here
}

macro seq2 {
do blah blah 
do put command here
}

macro seq3 {
do blah blah 
do put command here
}

macro seq4 {
do blah blah 
do put command here
}



User avatar
fadreus
The Kore Devil
The Kore Devil
Posts: 708
Joined: 17 Nov 2017, 23:32
Noob?: No
Location: Genting Highland, Malaysia
Contact:

Re: variable usage

#2 Post by fadreus »

kamirie wrote:

Code: Select all

if (($var == 1) call seq1 1 { )
if (($var == 2) call seq2 1 { )
if (($var == 3) call seq3 1 { )
if (($var == 4) call seq4 1 { )
Why you put '{' then ')' ?
Where the closing?

Image

Try or should be like this:

Code: Select all


macro mymacro {
@rand (1,4)
$var = @rand
if (($var == 1) call seq1 1 || ($var == 2) call seq2 1 || ($var == 3) call seq3 1 || ($var == 4) call seq4 1)
}


iRO Supporter.
Read before you ask is the wisest thing human can do.
Unless you're a cat.
Image

kamirie
Plain Yogurt
Plain Yogurt
Posts: 96
Joined: 22 Jul 2009, 23:19
Noob?: Yes

Re: variable usage

#3 Post by kamirie »

I will try this thanks

kamirie
Plain Yogurt
Plain Yogurt
Posts: 96
Joined: 22 Jul 2009, 23:19
Noob?: Yes

Re: variable usage

#4 Post by kamirie »

Can I do this ?

I'm playing in a pk server and I use this bot to cast skills . So if a player comes near my bot or tries to kill me , my bot will transfer to a different savepoint ( the new sp will depend on the result of the @rand ) , save in the kafra then continue what it's supposed to do.

Code: Select all

if (($var == 1) call seq1 1 { set $var1 == town0 } )
if (($var == 2) call seq2 1 { set $var1 == town1 } )
if (($var == 3) call seq3 1 { set $var1 == town2 } )
if (($var == 4) call seq4 1 { set $var1 == town3 } )
then in another automacro I will use $var1 . I read that all variables are global .

Code: Select all

automacro sp {
run-once 1
map $var1 {
do conf lockMap $var1
do move --to kafra coordinate
do talk --to kafra to save
release all
}
}

User avatar
fadreus
The Kore Devil
The Kore Devil
Posts: 708
Joined: 17 Nov 2017, 23:32
Noob?: No
Location: Genting Highland, Malaysia
Contact:

Re: variable usage

#5 Post by fadreus »

Why not make it more simple?

Like

When attacked > @warp $random
Then change lockMap as $random.
Automacro to trigger when at certain map >macro to save point.


Example:

Code: Select all

automacro Attacked {
	console /oh no im attacked or what ever it is>
	run-once 1
	call {
		$random = <ur maps
		do warp $random
		release all
	}
}

automacro map1 {
	location
	run-once 1
	call {
		do go save or whate ver you want
	}
}

<some more maps you wnat just like above

I'm myself don't write fancy code or complex stuff. I like it simple 8-)

iRO Supporter.
Read before you ask is the wisest thing human can do.
Unless you're a cat.
Image

kamirie
Plain Yogurt
Plain Yogurt
Posts: 96
Joined: 22 Jul 2009, 23:19
Noob?: Yes

Re: variable usage

#6 Post by kamirie »

fadreus wrote:Why not make it more simple?

Like

When attacked > @warp $random
Then change lockMap as $random.
Automacro to trigger when at certain map >macro to save point.


Example:

Code: Select all

automacro Attacked {
	console /oh no im attacked or what ever it is>
	run-once 1
	call {
		$random = <ur maps
		do warp $random
		release all
	}
}

automacro map1 {
	location
	run-once 1
	call {
		do go save or whate ver you want
	}
}

<some more maps you wnat just like above

I'm myself don't write fancy code or complex stuff. I like it simple 8-)
I will try this thanks

User avatar
SkylorD
Moderators
Moderators
Posts: 1166
Joined: 16 Dec 2011, 02:53
Noob?: No
Location: Brazil
Contact:

Re: variable usage

#7 Post by SkylorD »

Code: Select all

console /oh no im attacked or what ever it is>
Take a look at the LAST forward slash.

Correct is :

Code: Select all

console /oh no im attacked or what ever it is/
Learn rules

User avatar
fadreus
The Kore Devil
The Kore Devil
Posts: 708
Joined: 17 Nov 2017, 23:32
Noob?: No
Location: Genting Highland, Malaysia
Contact:

Re: variable usage

#8 Post by fadreus »

That one typo. xD
Comment made in hurry..

Ma bad..

iRO Supporter.
Read before you ask is the wisest thing human can do.
Unless you're a cat.
Image

User avatar
SkylorD
Moderators
Moderators
Posts: 1166
Joined: 16 Dec 2011, 02:53
Noob?: No
Location: Brazil
Contact:

Re: variable usage

#9 Post by SkylorD »

fadreus wrote:That one typo. xD
Comment made in hurry..

Ma bad..
u are a god! more power to u
Learn rules

kamirie
Plain Yogurt
Plain Yogurt
Posts: 96
Joined: 22 Jul 2009, 23:19
Noob?: Yes

Re: variable usage

#10 Post by kamirie »

I forgot , I need to use If statements because I need to do manual npc talk steps to save to the kafra of the new random map. I'm planning to also use inns as save points so I need IF statements to direct a sequence to a correct macro for steps.

Post Reply