Raised This Month: $51 Target: $400
 12% 

sawce's Strange Function Calls


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
stupok
Veteran Member
Join Date: Feb 2006
Old 04-18-2009 , 22:38   sawce's Strange Function Calls
Reply With Quote #1

I read bits and pieces of the Pawn manual a while ago, but I don't remember seeing anything like this:

Code:
register_plugin .author="sawce", .version="1.0", .plugin_name="DC Heal Stacker";

It's strange, because there are also "normal" lines like this:

Code:
mp_dcrequirehives=  register_cvar("mp_dcrequirehives","0");

and "mixed" lines like this:

Code:
if (equali(.b=MapName, .c=3, .a="co_")==1)

https://forums.alliedmods.net/showthread.php?t=52573

Could someone explain the significance of this style? I might look into the manual later if I'm bored.
__________________
stupok is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-18-2009 , 23:12   Re: sawce's Strange Function Calls
Reply With Quote #2

I also saw this:
Code:
pev HealTarget, pev_origin, Origin;
Even though the one you pointed out was even stranger, the code is still difficult to read.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-19-2009 , 00:11   Re: sawce's Strange Function Calls
Reply With Quote #3

Quote:
Originally Posted by stupok View Post
I read bits and pieces of the Pawn manual a while ago, but I don't remember seeing anything like this:

Code:
register_plugin .author="sawce", .version="1.0", .plugin_name="DC Heal Stacker";
That's documented. He's calling functions not using (). The other part is to pass the arguments by their names. That makes their meaning easily understandable and if i recall correctly makes you able to pass them not in the function header pre-defined order.


Quote:
Pawn is flexible in that key area: calling functions. pawn supports default
values for any of the arguments of a function (not just the last), callby-
reference as well as call-by-value, and “named” as well as “positional”
function arguments.
__________________

Last edited by joaquimandrade; 04-19-2009 at 00:16.
joaquimandrade is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 04-19-2009 , 00:16   Re: sawce's Strange Function Calls
Reply With Quote #4

so, are parenthesis required for use with =, ==, etc operators?
__________________
stupok is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-19-2009 , 00:21   Re: sawce's Strange Function Calls
Reply With Quote #5

Quote:
Originally Posted by stupok View Post
so, are parenthesis required for use with =, ==, etc operators?
Parenthesis are not required. You just need them to ignore the precedence rules.

You can say x = 3 * 4 + 2 but x won't be 18 unless you make it x = 3 * (4+2)
__________________
joaquimandrade is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 04-19-2009 , 15:05   Re: sawce's Strange Function Calls
Reply With Quote #6

I'm talking about this:

PHP Code:
if ( equali .b=MapName, .c=3, .a="co_" == )

or

if ( 
== equali .b=MapName, .c=3, .a="co_" 
__________________
stupok is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-19-2009 , 15:22   Re: sawce's Strange Function Calls
Reply With Quote #7

Quote:
Originally Posted by stupok View Post
I'm talking about this:

PHP Code:
if ( equali .b=MapName, .c=3, .a="co_" == )

or

if ( 
== equali .b=MapName, .c=3, .a="co_" 
Stupok, i've tested and you need to use function parenthesis when you are getting the returned value. So this is valid:

equali .a="a" , .b="b" , .c=1

This don't:

new x = equali .a ="a" , .b="b", .c=1

Same as for your if. So you need to make it:

if ( 1 == equali(.b=MapName, .c=3, .a="co_") )
__________________
joaquimandrade is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:48.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode