Code - Lock

Started by td, Thu 29/09/2005 20:09:36

Previous topic - Next topic

td

Hallo from Russia!
Someone, please ansver: how can i make code-lock in the game. For example i press 1,2,3 hotsots - and door is opened!

DoorKnobHandle

You will have to use variables. I will not explain the whole topic here - just some helpers:

Basically this is one way:

- Add "bool spot1, spot2, spot3" to your script.
- Initialize those variables as "false".
- When the player clicks on a hotspot ( for example the first ), then set its according variable from "false" to "true" ( so "spot1 = true;" ).
- Then check if all variables are true -> "if ( spot1 && spot2 && spot3 )" then open the door...

You could do this in a nicer way using simple arrays. Just define "bool spot_activated[3];" and then set for example "spot_activated[1] = true".

Anyways, read up on variables in the manual or search here for more information.

td

#2
Thanks DKH for spending time! OF cause i can search forum and AGS help but it all in english! So its more difficult then just asked...
RESPECT+  :)

But your second easy way (WITHOUT scripting) is:
123 my hotspots
1>any click n hotspots>WHAT SHALL i do then?

Just i dump....:)

Edited by Ashen, to remove double post.

esper

#3
Okay, we'll wait for you while you're dumping... But you didn't have to tell us about it.

You will shortly get slashed by a moderator, I deem, since you got all crazy and posted this in the other tech forums...

Listen, just do this... it won't even require any scripting: if you click on hotspot 1, then make such and such a variable equal 1. If you click on hotspot 2 and variable such and such equals one, make it equal two, otherwise make it equal zero again. When you click on hotspot 3, and if variable such and such equals two, open the door, otherwise set the variable back to zero...

you can do al that using only the interaction menu, no need to use any scripting at all...
This Space Left Blank Intentionally.

td

Thaaanks...now i try to undarstand what did u wrote ...:))

Ashen

What esper said was:

In the interaction editor, make a variable (e.g. Codelock)

Then, for the first hotspot you want to click add this interaction (i.e. if the 'code' is 2,3,1, this will be in hotspot 2):

        Conditional - If variable is set to a certain value (Codelock, 0)
          Game - Set variable value (Codelock, 1)
          Stop running more commands

Then, right-click the Conditional - If variable is set to a certain value (Codelock, 0)  and choose 'Add action after this':

        Game - Set variable value (Codelock, 0)

Then do the same for the second hotspot, so it looks like:

        Conditional - If variable is set to a certain value (Codelock, 1)
          Game - Set variable value (Codelock, 2)
          Stop running more commands
        Game - Set variable value (Codelock, 0)

And for the third:

        Conditional - If variable is set to a certain value (Codelock, 2)
          ...
          ...
          ...
          Stop running more commands
        Game - Set variable value (Codelock, 0)

Replacing the '...'s with whatever you need to show the door opening (e.g. animate the door object to show it opening).
I know what you're thinking ... Don't think that.

td

Big "Respect+" Ashen! U know u write much more understandably then Espen!  I try do this by second day but it dont work! :(
1) ?Variable=?Codelock=?Hotspot - right???
2) If yes why i can't change Value in "Game - Set variable value". Value allways=1 and Variable allways=Gobal 1
3) WHAT global different between Variable and Value?
Thaaaanks!

esper

#7
It's ESPER, cap'n.

Actually, I am a published author. I only wrote the way I did because I, unlike Ashen, I guess, don't have time to sit and figure stuff out for you. I learned the AGS interaction menu without even using the manual: I just sat back and screwed around with it until I figured out what did what. When I wanted to get a little more involved, I started using the manual. I wrote a very basic outline of what to do, but apparently, even though Ashen told you EXACTLY what to do, you still can't get it.

Now, listen close, because I'm only saying this once, and if you don't get it, you really don't need to be using AGS.

OPEN AGS
okay, we'll skip that.

Go to the room in which the buttons are. On the left side of the screen, click Room Editor, and then AREAS

In the box in the top left of the display area, where it should say "walkable areas" right now, click that and make it say "HOTSPOTS."

Use the buttons that look like they are from a paint program in the top center of the screen to draw over the first button, thus making it a hotspot.

Next to where it says EDITING:1 click the up arrow to make it say EDITING:2. Draw over the second button. It will be in a different color.

Repeat the last step, making it say EDITING:3 and drawing over the third button. Repeat again, making a EDITING:4 and draw over all the rest of the buttons.

Click INTERACTIONS.

Double click ANY CLICK ON HOTSPOT

From the Pulldown Menu select Game: Set variable Value

Click the top CHANGE button, and in the box that comes up click EDIT VARIABLES

In the bottom of the new box that comes up, click New Variable

Type in the name of the variable. We'll call it CODELOCK. Hit enter.

Click OK. From the pulldown menu, select CODELOCK. Click OK again. Click the bottom CHANGE button.

Make sure the radio button for VALUE is selected, and make sure the text in the box says 0 (zero).

Click OK. Do it again.

Click the down arrow next to the EDITING button to make it go back down to 1.

Click Interactions.

Make it say the following, using the examples of how to operate the Interactions menu I just used.
Ã,  Ã, Conditional - If variable is set to a certain value (Codelock, 0)
Ã,  Ã,  Ã, Game - Set variable value (Codelock, 1)
Ã,  Ã,  Ã, Stop running more commands

Click the same up arrow as before, and make it say 2. click Interactions, and do this:
Ã,  Ã, Conditional - If variable is set to a certain value (Codelock, 1)
Ã,  Ã,  Ã, Game - Set variable value (Codelock, 2)
Ã,  Ã,  Ã, Stop running more commands
Ã,  Ã, Game - Set variable value (Codelock, 0)

Click the same up arrow as before, and make it say 3. click Interactions, and do this:
Ã,  Ã, Conditional - If variable is set to a certain value (Codelock, 2)
Ã,  Ã,  Ã, Game - Set variable value (Codelock, 3)
Ã,  Ã,  Ã, Stop running more commands
Ã,  Ã, Game - Set variable value (Codelock, 0)

Then, when codelock=3, this means the door is open. I'm not going to bother telling you how to do that, since I haven't seen your game and don't know how it works. Like Ashen said, right there (after you set the variable to 3) you can do interactions that will show the door opening. If you need to close the door again, don't forget to set that variable back to 0.

To answer your questions:

1. Not quite.
2. Make sure A) you have the right radio button checked. When you click the top CHANGE button, the top radio button should be checked. When you click the bottom CHANGE button, the bottom radio button should be clicked.
3. Don't screw around with globals yet. Just do exactly what we told you, and it should work.

Sorry if those don't answer the questions, but you don't write so understandably yourself.

Ã,  Ã,  Ã, Do I get big "respect++" now???




This Space Left Blank Intentionally.

td

WOW!!! I don't know how :) but it WORK! 1,2,3- action!
Actually i stay far from scripting and programming (im more the painter and musicmaker) so i have problems with logical thiking (princile of interrection values and variables). Besides i know english on middle level.
Thank u all for spending time for me (Esper: Respect ++:))

esper

Thanks, pal. Hope I wasn't too harsh on you, and I hope the game comes out alright.
This Space Left Blank Intentionally.

Wretched

Suggest you use a different lock code in the game as we all know what it is now ;)

Gilbert

Well, but still, you can always assume 90% of people who download and play a game won't read this specific thread. :=

SMF spam blocked by CleanTalk