Stupid Question

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: Stupid Question
Agent
Member # 27
Profile #0
Where can I get the coordinates of a space, besides counting the squares in the editor. I use a PC, if that makes any sort of difference.
Posts: 1233 | Registered: Wednesday, October 3 2001 07:00
? Man, ? Amazing
Member # 5755
Profile #1
The 3D editor puts the x,y coordinates of the center point in the editing window, right below all the icons. *checks* It is the third line from the bottom in the lower right corner.

Also, Kel made a special ability in that shows the coordinates in-game.

--------------------
quote:
Originally written by Kelandon:

Well, I'm at least pretty sure that Salmon is losing.


Posts: 4114 | Registered: Monday, April 25 2005 07:00
Agent
Member # 27
Profile #2
New question: Here is some scripting I wrote for my practice scenario. It works, but for some reason keeps reactivating. What I mean is, when you pull the lever for the first and what should be only time, everything works. But when you step on the lever again you get the message
quote:
"You pull the lever. At first nothing seems to happen, then something spawns on the pentagram."

Nothing else happens. The demon doesn't spawn, the sound effect doesn't go off, nothing. But the message comes up every time you walk over the lever. Here is my code:

beginstate 12;
if (get_flag(2,3) <= 0) {
reset_dialog();
add_dialog_str(0,"An innocent lever sits in the floor.",0);
add_dialog_str(1,"Pull it?",0);
add_dialog_choice(0,"Yes");
add_dialog_choice(1,"No");
}
if ((run_dialog(0) == 1) && (get_flag(2,3) <= 0)) {
play_sound(99);
set_terrain(18,10,375);
set_terrain(15,12,33);
set_flag(2,3,1);
set_state_continue(13);
}
break;
beginstate 13;
if (get_flag(3,3) <= 0) {
message_dialog("You pull the lever.","At first nothing seems to happen, then something spawns on the pentagram.");
place_monster(20,8,59,1);
put_effect_on_space(20,8,10,4,1);
set_flag(3,3,1);
}
break;
To keep my question simple, WTF?
Posts: 1233 | Registered: Wednesday, October 3 2001 07:00
The Establishment
Member # 6
Profile #3
Just curious on a couple things:

1) Why don't you enclose the second half of state 12 into the first, i.e. nest the second conditional in with the first, that way it never gets seen if 2,3 is > 0.

2) Why are two seperate states required. It seems like the flag 3,3 is used unnecessarily. This is, of course, assuming you have shown us all that relates to this encounter.

3) I usually put the result of run_dialog() in another variable, typically called "choice". I don't think it matters, but I've had weird things with dialog at times.

[ Sunday, June 25, 2006 12:22: Message edited by: *i ]

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Apprentice
Member # 7216
Profile #4
If you use the original specobj script for the lever, memory cells 2 and 3 are the coordinates of a flag that, when set to 1, prevent the event from happening. So... set mem cell 2 =2 and mem cell 3 = 3 to prevent the lever from being used again.

EDIT: flag (3,3) does seem to be unnecessary to this section of script.

[ Sunday, June 25, 2006 13:32: Message edited by: Green Apple ]

--------------------
Apple.elqqA
Posts: 18 | Registered: Monday, June 12 2006 07:00
Agent
Member # 27
Profile #5
beginstate 12;
if (get_flag(2,3) <= 0) {
reset_dialog_preset_options(2);
run_dialog(0) == 2;
play_sound(99);
set_terrain(18,10,375);
set_terrain(15,12,33);
set_flag(2,3,1);
message_dialog("You pull the lever.","At first nothing seems to happen, then something spawns on the pentagram.");
put_effect_on_space(20,8,10,4,1);
place_monster(20,8,59,1);
}
This worked. I combined them together like you said, and the message dialog wouldn't continue to show up every subsequent time I stepped on the lever.

quote:
If you use the original specobj script for the lever, memory cells 2 and 3 are the coordinates of a flag that, when set to 1, prevent the event from happening. So... set mem cell 2 =2 and mem cell 3 = 3 to prevent the lever from being used again.

It's little important facts like these I wish were put in big bold letters somewhere easy to find.

Question: I set the memory cells on the lever to my SDF. Does this mean I dont have to use the call set_flag(2,3,1)?

Edit: And because I used the specobj script on the lever, do I not have to place special encounter over it?

