DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • April 24, 2018, 03:43:37 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: get_module_pref order  (Read 2951 times)
0 Members and 1 Guest are viewing this topic.
DaveS
Mod God
*****
Offline Offline

Posts: 1544


Dfly... you know, as in DaveFly


View Profile
« on: April 14, 2006, 09:57:58 AM »

I wanted to make sure I don't make this mistake anymore... so I was wondering if someone could outline the order of how things should appear when you get information (or set or increment) from a preference or a setting.


For instance...

Code:
increment_module_preference("a",b,"c",d)

As far as I recall:
a= The preference that is being called
b= the amount that the increment will change
c= the module that the preference is from
d= the id number of the player

What is the "master order"? In other words, is there an e, f, g, h, i etc.?

Code:
increment_module_preference("a",b,"c",d,e,f,g,h,i)

Logged

Check out my Last Module:
The Dragon Eggs Expansion
http://dragonprime.net/index.php?topic=8474.0

About my Retirement:
http://dragonprime.net/index.php?topic=9080

See my complete module list here:
http://dragonprime.net/index.php?topic=3038.0
Torne
SVN Users
Codemeister
*
Offline Offline

Posts: 259


Code ninja


View Profile
« Reply #1 on: April 14, 2006, 10:10:27 AM »

That's it. Set and increment have those four parameters in that order; get and clear have just a, c and d. (no value).
Logged
DaveS
Mod God
*****
Offline Offline

Posts: 1544


Dfly... you know, as in DaveFly


View Profile
« Reply #2 on: April 14, 2006, 11:14:53 AM »

clear? What's clear?

*sits at Torne's feet and waits for story time.
Logged

Check out my Last Module:
The Dragon Eggs Expansion
http://dragonprime.net/index.php?topic=8474.0

About my Retirement:
http://dragonprime.net/index.php?topic=9080

See my complete module list here:
http://dragonprime.net/index.php?topic=3038.0
sixf00t4
Mod God
*****
Offline Offline

Posts: 1916



View Profile WWW
« Reply #3 on: April 14, 2006, 11:39:57 AM »

look at how the function is set up in lib/modules.php

line 698:
Code:
function get_module_pref($name,$module=false,$user=false){

line 751:
Code:
function increment_module_pref($name,$value=1,$module=false,$user=false){
Logged

ShadowRaven
Mod God
*****
Offline Offline

Posts: 805


Silence is a virtue...


View Profile WWW
« Reply #4 on: April 14, 2006, 11:51:42 AM »

I think he means what does the 'clear' mean. I believe clear_module_pref  removes the value from the specified pref?
Logged

DaveS
Mod God
*****
Offline Offline

Posts: 1544


Dfly... you know, as in DaveFly


View Profile
« Reply #5 on: April 14, 2006, 12:04:52 PM »

Actuallly both answers are really helpful. Thanks for showing me where that is in the core, Six.

So about this clear thing... Aren't these two things doing the exact same thing?:

Code:
clear_module_pref("stuff");

Code:
set_module_pref("stuff",0);

Is "clear" more efficient? Or does "clear" set ALL users to zero?
« Last Edit: April 14, 2006, 12:07:02 PM by DaveS » Logged

Check out my Last Module:
The Dragon Eggs Expansion
http://dragonprime.net/index.php?topic=8474.0

About my Retirement:
http://dragonprime.net/index.php?topic=9080

See my complete module list here:
http://dragonprime.net/index.php?topic=3038.0
Torne
SVN Users
Codemeister
*
Offline Offline

Posts: 259


Code ninja


View Profile
« Reply #6 on: April 14, 2006, 12:34:47 PM »

clear deletes the pref from the database completely (for the current user, or the user you specify). Setting it to zero just stores a value of zero in the database. Zero is a perfectly valid value and is distinct from the pref not existing Wink
Logged
sixf00t4
Mod God
*****
Offline Offline

Posts: 1916



View Profile WWW
« Reply #7 on: April 14, 2006, 12:51:37 PM »

Actuallly both answers are really helpful. Thanks for showing me where that is in the core, Six.

So about this clear thing... Aren't these two things doing the exact same thing?:

Code:
clear_module_pref("stuff");

Code:
set_module_pref("stuff",0);

Is "clear" more efficient? Or does "clear" set ALL users to zero?


Line 776:
Code:
function clear_module_pref($name,$module=false,$user=false){
Logged

ShadowRaven
Mod God
*****
Offline Offline

Posts: 805


Silence is a virtue...


View Profile WWW
« Reply #8 on: April 15, 2006, 11:21:28 PM »

So when adding prefs that are set later by what a user does/buy/sell et.., is it better to leave the pref blank, or give it the value of 0? Does the pref only get added to the DB if there is a value to it?
Logged

Torne
SVN Users
Codemeister
*
Offline Offline

Posts: 259


Code ninja


View Profile
« Reply #9 on: April 16, 2006, 07:13:27 AM »

If you set a value of 0, it will be stored in the DB and it will return 0 when you get the value.
If you don't set a value at all, nothing will be stored in the DB and it will return the default value specified in the prefs array.

There is no way to set the pref to 'nothing' - if you pass in the empty string or 0 it will save it as the empty string or 0 respectively, and if you pass in an undefined value it will set it to the empty string (or possibly PHP will error at you).

You can just not set the pref, if there's no value for it yet.. and use clear if you want to reset it to 'no value' later.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
36 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search