Page 1 of 1
Passing argument type to subroutrine
Posted: Sun May 24, 2015 6:15 pm
by Steveiwonder
Hiya,
I'm having some problems passing particular object types to subroutines.
I've got the following
Code: Select all
Sub Test(obj)
/echo ${obj.ID}
/return
I'm basically trying to pass a "spawn" to the routine but i think tostring is being called on the object before it gets passed in. I looked a the documentation and see you can delcare the var type like
I have tried
but not getting anywhere, is it even possible to do something like this?
Code: Select all
Sub Main
/call Test ${Target}
/return
Sub Test(obj)
/target id ${obj.ID} // No such 'string' member 'ID'
/return
Hope that makes sense. Obviously the above is useless it's just to demonstrate what I'm doing.
Thank you.
Steve
Re: Passing argument type to subroutrine
Posted: Sun May 24, 2015 6:35 pm
by PeteSampras
you cant pass objects in macro because even though it technically exists, it doesnt exist in the macro parser.
So you can pass strings or ints or bools or floats, etc but not spawntypes.
In your example you would do the (int obj) and /call test ${Target.ID}
I mentioned this awhile back to eqmule but it wasnt any near the top of his to do list. Same for spelltypes.
EDIT: I just reviewed the code again, and maybe you can do it and i just didnt try it correctly. This should work if it works at all:
Code: Select all
Sub Main
/call test ${Target}
return
Sub Test(spawn obj)
/echo ${obj.ID}
return
And if it does work, then we've all been doing macros wrong this whole time.
Re: Passing argument type to subroutrine
Posted: Sun May 24, 2015 9:55 pm
by warlock45
are you looking to target a specific thing and pass that on in a macro?
IE
Code: Select all
Sub Main
........
/declare MATarget int outer
.......
/varset MATarget ${Target.ID}
.....
/if (${Target.ID}!=${MATarget}) /target ${Spawn[${MATarget}].ID}
or are you trying to pass say "${Target.Type.Equal[corpse]}"
or am I just too tired... heh
Re: Passing argument type to subroutrine
Posted: Sun May 24, 2015 11:10 pm
by PeteSampras
He wants to pass it as a spawntype. So if it works at all, it would be what i put.
His backup plan would be to access it via /vardata.
/declare i int local
/vardata i obj.ID
/echo ${i}
Re: Passing argument type to subroutrine
Posted: Mon May 25, 2015 3:09 am
by Steveiwonder
Thanks for the replies.
I have tried it like this however it doesn't work, but the result is different.
Instead of it throwing an error like cannot find member 'ID', the echo actually outputs 0. So it must have passed a type of some kind. I tried echoing more properties on the 'obj' and the values output seem to be their "default"?
Example:
Code: Select all
/echo ${obj.ID} | Always 0
/echo ${obj.AFK} | always FALSE
/echo ${obj.Name} | always empty string
/echo ${obj.Gender}| awlays 'male'
I've tried the above macro on myself and other players male and female just to be sure.
Does this mean it might be possible with maybe a small fix in MQ2? I'm going to try and find my way around the code.
Thanks
Steve
Re: Passing argument type to subroutrine
Posted: Mon May 25, 2015 3:22 am
by warlock45
ah. I thought perchance he/you was... well saying one thing and meaning another basically.
Maybe I am too sleepy but failing to fathom why you would need to pass that information on beyond a check.
if target is afk and male and whatever, add to X list/array/variable.
maybe my knowledge is lacking in this area is all, simply trying to be helpful =)
Re: Passing argument type to subroutrine
Posted: Mon May 25, 2015 3:56 am
by Steveiwonder
The macro above was just an example, I'm trying to do something slightly different but i get i can just use a var which is fine and i will do.
Thank you anyway, worth knowing if this could be done.
Re: Passing argument type to subroutrine
Posted: Mon May 25, 2015 4:44 am
by PeteSampras
I can write little plugin snippet to create what you are asking for in the form of a /command. However, there is probably a better way to incorporate it actually working. What needs to happen is a way to directly access GetSpawnByName() and GetSpawnByID(). a la:
/declare MySpawn1 spawn GetSpawnByID(${Target.ID})
/declare MySpawn2 spawn GetSpawnByName(PeteSampras)
That is the capability I had mentioned to eqmule way back when. To be able to /declare spawn & spell mostly, but other types could be useful.
What I could do now is create a map and store your variable into a vector of spawns/spells/etc.
You can reference the MQ2Ifs post i put up in the plugin section if you'd like to see wtf im talking about.
Re: Passing argument type to subroutrine
Posted: Mon May 25, 2015 5:58 am
by Steveiwonder
PeteSampras wrote:I can write little plugin snippet to create what you are asking for in the form of a /command. However, there is probably a better way to incorporate it actually working. What needs to happen is a way to directly access GetSpawnByName() and GetSpawnByID(). a la:
/declare MySpawn1 spawn GetSpawnByID(${Target.ID})
/declare MySpawn2 spawn GetSpawnByName(PeteSampras)
That is the capability I had mentioned to eqmule way back when. To be able to /declare spawn & spell mostly, but other types could be useful.
What I could do now is create a map and store your variable into a vector of spawns/spells/etc.
You can reference the MQ2Ifs post i put up in the plugin section if you'd like to see wtf im talking about.
I appreciate the offer but honestly, i don't want to consume your time when i can achieve what i want by other means.
Thank you though, it is appreciated