[ Sunday, June 25, 2006 14:07: Message edited by: Enraged Slith ]
Posts: 1233 | Registered: Wednesday, October 3 2001 07:00
Apprentice
Member # 7216
Profile #6
The documentation is confusing, isn't it. If I was an old member who'd been here for years, I'd probably post a link to some site that explains it all perfectly.
I'm pretty sure that you do need to use the set_flag call- the mem cells are only used to say which flag prevents the event, not which flag to set to 1-you'd need to write your own object script for that.
I'm also sure that you don't need a special encounter. If I'm wrong, please tell me. :)

--------------------
Apple.elqqA
Posts: 18 | Registered: Monday, June 12 2006 07:00
Law Bringer
Member # 4153
Profile Homepage #7
Okay, if you use a specobj script, you don't need a special encounter on the lever's space. As for the code itself, I see issues. (see comment)

quote:
Originally written by Enraged Slith:

beginstate 12;
if (get_flag(2,3) <= 0) {
reset_dialog_preset_options(2);
run_dialog(0) == 2;
play_sound(99);
set_terrain(18,10,375);
set_terrain(15,12,33);
set_flag(2,3,1);
message_dialog("You pull the lever.","At first nothing seems to happen, then something spawns on the pentagram.");
put_effect_on_space(20,8,10,4,1);
place_monster(20,8,59,1);
}

What was the line "run_dialog(0) == 2;" intended to do? Because in here, all it will do is run the dialogue box, without taking the player's input.

--------------------
Gamble with Gaea, and she eats your dice.

I hate undead. I really, really, really, really hate undead. With a passion.
Posts: 4130 | Registered: Friday, March 26 2004 08:00
Agent
Member # 27
Profile #8
Maybe it's just because I've just started but the run_dialog() instructions seemed very vague to me. I spent a lot of time trying to make sense of them, but the closer I thought I knew what they did, the less I actually understood. Could someone clarify this call's function for me?
Posts: 1233 | Registered: Wednesday, October 3 2001 07:00
Law Bringer
Member # 4153
Profile Homepage #9
run_dialog() runs the dialog that has been constructed by using the add_dialog_string(), add_dialog_choice(), and all the preset dialog functions. If you put a 1 in the parentheses, the "record" button will appear when the dialog is displayed, a zero will omit the button.

As for what the function returns, if there's only one choice (say, "Okay."), the function will just return a 1, since that's the number of the choice. For more than one choice, it will return different numbers depending on what choice the player picks. Say I've got this set up:

short choice = 0;

reset_dialog();
add_dialog_str(1,"Pointless drivel.",0);
add_dialog_choice(0,"Fish.");
add_dialog_choice(1,"Pi.");
choice = run_dialog(1);
"Pointless drivel" will appear with the choices and a Record button. If the player picks "Fish", run_dialog() will return a '1', thus making choice equal to 1. (Note, the function returns a number one higher than the number given in add_dialog_choice().)

If the player picks "pi", then the function returns a 2.

I hope that cleared things up. Class is dismissed.

--------------------
Gamble with Gaea, and she eats your dice.

I hate undead. I really, really, really, really hate undead. With a passion.
Posts: 4130 | Registered: Friday, March 26 2004 08:00
Agent
Member # 27
Profile #10
Thanks for clearing up the function of run_dialog(), however, one thing about it still bugs me.

The phrase "choice = run_dialog(1);". What is the function of choice = and why change the variable from '0' in the first place? Wouldn't saying choice = run_dialog(1) be the same as saying
0 = run_dialog(1)? So what would 0 = run_dialog() mean? Isn't '0' preset to false?
And when writing the next part of the script
if (choice == 2) // or (0 == 2)and '2' just being an example of an answer.
Wouldn't that basically be saying if (FALSE)? I'm running on low sleep and this problem is driving me crazy. Please clarify.

A less involved question: What exactly is the function of 'end()' and when would it be used?
Posts: 1233 | Registered: Wednesday, October 3 2001 07:00
Off With Their Heads
Member # 4045
Profile Homepage #11
The idea is that "choice = run_dialog(1)" sets the variable "choice" to whatever the value of run_dialog is. It's like saying "choice = 1" or "choice = 2" or whatever. (You work right to left, so BoA turns the run_dialog into a number and then sets choice to that number.)

