DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • August 18, 2017, 08:39:05 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Random Forest Healer  (Read 5620 times)
0 Members and 1 Guest are viewing this topic.
mProwler
Guest
« on: July 31, 2004, 12:25:19 PM »


Another new module.  This one is a random forest healer event.

The healer will either restore a random number of hit points, take away a random number of hit points, or take away a forest fight (if the person is already fully healed).  The event will *not* kill you (though it will take you down to 1 hp)

Enjoy. Cool

http://dragonprime.net/users/mProwler/forestheal.zip
Logged
Kendaer
Guest
« Reply #1 on: August 01, 2004, 01:29:59 AM »

All array access should be done with the array indices in '' if they are words.

For instance, you do
Code:
if ($roll <= $chance && $session[user][hitpoints] > 1) {
and should do
Code:
if ($roll <= $chance && $session['user']['hitpoints'] > 1) {

This is something you do frequently.  [I just noticed you did this in showcharm.php as well]

Logged
dut
Guest
« Reply #2 on: August 02, 2004, 03:14:25 PM »

Is that just stylistic, or does it make a difference in some PHP versions? I've been using PHP5 w/ no problems with either variable naming scheme. If it makes a difference, I'm going to have to go back and change all mine too. Wink

 -- dut
Logged
mProwler
Guest
« Reply #3 on: August 02, 2004, 05:06:41 PM »

 
PHP will accept both, though, as Kendaer pointed out, you should use quoted indices instead.  Many places of the LoGD game code actually use non-quoted array indices (hence why I used them, I usually know better, laugh).  However, I would follow Kendaer's suggestions, just to prevent any problems with your code in the future. (PHP.net specifies to use quotes when dealing with arrays)

Logged
Kendaer
Guest
« Reply #4 on: August 02, 2004, 10:54:41 PM »

Is that just stylistic, or does it make a difference in some PHP versions? I've been using PHP5 w/ no problems with either variable naming scheme. If it makes a difference, I'm going to have to go back and change all mine too. Wink

 -- dut

Actually without them you get even more warnings if you don't turn off that level of notification in the error handling.  (we do).  There are other places where we get warnings which is why those error notifications remain off.

Please make sure that you use quoted alphabetic indices for arrays.
Logged
Kendaer
Guest
« Reply #5 on: August 02, 2004, 10:55:51 PM »

Many places of the LoGD game code actually use non-quoted array indices

Umm not as of 0.9.8.  If you find any places where alphabetic constant indices are unquoted, bring them to my attention.  As far as I know they are all gone.
Logged
Dragonslayer
Guest
« Reply #6 on: September 01, 2004, 06:03:51 AM »

If you don't quote php "thinks" that your indice is a constant and tries to use the constant first. When it won't find the constant it assumes  the  text to be a string.
This is why it works, but it takes longer to parse...doesn't matter in short scripts, but  if the whole logd script would have been written like that the execution time would increase dramatically
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
28 Guests, 1 User
tnyguy
Home Forums News Downloads Login Register Advanced Search