DragonPrime - LoGD Resource Community
Welcome Guest
  • Good afternoon, Guest.
    Please log in, or register.
  • July 15, 2018, 04:23:03 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1] 2 3   Go Down
  Print  
Author Topic: Settings values (for anyone who would like to know)  (Read 20188 times)
0 Members and 1 Guest are viewing this topic.
Spider
Guest
« on: August 17, 2004, 04:08:56 PM »

this isn't a request, but a general help for anyone who needs it.  I've thrown together a rough guide of all the settings and prefs you can use in the getmoduleinfo bit of your modules.

Thanks to Kendaer for the help, and I apologise for a couple of them being incomplete.

title
this is used to give a header, all of the settings bits in the modules have these so examples are plentiful Smiley

note
this gives a plain bit of text, a note really.
Example in suipcontrol.php

dayrange,end,step|default
this produces a drop down box which allows you to pick a date, from now until the end date with intervals of step.
example in gardenparty.php

range,min,max,step|default
this produces a drop down box allowing you to select a value from a range of numbers between min and max, with intervals of step.
example in forestturn.php

floatrange,min,max,step|default
identical to range, except that floatrange allows decimals, so you can have 0.5 instead of it being rounded to 1.
example in thieves.php

bitfield,
gives you checkboxes, as many as you want Smiley
example in extlinks.php
sorry I haven't given the arguments, but this one is a little complicated and I don't quite understand it myself...

datelength|default
the defaults for this are defined in lib/showform.php

enum
this gives you a defineable drop down list, the arguments are not given because no modules have an example of this.  Sorry.

password|default
A password entry field, meaning what you enter appears as *'s, apart from that it's not complicated.
No examples exist in the core release modules.

bool|default (0 or 1)
dead simple, on or off (0 is off, 1 is on).
example in riddles.php

hidden|default
a hidden field, gives you a form value that cannot be seen or changed by the user.  Useful for passing variables that the user doesn't need to know about.
No examples exist in the core release modules.

viewonly|default
A form value which the user can see, but cannot change.
example in lottery.php

textarea|default
A large(ish) text entry field, works just like the default input box but with multiple lines.
No examples exist in the core release modules.

int|default
An input box that will only accept numbers, and will round what is inputted to the nearest whole.
example in dag.php

float|default
As with int, but float does not round the numbers so decimals can be used.
No examples exist in the core release modules.


no type defined gives a 50 character large input field, you can set |default as with all others.

all of these except for title and note must be followed with |
you don't always need a value after that, but the | has to be there.

also, all of these must be followed by a , after the default value, except the last one (although it doesn't hurt to put it in, that way you never forget).
Logged
Kendaer
Guest
« Reply #1 on: August 17, 2004, 05:47:22 PM »

Spider is somewhat correct Smiley

He is correct that using the form elements withing settings (and prefs) requires the | except on title (and note) elements.

However, that is specific to the module stuff and isn't actually used by the showform library which the rest of the line is being used for.  We sort of merged the ability to do default values in with that for the module stuff because it was reasonably clean and put the defaults near the values which would be used for the configuration and user forms later.

enum has a decent example in configuration.php where we set up the default language of the game enum.

It's format is
Code:
enum,<val1>,<name1>[,<val2>,<name2>[,...]]
This will set up a dropdown that looks like

    val1: name1
    val2: name2

When you select an option from the list, the value is stored in the form as with any dropdown.

bitfields are a bit tricky.
their format is
Code:
bitfield,<allowedmask>,<val1>,<text1>[,<val2>,<text2>[,...]]

The allowedmask is used to restrict certain values from being set by certain players.  It's used for instance in the superuser bitfield to prevent someone giving themselves (or others) powers that they don't have.  For most module applications, you can use 0xffffffff just as the extlinks.php module does.

The val is the value which will be returned if that checkbox is checked.  It should ALWAYS be a power of 2 (hence the term bitfield).  The text is what is shown next to the checkbox.

These also require special handling on the form submission.  Again, look at extlinks.php and the handling of the link<x>show fields.  You will need to do similar handling on that hook.  This is because of how the bitfield checkboxes are returned as an array in php (well we set them up to be since that made the handling easier).  Basically that code is summing up the bitfield values and converting them back into a number rather than an array.

Hope this helps!


Logged
Lightbringer
Member
Codemeister
****
Offline Offline

Posts: 267


Life's a lich and then you don't die...damn unlife


View Profile
« Reply #2 on: February 21, 2005, 03:26:10 AM »

Why didn't I find this stuff earlier   o.0

Extraordinarily handy...

Thankees...

Oh my god!~!  Did I just say Thankees?

Someone please kill me now

* Lightbringer dies a horrible death
Logged

________________________ _____________________

Lightbringer
PHP/SQL/VB.NET/C#/AJAX Developer
CortalUX
Dwellings Project
Mod God
*****
Offline Offline

Posts: 796


Wogga! Meep!


View Profile WWW
« Reply #3 on: March 30, 2005, 12:50:01 PM »

I was just wondering... when I first started coding, I'd just use '<WHATEVER>,|' for a text box.. (I think it was that, I might not have put the comma)
And since then, I now always use '<WHATEVER>,text|'... what is the 'officially supported' way of showing a text input field?
Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #4 on: March 30, 2005, 12:53:44 PM »

Code:
Blah,text|",
Or
Code:
Blah,textarea|",
Basically, your old way would work, but ,text| defines a text field in the DB, while blah,| will just do the default. So, it is just clean code, as well as a way to better define things, rather than leaving it to chance.

lib/showform.php:
Code:
default:
   $val = $row[$key];  
   rawoutput("<input size='50' name='$keyout' value=\"".HTMLEntities($val)."\">");
      }