So "choice" starts out as 0 in the beginning of the script — this is unnecessary; you could take it out and just say "short choice;" — and then it gets set to whatever the run_dialog returned (either 1 or 2, depending on what the player chose). That way, when you run your "if" business, the "choice" variable is either 1 or 2.

And "end" is used when you want everything to stop right away. I have an example of this in an article — "end" is under One-Shot Specials.

[ Monday, June 26, 2006 17:18: Message edited by: Kelandon ]

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
The Establishment
Member # 6
Profile #12
quote:
The phrase "choice = run_dialog(1);". What is the function of choice = and why change the variable from '0' in the first place? Wouldn't saying choice = run_dialog(1) be the same as saying
0 = run_dialog(1)? So what would 0 = run_dialog() mean? Isn't '0' preset to false?
The variable 'choice' is a placeholder variable and useful as it is more or less fixed until changed or entering a new area. Run dialog is a specific function that does two things:

1) It brings up the dialogue message allowing the player to see it and choose.
2) It returns the choice that the player gave. Note that run_dialog() does not have an intrinsic value in itself...it is a function, not a variable.

I'd suggest assigning first and not putting run_dialog() in a logical test as it may or may not get evaluated depending on the order of operations and the coding Jeff used on how the boolean statements are evaluated. In other words, if one of the conditions is determined false in an AND construct, it could just skip evaluating the other because it "knows" the entire statement is false. In such case, the player would see no message at all. Of course, the coding could have that all values are checked regardless of the logic meaning this would not be the case.

'0' is an integer value and not generally the same as false. For a boolean or logical type variable, 0 may mean false in some languages. However, 0 and false should not be equated as the same. In your case, 'choice' is an integer variable so that the meaning of 0 is indeed the number zero, not false.

0 = run_dialog() would mean that you are attempted to reassign the integer value of zero, which is not allowed. Assignment is done with the variable to be operated on on the left -- don't confuse assignment equals with the mathematical equals, there is a subtle difference that I just pointed out.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Off With Their Heads
Member # 4045
Profile Homepage #13
quote:
Originally written by *i:

I'd suggest assigning first and not putting run_dialog() in a logical test as it may or may not get evaluated depending on the order of operations and the coding Jeff used on how the boolean statements are evaluated.
I think, in this case, he's okay. I usually put run_dialog in an "if" phrase unless I have three options to choose among, and it's safe as long as the run_dialog is in the first condition, I believe.

The reason, apparently, is that BoA reads right-to-left inside expressions but left-to-right outside them. Or something. :rolleyes:

[ Monday, June 26, 2006 17:27: Message edited by: Kelandon ]

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Agent
Member # 27
Profile #14
Thank you, that cleared a lot of things up.
beginstate 12;
if (get_flag(2,3) <= 0) {
reset_dialog_preset_options(2);
choice = run_dialog(0);
}
if (choice == 2) {
play_sound(99);
set_terrain(18,10,375);
set_terrain(15,12,33);
set_flag(2,3,1);
message_dialog("You pull the lever.","At first nothing seems to happen, then something spawns on the pentagram.");
put_effect_on_space(20,8,10,4,1);
place_monster(20,8,59,1);
}
break;
Is this more or less what it should look like now? Note that I set 'choice' as a variable earlier in the town script.

Edit: And yes I did read the one-shot specials section, but I'm going to stay away from 'end()'for the time being until I get a better handle on scripting.

[ Tuesday, June 27, 2006 08:58: Message edited by: Enraged Slith ]
Posts: 1233 | Registered: Wednesday, October 3 2001 07:00
Off With Their Heads
Member # 4045
Profile Homepage #15
You also have to run the effect. Stick a run_animation or run_animation_sound at the end, perhaps after you've placed the monster.

By the way, if you place the monster first and use a hidden group (which I always prefer over place_monster whenever possible, for a variety of reasons), you can use put_effect_on_char instead of specifying the space.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Warrior
Member # 6682
Profile #16
This thread is useful for newbies like me...

--------------------
Lancer
Posts: 73 | Registered: Friday, January 13 2006 08:00
The Establishment
Member # 6
Profile #17
Glad to see it's of use. At some point, we should archive some of the more useful discussions. Unfortunately, I really don't have time, but an ambitious person would definitely be appreciated.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Agent
Member # 27
Profile #18
New question:

