Scripts / Script for a series of activations to be able to progress?

Author
Message
CorzaX24
9
Years of Service
User Offline
Joined: 22nd Dec 2015
Location: Melbourne, VIC
Posted: 17th Jan 2016 12:17
Hello,

I'm curious if anyone knows how I would script in such a way that would require the player to activate multiple, let's say 3, switches in order to progress.

-Activate 3 switches
-Each time, prompt appears how many switches left
-After final switch, another entity appears at another location
-Player cannot progress forward pass a locked door until the above process has been done

Ideas?

Thanks in advance
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 18th Jan 2016 21:00
Attach this script to the door:



Attach this script to each switches:



In action - crappy quality video, but it does the trick.




In the video I'm spawning a barrel, remember set "spawn at star=no" in your item properties (those that you want to spawn).
hth

3com




Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
CorzaX24
9
Years of Service
User Offline
Joined: 22nd Dec 2015
Location: Melbourne, VIC
Posted: 20th Jan 2016 12:48
Ah that's awesome man, great job! Exactly what I was looking for.

Now, if I wanted to expand on this more -

- Instead of the switches being actual switches, what if they were tall stones?
- You have to activate each stone in a certain order
- Each time a stone is activated, it start to glow (or something of the sort)

Your expertise is greatly appreciated!

Thanks
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 21st Jan 2016 12:46
Quote: "- Instead of the switches being actual switches, what if they were tall stones?"


So attach script to stones instead of switches

Quote: "- You have to activate each stone in a certain order"

Assuming you've this order: (1,3,4,2), meaning you'e 4 stones to activate as follow:

1- stone #1
2- stone #3
3- stone #4
4- stone #2

Well, here we can work with arrays, but a easiest way for you, I thought, as follow:

Declare global variable, named let's say, " stoneNum", and make than only each stone passing their value to the var.

Example: only stone #1 can pass 1 as value to " stoneNum" variable.
Stone 4 check if var is equal to 1, before passing their value (2), and so on.

Quote: "- Each time a stone is activated, it start to glow (or something of the sort)"


Here you can modeled the 2 assest, one as normal and another shiny, to change them when necessary.
Or place some decal (light?) closest to the stone, make it spawn at start = no, and spawn it when necessary.

Here you've a good guide for starting: http://steamcommunity.com/sharedfiles/filedetails/?id=398177770&insideModal=1

If you've some question do not hesitate to ask here, someone here can help'u, even me.

If so, please post you script (what you've so far), and use the code tags (LUA).

hth

3com

Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
TazMan
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 20th Jan 2011
Location: Worldwide Web
Posted: 21st Jan 2016 18:01
Not to knock 3coms great work, I saw you second post and have been working on a script to allow as many or as few 'switches / stones' as needed. It counts how many 'switches / stones' you put down with the same name and the script attached and uses that as the 'switches / stones' count.

At the moment it will only work on one door but with a bit of work it can be adjusted so that you can put multiples sets up. All you need to do is call the entities that are in the same set the same name with the exception of the switches having a number on the end of them.

Any Animations that would be needed for the 'switches / stones' would have to be added of course. I have just added that they have been activated when doe in order..

IE BigDoor01, BigDoor02 etc... and the door would obviously be BigDoor.

You would put this on the door:


and this on each 'switche / stones':


I tried this on 4 switches and it worked great
HP Pavilion Laptop, AMD A8-4555M APU with Radeon(tm) Graphics HD Graphics 1.6GHz, 8GB Memory, 64 Bit Operating System (Windows 10), 1 TB Hard Drive.

I've got something to say - It's better to burn out than fade away.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 21st Jan 2016 19:36
Someone has been studying thoroughly.

Great job Taz!

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Mariokiki
16
Years of Service
User Offline
Joined: 22nd Oct 2008
Location:
Posted: 22nd Jan 2016 01:01
Hi all,

I propose a similar code that I use in my game...
4 switches allow to open a door with the condition that they are activated in a specific order.

For my game, I used colored blocks (red, green, blue and yellow) with a light system on each switch when activated.
The door automatically opens when the code is correct (in my game, it's a grid that rises like a castle door).
If the order is not correct, a message appears at the door and switches are reset and the lights are switched off.

Principe of the test scripts :
Each switch uses a script called "serrure" from 1 to 4.
The door uses a script called "porte_4serrures".
The code corresponding at the opening sequence is defined in this script with les values of "serrure01, serrure02, serrure03, and serrure04".
example : opening order is 2,4,1,3 : serrure01 = 2 serrure02 = 4 serrure03 = 1 serrure04 = 3

When the player touches a switch, this one is activated.
example :
switch 03 is the 1st activated, the value is : serrure03 = 1
switch 04 is the 2nd activated, the value is : serrure04 = 2
switch 02 is the 3rd activated, the value is : serrure02 = 3
switch 01 is the 4th activated, the value is : serrure01 = 4

When the four switches are activated, the player goes to the door.

A message appears to indicate if the opening sequence of the switches is correct or not.
If the opening order is incorrect, the switches are reset and the player can start again.

The only limitation is the sequence order is fixed in the door script, but it might be enough for what you want to do ?
Be indulgent, it's one of my first code I share...

Attachments

Login to view attachments
PM
Mariokiki
16
Years of Service
User Offline
Joined: 22nd Oct 2008
Location:
Posted: 22nd Jan 2016 01:17
Sorry , small mistake in the explanations...

example : opening order is 2,4,1,3 :

serrure01 = 3 => 3rd position
serrure02 = 1 => 1st position
serrure03 = 4 => 4th position
serrure04 = 2 => 2nd position

following the text is correct... sorry !!!!
PM
Isagabe
10
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 24th Jan 2016 09:48
You guys are too GOOD. Thank you. This has helped me understand a few things. (I hope).
CorzaX24
9
Years of Service
User Offline
Joined: 22nd Dec 2015
Location: Melbourne, VIC
Posted: 26th Jan 2016 10:25
Amazing work guys, very much appreciated!
PM

Login to post a reply

Server time is: 2024-12-22 12:47:40
Your offset time is: 2024-12-22 12:47:40