Post new topic    
Liquid Metal Slime
Send private message
scripting for a puzzle 
 PostSun Oct 09, 2011 2:45 am
Send private message Reply with quote
How would I do this:

As part of a puzzle, there would be 4 rooms. In each of these 4 rooms are 4 items. The player must pick up the items and then set them in the correct "box" in the correct room.

For instance: item 1 goes in room 4, item 2 goes in room 3, item 3 goes in room 1, item 4 goes in room 1.

However, the player will only know if they have made the right choice once all the items have been placed. And if the correct sequence hasn't been placed, they could pick up the items and rearrange them.

Here's what I've figured out:

I've made 4 items. When in the player's inventory, they activate 4 separate tags. When the player uses one of the "boxes" it brings up a custom menu that lets them select one of whichever one of the items they have in their inventory.

After that, I'm stuck. Presumably the menu would activate a script which would remove the item from the inventory. But how would it change the NPC "box" to show the item inside it? And how would the player be able to retrieve the item if they wanted to rearrange them? And how would the game know when all the items are in the right boxes?

Any idea on how I can structure this puzzle to work? It seems like a monumental mess.
Metal Slime
Send private message
 
 PostSun Oct 09, 2011 1:46 pm
Send private message Reply with quote
just wait for awhile, i'm creating a visual aid for you.
Hey, I just met you, and this is crazy... So here's some lunchmeat... Sandwich, maybe?
 
 PostSun Oct 09, 2011 1:48 pm
Send private message Reply with quote
I'm far too lazy to actually write it out, but hopefully I can step you through. I will pretend the items are string for the sake of clarity.

STEP 1: We need variables.
We need variables for the items.
We need variables to see if an item is in the box.
We need variables to see if the correct item is in the box.

STEP 2: There's a script that'll be run when the player interacts with a box.
It has to check to see if variable [iteminbox#] is true.
If [iteminbox#] is true, then the player has already put something in the box and it needs to be taken out. So, we use [get item (item:string1)].
If [iteminbox#] is false, it runs a menu.

STEP 3: We need a menu.
Simply enough, we need a menu that will ask "Which string do you want to put in this box?"
When a string is selected, it goes to another script. One for each.

STEP 4: Put the item in the box.
We're at [npc:box3] and we just said "put string 1 in this box".
Use [delete item (item:string1)] to erase it from your inventory.
Run an if/then script to see if this is the correct item for this box. If yes, activate that variable for this box [box3correct]. If not, just activate the variable that says there's something in the box [box3full].
Use [alter NPC (npc:box3, npcstat:picture, 5). This assumes that npcs 1, 2, 3, and 4 are your boxes' default. 5, 6, 7, and 8 are the "item in this box" look. Or you could just use two. Up to you. We just changed the box's look.

STEP 5: Run a quick check at the end of every one of these scripts.
We're looking for if [box1correct] AND [box2correct] AND [box3correct] AND [box4correct]. If yes, trigger endgame for the puzzle. If not, just have it exit the script.


It's not that complicated, but since I don't feel like making 4 items and boxes and a menu and testing, I'm leaving that to you. However, I may just do that if you still need help/I feel like it. As I haven't written the script yet, I don't know if it'll work, but the logic's there, so maybe. This may not be the most efficient way, but it should work. Let me know if it does!
Metal Slime
Send private message
 
 PostSun Oct 09, 2011 3:29 pm
Send private message Reply with quote
you can do it his way, or you can follow the example i'm about to send you. i at least know that my way works since i tested it myself. let me know if this is what you were looking for.
Hey, I just met you, and this is crazy... So here's some lunchmeat... Sandwich, maybe?
Liquid Metal Slime
Send private message
 
 PostTue Oct 11, 2011 12:28 am
Send private message Reply with quote
Actually, J_Taylor and mjohnson, your methods are both very similar in concept.

That being said, thanks mjohnson for doing all that work for me. I should be able to use these scripts with very little editing. I'm going to have to take some time to pull it apart and make sure I understand everything though.

In any case, great work. I can't thank you enough.
Metal Slime
Send private message
 
 PostTue Oct 11, 2011 12:45 am
Send private message Reply with quote
no problem, it was a lot like the bookcase puzzle in my game, only slightly expanded. i was feeling pretty bored anyway. Grin
Hey, I just met you, and this is crazy... So here's some lunchmeat... Sandwich, maybe?
Display posts from previous: