Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / ctm's algorithms: puzzle script

Author
Message
ctm
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location:
Posted: 27th Jun 2010 13:48 Edited at: 27th Jun 2010 15:33
I found this thread from Mr Game with a very interesting question about using variables for a combination puzzle:

http://forum.thegamecreators.com/?m=forum_view&t=166053&b=23

This kind of puzzle gives the player only 2 choices (left/ reight) which can get combined to a combination like: 3 left, 2 right, 1 left.

Ingame this can be done with sundials (like MrGame did it) or buttons or switches or the keyboard.

My idea for a easy solution was to write the combination as a binary code like 000110.
"0" would stand for a "left" and "1" for a "right" choice.

To be able to use that "code" in a script you have to make a decimal number out of it:
In my example above the code "3 left, 2 right, 1 left" is: "000110"
To get a dezimal number you have to delete all zero at the left side of the code.
So the code is : 110

What does the script do to compare the player input with the combination?

It adds, depending of the current number of player inputs a value to a variable and after 6 inputs it compares the value of the variable with the wanted combination.

Example:
The used variable starts with a value of 0.
The players first choice is "right" -> script adds 100000 to the variable.
Second choice is "left" -> nothing happens.
Third choice is "right" -> script adds 1000 to the variable.
Choice 4-6 is "left" -> nothing happens.

So the variable has the value 101000 after 6 player inputs.

The wanted combination was 110. So the players input was incorrect.

Why this way?
Because if you want to use the script for more than one puzzle the only thing to change is the combination.
No need the change lots of lines of code.

The script is not meant for drag and drop usage because i used rawtext as placeholder for other actions like rotation, or switch animation etc..

For testing it can get used as is (works only with vanilla FPSC v.1.16).
The defined keys for "left" and "right" are the N and M keys.

The script:



As you can see the only thing to do to change the wanted combination is to set a other value in 2 lines in state=70.

Commented version:


Hope my text is understandable...i am not a native english speaker.
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 27th Jun 2010 19:00
It is too bad that nobody had responded to Mr Game. I was still in the process of finishing up my mod.

This is good example and thanks for sharing. I remember some time ago -- before variables were introduced to FPSC -- that I had created a script for a combination type lock. The person had to enter in the correct number combination. However, now with variables, this makes it a lot easier.

Another individual had also done the same thing. The amount of script lines were incredible which made it complex.

Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 28th Jun 2010 00:31 Edited at: 28th Jun 2010 00:40
Quote: "I found this thread from Mr Game with a very interesting question about using variables for a combination puzzle:"

Interesting

Quote: "My idea for a easy solution was to write the combination as a binary code like 000110.
"0" would stand for a "left" and "1" for a "right" choice.

To be able to use that "code" in a script you have to make a decimal number out of it:
In my example above the code "3 left, 2 right, 1 left" is: "000110"
To get a dezimal number you have to delete all zero at the left side of the code.
So the code is : 110"

Very interesting (I love playing with binary)

Quote: "It is too bad that nobody had responded to Mr Game."

You are right.
I don't know how I missed that thread, because I would have definitely commented.

Quote: "I remember some time ago -- before variables were introduced to FPSC -- that I had created a script for a combination type lock. The person had to enter in the correct number combination. However, now with variables, this makes it a lot easier...Another individual had also done the same thing. The amount of script lines were incredible which made it complex."

LOL ...talk about complex...
I made a combination lock before we even had scancodekeypressed=x
I used the ENTER key (plrusingaction=x) and the timer to set the 3 numbers for the combination.
As you held down the enter key the timer was ticking, and advancing states incrementally based on timer.
Each state removed the old display number for that digit and would show the new one, so it had the visual display built in without variables.
When you let off the key in any state, that is what set the value for the number by hopping to the next digit.
So, if you hop out at the wrong state it didn't matter what you entered next.
If you hop out at the right state then it went to a state where it would matter what you entered next.
Those three states with the correct hops for the three digits were what determined the set combination.
To change the combination then you change the bad and good hops.
Three correct hops (one for each digit) and you made it to the magic state that unlocked the door.

It may sound funky (and yes it was long too), but believe it or not, it actually worked well.

   Conjured Entertainment

 WARNING: Intense Madness
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 28th Jun 2010 01:51
Quote: "I made a combination lock before we even had scancodekeypressed=x"


As far as FPSC is concerned, you are as old as dirt.

I can't imagine not having at least scancodekeypressed!

Shadowtroid
14
Years of Service
User Offline
Joined: 23rd Dec 2009
Location: nope
Posted: 28th Jun 2010 04:17
Quote: "I can't imagine not having at least scancodekeypressed! "


lol

Amen to that. I've come in pretty recently to the game, so I have the liberty of not knowing the horrors of lack of scripting commands.

Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 28th Jun 2010 05:06 Edited at: 28th Jun 2010 05:10
Quote: "As far as FPSC is concerned, you are as old as dirt."

Yeah, my join date is like 10 days prior to the release of FPSC.
And yes, I discovered TGC because of it.
And yes, I will stick around until the end. (which will probably be mine not FPSC's)


Quote: "I can't imagine not having at least scancodekeypressed!"

Scancodekeypressed was was added in v103 when FPSC was about a year old, but v109 gave us the variables in FPI.
The user variables are what enabled me to really work some FPSC magic with scripting.

His binary example above shows how easy it is to get rid of the zeros on the left of the string just by taking it literally as a number.
Cool stuff really, but what is even cooler is that his join date is older than mine.

   Conjured Entertainment

 WARNING: Intense Madness
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 28th Jun 2010 06:55
Quote: "Cool stuff really, but what is even cooler is that his join date is older than mine"


I didn't notice that. So, he's older than dirt.

Kudos to you both.

ctm
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location:
Posted: 28th Jun 2010 11:37 Edited at: 28th Jun 2010 12:42
Quote: "So, he's older than dirt"

lol
I joined the forums after downloading the demo of the Early Adopter version of FPSC.
Was totally enthusiastic about the easiness of making a game with this software

Scripting was hard because of the limitations...only state changes and activated=x were there.
Scripts looked like that in the beginning:

3 switches to open a door

Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 29th Jun 2010 00:27
Quote: "Scripts looked like that in the beginning:"

Man my old scripts are on my old PIII 1.2 Ghz computer... lol ... the Hard Disc Drive is locked up on that. (I tried firing it up just the other day)
I had forgotten all about those old script (like the one I mentioned) even being on there, so now I have to work on that drive.

   Conjured Entertainment

 WARNING: Intense Madness
ctm
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location:
Posted: 29th Jun 2010 02:00
Yes, lots of stuff gets lost when you change to a new PC...happend to me too.
But sometimes it's maybe better to forget the old stuff and make it new and better...especially here. Some of the old FPSC scripts are looking realy outdated today...even though they are still working
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 29th Jun 2010 08:06 Edited at: 29th Jun 2010 08:13
Quote: "Some of the old FPSC scripts are looking realy outdated today...even though they are still working "

Yeah, my poor little add-on pack is so outdated.
Come to think of it, those scripts were pre-scancodekeypressed!
lol
That's right people, dont' buy it! (unless you're into 'antique' scripts)

Quote: "sometimes it's maybe better to forget the old stuff and make it new and better"

You're right, I should re-write those jewels.

   Conjured Entertainment

 WARNING: Intense Madness

Login to post a reply

Server time is: 2024-11-24 21:47:45
Your offset time is: 2024-11-24 21:47:45