char_on_spot...?

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: char_on_spot...?
BANNED
Member # 4
Profile Homepage #0
This script does nothing:

beginstate 31;
if(char_on_spot(19,36) == 0 || char_on_spot(19,36) == 1 || char_on_spot(19,36) == 2 || char_on_spot(19,36) == 3){
print_str("You are standing on the mat.");
}
else{
print_str("You are not standing on the mat.");
}
break;

----

If I'm merely making some stupid syntax error, then please alert me.

--------------------
*
Posts: 6936 | Registered: Tuesday, September 18 2001 07:00
Infiltrator
Member # 3040
Profile #1
I think you may need parentheses around each condition, but I'm not sure:

((char_on_spot(19,36) == 0) || (char_on_spot(19,36) == 1) || (char_on_spot(19,36) == 2) || (char_on_spot(19,36) == 3))

--------------------
5.0.1.0.0.0.0.1.0...
Posts: 508 | Registered: Thursday, May 29 2003 07:00
BANNED
Member # 4
Profile Homepage #2
Nope- Doesn't work.

--------------------
*
Posts: 6936 | Registered: Tuesday, September 18 2001 07:00
Infiltrator
Member # 169
Profile #3
Looks like it should work. Did you make sure the state is actually being called? (Put a print_str outside the conditional.)
Posts: 422 | Registered: Tuesday, October 16 2001 07:00
BANNED
Member # 4
Profile Homepage #4
I tried both Namothil's and Wizard's suggestions, but still couldn't make it work. Bah. -_-

(First, I tried calling this through state 2. Then, I tried calling it as a node. Both didn't work.)

--------------------
*
Posts: 6936 | Registered: Tuesday, September 18 2001 07:00
Infiltrator
Member # 154
Profile #5
Try incrementally checking it.

good = false;
good = (char_on_spot(19,36));
if (good = false) good = (char_on_spot(20,37));
if (good = false) good = (char_on_spot(20,37));
if (good = false) good = (char_on_spot(20,37));

if (good = true) {
// on mat

Etc.

[ Sunday, March 28, 2004 05:33: Message edited by: Snuff ling kin ]

--------------------
Apparently still annoying.
Posts: 612 | Registered: Saturday, October 13 2001 07:00
BANNED
Member # 4
Profile Homepage #6
Boolean checks don't use semicolons.

That aside, I'm not entirely sure what you're getting at.

--------------------
*
Posts: 6936 | Registered: Tuesday, September 18 2001 07:00
Infiltrator
Member # 154
Profile #7
quote:
Originally written by Snuff ling kin:

Try incrementally checking it.

good = false;
good = char_on_spot(19,36);
if (good = false) good = (char_on_spot(20,37));
if (good = false) good = (char_on_spot(20,37));
if (good = false) good = (char_on_spot(20,37));

if (good = true) {
// on mat

Etc.

It works like this.

Good is false.
Good is whatever char_on_spot returns (i.e. true if char there, false otherwise).
Then, if good is still false, it sets good to whether char is on the next spot. And again and again until it's tried all the spots. Then you check good, see if it's true, if it is, a char is on any of the spots.

--------------------
Apparently still annoying.
Posts: 612 | Registered: Saturday, October 13 2001 07:00
Post Navel Trauma ^_^
Member # 67
Profile Homepage #8
Try making it print the result of is_char_on_spot.

--------------------
Barcoorah: I even did it to a big dorset ram.

New Mac BoE
Posts: 1798 | Registered: Thursday, October 4 2001 07:00
Shock Trooper
Member # 4154
Profile #9
Put a space between the if and the first parenthesis. I don't know if the space matters, but its worth a try.

--------------------
You're a moron if you think I'm not.
Posts: 213 | Registered: Friday, March 26 2004 08:00
Apprentice
Member # 4127
Profile #10
quote:
Originally written by Tentacle Monster:

This script does nothing:

beginstate 31;
if(char_on_spot(19,36) == 0 || char_on_spot(19,36) == 1 || char_on_spot(19,36) == 2 || char_on_spot(19,36) == 3){
print_str("You are standing on the mat.");
}
else{
print_str("You are not standing on the mat.");
}
break;

----

If I'm merely making some stupid syntax error, then please alert me.

It is a good idea to check out the tech support page page, as I and others have been sending all these issues to Jeff.

This is a bad documentation bug. There are two functions, each of which is poorly documented: char_on_spot() and char_on_loc(). The function char_on_spot() is NPC only. You are clearly checking for player characters here.

Change it to char_on_loc().
Posts: 48 | Registered: Saturday, March 20 2004 08:00
Apprentice
Member # 4127
Profile #11
One more thing. To make it a little more efficient, you want to write (now that I know the UBB for code)

beginstate 31;
if (char_on_loc(19,36) >= 0 && char_on_loc(19,36) <= 3) {
print_str("You are standing on the mat.");
} else {
print_str("You are not standing on the mat.");
}
break;

Posts: 48 | Registered: Saturday, March 20 2004 08:00