Page 1 of 1

Opitional Parameters

Posted: 2012-09-27 21:29:03
by DracoX
Is there a way to create a function that may receive 0 OR 1 OR 2 parameters.

For example:

0 parameters:
Magery() ; Would cast a default spell without waiting the result of the cast

1 parameter:
Magery('Magic Arrow') ; Would cast 'Magic Arrow' into a target without waiting the result of the cast

2 parameters:
Magery('Magic Arrow',5000) ; Would cast 'Magic Arrow' into a target and wait up to 5sec for the result


I've tryed using Sub Magery(param1) and Sub Magery(param1,param2) in my autoload and Injection only checked one of them for parameter number.

The objective is to be able to use ,exec Magery ingame and Magery(...) with as much parameters as I need



One more thing... Is there a way to use ,exec with functions with parameters?

Re: Opitional Parameters

Posted: 2012-09-28 00:51:54
by Juicy Fruit
With this script.dll. viewtopic.php?f=12&t=16689

Function overloading:

Code: Select all

Sub Magery(p)
...
end sub

Sub Magery(p1,p2)
...
end sub

Sub Magery(p1,p2,p3)
...
end sub
etc...


,exec with functions with parameters - see example in latest post.

Re: Opitional Parameters

Posted: 2012-09-28 15:20:35
by DracoX
Thx for the info!

I might not use this, since I script for other players, and they usually have issues for not following instructions like "download this script.dll and paste it in your Injection folder". Yeah.. they usually don't even read XD

But it's nice to know that there are some developments going around!

Re: Opitional Parameters

Posted: 2012-09-28 23:31:44
by Destruction
U can set global variables and then call required function.

To simplfy developing process, u can write like Juicy advises and write some converter to compatible version (its not so hard..).