Opitional Parameters

Ask for help

Moderators: Murderator+, Murderator

Post Reply
DracoX
Posts: 14
Joined: 2012-09-10 20:18:54

Opitional Parameters

Post 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?
Juicy Fruit
Posts: 820
Joined: 2011-06-11 19:54:23

Re: Opitional Parameters

Post 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.
DracoX
Posts: 14
Joined: 2012-09-10 20:18:54

Re: Opitional Parameters

Post 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!
Destruction
Junior Expert
Posts: 3221
Joined: 2004-06-24 22:08:56

Re: Opitional Parameters

Post 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..).
YokoInjection CodeSweeper
Function not found?
Possession of mathematics at the level of art - a gift that is only available for election.
Sorry for my clumsy English.
Telegram: @tatikom
Post Reply