Hope this helps.
« Last Edit: March 30, 2005, 12:57:04 PM by Sichae » Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

CortalUX
Dwellings Project
Mod God
*****
Offline Offline

Posts: 796


Wogga! Meep!


View Profile WWW
« Reply #5 on: March 30, 2005, 12:59:50 PM »

Code:
Blah,text|",
Or
Code:
Blah,textarea|",
Basically, your old way would work, but ,text| defines a text field in the DB, while blah,| will just do the default. So, it is just clean code, as well as a way to better define things, rather than leaving it to chance.

lib/showform.php:
Code:
default:
   $val = $row[$key];  
   rawoutput("<input size='50' name='$keyout' value=\"".HTMLEntities($val)."\">");
      }
Hope this helps.
Thanks a lot for that:)
Logged
Arwym Starlight
Guest
« Reply #6 on: August 01, 2006, 08:49:45 AM »

Thank you for this guide... I definitely needed to know. Smiley
Logged
Tela
Guest
« Reply #7 on: March 09, 2008, 04:55:49 AM »

A great use for enum, which I've used in my first module (working on it now, it's a race template for extreme customization, including golds,gems,minedeath,mindk,maxdk,forest fights, exp mod, race lock, racial skills - all options in the grotto)

Code:
"settings"=>array (
blah blah blah blah etc etc :)
  "Racial Effects,title",
    "racelock"=>"What sex is the race available to?,enum,1,Males,0,Females,2,Both|2",
)
Then in case "chooserace":
Code:
       case "chooserace":
        $raceval = get_module_setting("racelock");
        if ($raceval==0 &&
        ($session['user']['sex']==SEX_MALE))
        break;
        if ($raceval==1 &&
        ($session['user']['sex']==SEX_FEMALE))
        break;
I suppose I could have just as easily used bitfield, but I think everyone is used to the drop-down boxes, so may as well keep it simple. Heh.
Logged
White Knight
Mod God
*****
Offline Offline

Posts: 1030

For the truth!


View Profile
« Reply #8 on: March 09, 2008, 05:31:13 AM »

Then in case "chooserace":
Code:
       case "chooserace":
        $raceval = get_module_setting("racelock");
        if ($raceval==0 &&
        ($session['user']['sex']==SEX_MALE))
        break;
        if ($raceval==1 &&
        ($session['user']['sex']==SEX_FEMALE))
        break;

A style point:
if-break-if-break is something most people don't like to use (look up spaghetti code).  Instead, try an if-elseif construct:
Code:
<?php...
case "chooserace":
$raceval get_module_setting("racelock");
if ($raceval==&&
($session['user']['sex']==SEX_MALE))
/* do something */ }
elseif ($raceval==&&
($session['user']['sex']==SEX_FEMALE))
/* do something */ }
else /* code for both */
break; // one final break; to end the case
...?>
Logged

Helping you help yourself.
Iori
Mod God
*****
Offline Offline

Posts: 832


View Profile WWW
« Reply #9 on: March 09, 2008, 05:38:26 AM »

In this case, this is simpler:

Code:
case "chooserace":
if ($session['user']['sex'] != get_module_setting("racelock")) {
/* do something */
}
break;

since SEX_MALE = 0 and SEX_FEMALE = 1 in the database
« Last Edit: March 09, 2008, 08:06:46 AM by Iori » Logged

Nightborn
Guest
« Reply #10 on: March 09, 2008, 05:49:01 AM »

Is this a private party or may I join in? Wink


@highly flexible race module

what you will create is a high-load module that does in MOST locations it hooks in nothing =)

but don't let that discourage you, it's just my opinion I state, and I think *doing* that module is helpful for your own development as coder ^^
Logged
Tela
Guest
« Reply #11 on: March 09, 2008, 07:14:28 AM »

Is this a private party or may I join in? Wink


@highly flexible race module

what you will create is a high-load module that does in MOST locations it hooks in nothing =)

but don't let that discourage you, it's just my opinion I state, and I think *doing* that module is helpful for your own development as coder ^^
You are right of course. I'm learning as I go, and this is a great way to do it. Smiley

Basically, I'm coding this for myself, so I can pop out races fast later when I need them. I can trim back the variables and options I'm not using after I set each race the way I want it...And, well high-load or not I know some non-coding admins will want to use it just for the customization ability. Smiley

