If player talked to door change room

Started by Buckethead, Sat 30/09/2006 19:24:37

Previous topic - Next topic

Buckethead

hiya,

It's me again,

Ok here's the problem:

I have this door. I want the player to go through if he interacts with it, easy... but... I want to player to talk to the door first and then he can go through. The player must say: "it's locked " if he can't get through yet.

PS: I checked the manual and asked someone (who wants to remain un known) on msn but both things got me no where. I think i need to do something with variable (or something)

anyway,

thnx in advance!

- Buckethead  :)

Ashen

Well, it'd be useful to know what you've tried, even if they didn't go anywhere.
You're right, though, sounds like you need to use a variable - why not try try a forum / manual search for them, if you're having problems. Again, if you explained what you've already tried, how/why that didn't work out, and what problems (if any) you're having with variables you might get a more specific response.

Some useful links, if you haven'tread them already:
From the BFAQ:
Variables & How to use them
GlobalInts: your friend


And from the manual:
if ... else ... statements
I know what you're thinking ... Don't think that.

Buckethead

i have seen them all but didn't find the sulution.  It might be in variables part but I don't get anything of it  ???

Ashen

So, what have you tried? Knowing what you've done that doesn't work helps to figure out what WILL work.

This is really fairly simple. At the top of the room script add the line:
Code: ags

bool Spoke;


A bool variable can only be true or false - which is all you need in this case - ut you could just as easily use int Spoke;.
Then for the 'Talk to door interaction:
Code: ags

// Whatever dialogue you want to happen
Spoke = true;


And for the Interact, er, interaction:
Code: ags

if (Spoke == false) { // Player hasn't spoken to door yet, so it's locked
  player.Say("It's locked.);
  // Or whatever
}
else { // Player has spoken
  player.ChangeRoom(NewRoom);
  // Or whatever
}


I know what you're thinking ... Don't think that.

Buckethead

Thnx once again almighty Ashen!!  :D  I haven't been really filling in anything but I have gone throug various documents but didn't find what to do. Where is this sulution you gave located?  :)

Mikko

In most cases these codes actually aren't available exactly like this anywhere.

In my opinion the thing about scripting (or coding in general) is to have knowledge of the basic commands and then to have the ability of put them together to achieve your wanted result. After that it is much more easier to search and find answers to more complicated problems.

In this particular case you needed to know how to declare a variable and how to use if...else statements. These both are something you basically cannot avoid in any case of scripting.

For that reason I'd suggest that just for practise you should try to modify this code for example in these ways:

- player must talk twice to the door to get through
- player could enter every second time he/she has spoken to the door
- player needs to pick right dialog option to through
- player needs to pick two correct dialog options to go through
- make a counter that goes one upwards every time player tries to get in, but can't because of not talking to the door
- make a counter that goes from three to zero and after that the player is let through the door
- and other similar modifications

They don't make much sense, but they are something you can do quite easily, I think, and that should make variables and If...else statements easier for you. :)

Ashen

Exactly.
I don't think the solution to this specifically is mentioned  anywhere, although if you look around you'll probably find many similar things. But the basics of it are covered in those three articles I linked to - the first Wiki link explains how to create the variables, and the manual link deals with using them, in conditional statements. Beyond that, as Mikko said, it's just a matter of practice. (Making random modifications to the code to test yourself is a pretty good idea - just be sure you've backed up the original.) Browsing the Technical forums would help too: since variables and conditionals are used in most areas of scripting, virtually any random thread will give you an example of how to use them.
I know what you're thinking ... Don't think that.

Buckethead

Quote from: Mikko on Sat 30/09/2006 20:49:45
In most cases these codes actually aren't available exactly like this anywhere.



They don't make much sense, but they are something you can do quite easily, I think, and that should make variables and If...else statements easier for you. :)

I might try them. I'm pretty sure I can do them all now. I already knew how to use if, else statements and I've readed through varibles on wikki but just didn't get them. But now this problem is sloved I think I can go on with searching through it and do slove the problems I might have in the future.

Anyway... thnx alot , both of you  :) ;)

SMF spam blocked by CleanTalk