Good News!

Forum Archive - from http://theuniversal.net
Locked
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Good News!

Post by Mit »

0.68.9 servers now support function array parameters by reference!
Woot!
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

yea what's newbspeak for that?
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

erm, isn't it obvious? :)

Really needs an example (i've got a nice generic school script which ill post later), but essentially..

Say you've got an array like :

Code: Select all

$maSkillsList1[] = 
{
  "Farmer",
  "Lumberjack",
  "Miner",
  "",
}
and you've got a nice lil function that loops the array, building up an OSD or something.
Now you can call the function with the array as a parameter, e.g :

Code: Select all

ShowSchoolsOSD( $maSkillsList1 )
So.. if you want to display a different list (for a different school building for instance), you can just create another array ( $maSkillsList2 for instance ) and call the same display function as in :

Code: Select all

ShowSchoolsOSD( $maSkillsList2 )
Hence I can now go and delete about 60% of my script code, making everything much more maintainable and generic. Well i consider that a woot :]
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

Post by morbydvisns »

Nice. One of the rare times where 'more generic' is a good thing =).
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post by Mit »

mebbe 'reusable' is a better term.. and that's always a good thing in code land.
Locked