Also, yeah, this race is nearing the same byte size as racehuman (and it doesn't have a city attached) Tongue

Code:
    "settings"=>array (
      "General Settings,title",
        "minedeathchance"=>"Percent chance to die in the mine,range,0,100,1|50",
        "mindk"=>"How many DKs do you need before the race is available?,int|0",
        "maxdk"=>"At what DK does the race become unavailable?,int|100",
      "Gold/Gem Finding,title",
        "gemchance"=>"Percent chance to find a gem on battle victory,range,0,100,1|5",
        "goldmod"=>"What is the percent modifier for gold after battles?,range,0,200,2|0",
        "gemfind"=>"Message to display when finding a gem|`&Your sense is tingling! You extend your grubby fingers and grab a `%gem`&!",
        "goldchance"=>"Percent chance to find extra gold on battle victory,range,0,100,1|0",
        "goldfind"=>"Message to display when finding gold|`&Your senses tingle, and you notice a bag of gold`&!",
      "Racial Buffs,title",
        "gemgoldbuffdisplay"=>"Display this race's gem/gold finding ability as a buff?,bool|1",
        "gemgoldbuff"=>"What is the name of this race's gem/gold finding buff?|`6Gem Affinity`&",
        "racebuffdisplay"=>"Display this race's racial buff?,bool|1",
        "racebuff"=>"What is the name of the racial buff?|`@Something Cool`&",
        "gemgoldbuffdisplay"=>"Display the gem/gold finding ability as a buff?,bool|1",
        "gemgoldbuff"=>"What is the name of the gem/gold finding buff?|`6Gem Affinity`&",
        "extrabuffdisplay"=>"Display an extra buff? Has no actual effect - just like the gem/gold buff,bool|0",
        "extrabuff"=>"What is the name of the extra buff?|`1Snappy Dresser",
        "racelock"=>"What sex is the race available to?,enum,1,Males,0,Females,2,Both|2",
      "Added some junk,title",
    "exp"=>"What is the experience percent modifier of this race? 100% is normal,range,10,200,2|100",
        "expsetrace"=>"Message to display about experience modifier upon choosing the race|You get more exp! Yay!",
        "forestfights"=>"What is the daily forest fight modifier for this race?,range,-10,10,1|0",
        "ffsetrace"=>"Message to display about forest fight modifier upon choosing the race|Your momma said you were special, so you receive some extra forest fights per day.",
        "ffnewday"=>"Message to display about forest fight modifier at each newday|Since you're so special, you get some extra forest fights today!",
    "dpoption"=>"Can the race be bought with donation points?,enum,0,Only with donations,1,Never with donations,2,Donations as an option|1",
        "dpcost"=>"How many donation points does the race cost, if applicable?,int|0",
"Racial Skills,title",
  "enableskills"=>"Enable racial skills?,bool|0",
  "skill"=>"Points in Racial Skills,int|0",
  "skill1"=>"How many uses of Skill #1 allowed each newday,int|0",
  "skill2"=>"How many uses of Skill #2 allowed each newday,int|0",
  "skill3"=>"How many uses of Skill #3 allowed each newday,int|0",
"Look at this it's a note!,note",
    ),
lol, not even close to done yet. Hmm,

Also thank you for the advice, all 3 of you. Smiley
I'm sure I'll be making plenty more mistakes as I go. It's nice to have experienced people around like you people to give advice. Smiley

*EDIT*
So far only 15 extra queries, compared to the standard "racehuman". Cheesy

Well, on a server by myself with character creation disabled, my pagegens are normally 0.08 or less Wink
We'll see what happens later lol
« Last Edit: March 09, 2008, 07:48:11 AM by Tela » Logged
Nightborn
Guest
« Reply #12 on: March 09, 2008, 07:48:20 AM »

 Grin don't sweat, you're probably right about people wanting to have it when they are non-coders.

You should think about a nice way to put in two or more of this modules at once =) because: only one can have the same name, then if you rename files, you have  to rename the functions. That would be manually editing and defeat the purpose somehow =)

^^ nobody stops making mistakes, but we can try to learn from them, that's also my agenda.
(and as I do mistakes daily, one day I'll be a wise man? Oo)
Logged
Tela
Guest
« Reply #13 on: March 09, 2008, 07:55:34 AM »

You only have to edit every instace of race*insert_race_name* right? So instructions to customize would be simple:

  • Open the module in your favorite editing program (notepad will work if it's all you have)
  • Do a find&replace, matching case: REPLACE "racetemplate" with "raceYOUR_RACE_NAME"
  • Do a find&replace, matching case: REPLACE "Template" with "YOUR RACE NAME"
I think that would do it, wouldn't it? Works for me anyway :O
Logged
els forever magic
Guest
« Reply #14 on: March 09, 2008, 03:22:06 PM »

But if you want to do a different buff like the race angel by... I think it is by RPGSL but no one has done that buff before... you could be in trouble.

I learnt on races but now I am working on 2 shops... they are WAY easier... or I am just getting better XD.
Logged
Pages: [1] 2 3   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
35 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search