I am designing a practice town with a lot of puzzles, SDFs, and combinations. I am trying to make an altar that kills a character of your choice if he doesn't have enough (stat). Please help me fill in this code (or fix whatever I screwed up).

beginstate 14;
// select character
// selected character = ME
reset_dialog()
add_dialog_str(0,"blah blah.",0);
add_dialog_str(1,"blah blah.",0);
add_dialog_str(2,"Rest on the altar?");
add_dialog_choice(0,"Try to resist");
add_dialog_choice(1,"Rest on the altar.");
choice = run_dialog();
if ((choice = 1) && (get_stat(ME,2) >= 6)) {
message_dialog("blah blah.","");
end();
}
else {
message_dialog("Blah blah.","");
kill_char(ME,2,0);
end();
}
if (choice = 2) {
message_dialog("Blah blah.","");
kill_char(ME,2,0);
end();
}
break;
Edit: Mainly I want you to correct any large errors and fill in what I need at the top. I've already found most of the small errors and typos.

[ Friday, June 30, 2006 08:00: Message edited by: Enraged Slith ]
Posts: 1233 | Registered: Wednesday, October 3 2001 07:00
Infiltrator
Member # 5576
Profile Homepage #19
ME is a reserved constant, defined equal to -1, except when running a creature (or terrain? I can't remember.) script. You need a different variable name I think. Also, you can get the selected pc with a get_selected_char() call. Or, you can ask the player to selecta pc with run_select_a_pc() and get_selected_pc(). It might also be a nice touch to alter the strings so that the player is asked "Do you want [name of selected character] to rest on the alter?" and so forth. You can do this with the string manipulation calls without too much trouble.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Off With Their Heads
Member # 4045
Profile Homepage #20
The call run_dialog needs arguments (probably the number "1").

You don't need the "end" calls.

As Niemand indicated, you'll need a real variable, not ME.

I'd go with something like this at the top (much like what Niemand described):

message_dialog("Something about needing to select a person.","");
if (run_select_a_pc(0) == 0)
message_dialog("You fail. At life.","");
else {
}
Within the "else" part, you can put the rest of your code, and instead of ME, use get_selected_pc().

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Agent
Member # 27
Profile #21
New question, sort of. I looked back over this town script and figured out why I was having trouble with a certain state. However, I can not think of a different way to write it out. Basically this is what I have written:
beginstate 14;
run_select_a_pc(0);
bob = get_selected_pc();
reset_dialog();
add_dialog_str(0,"addfstyjkujk,"0);
add_dialog_str(1,"a;lsjkdflasf;asdf.",0);
add_dialog_str(2,"Bibbity?",0);
add_dialog_choice(0,"no bibbity");
add_dialog_choice(1,"bibbity.");
choice = run_dialog(1);
if ((choice == 1) && (get_stat(bob,2) >= 6)) {
message_dialog("I touched the applesauce.","");
}
else {
message_dialog("mango","woogity woogy.");
kill_char(bob,2,0);
}
if (choice == 2) {
message_dialog("blah","wakka wakka.");
kill_char(bob,2,0);
}
break;
The problem here was that when your character selected the second choice, the first choice ELSE message would play, and then the second message would play. I know now that ELSE is called whenever the IF requirements are not met.

How can I make it so that Choice 1 has two possible outcomes while Choice 2 is also a possible outcome.
Posts: 1233 | Registered: Wednesday, October 3 2001 07:00
Infiltrator
Member # 5576
Profile Homepage #22
What you want is:
if(choice == 1){
if(something){
//do stuff
}
else{
//do other stuff
}
}
else if(choice == 2){
//do different stuff
}
The problem was that you combined two conditions into one if statement, so that the else block occurred if either was false, when you wanted it to occur when only a specific one was false.

EDIT: How did I mispell 'that' as 'htta'?

[ Tuesday, July 11, 2006 12:30: Message edited by: Niemand ]

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Lifecrafter
Member # 6193
Profile Homepage #23
quote:
Originally written by Enraged Slith:

choice = run_dialog(1);
if ((choice == 1)
{ if(get_stat() >= x)
message_dialog("I touched the applesauce.","");

else {
message_dialog("mango","woogity woogy.");
kill_char(bob,2,0);
}
}


You need brackets after the if(choice == 1).
Edit: Note to self, don't use tab when posting.

[ Tuesday, July 11, 2006 12:37: Message edited by: Lazarus. ]

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00