Korman - how to write python for puzzle code?

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

Korman - how to write python for puzzle code?

Postby ametist » Wed Sep 16, 2020 10:16 am

Me again, needing guidance ;) I have everything working in my age now, using xAgeSDLBoolSet, xAgeSDLBoolRespond, xAgeSDLBoolShowHide and xStandardDoor in the korman nodes.
I have an SDL file which saves the states of buttons and animations. Quite happy with it all so far :) . But I have saved the hardest work until the end - a
little puzzle. There are three buttons that should be clicked in a certain order, then a lever is operational, which then activates a door button so
the player can enter the interior of the age. The door can not be open without doing this.

As for now it can be solved by trial and error but the state is not saved so the player has to do it everytime he or she enters the age.

So, how would I do this? Reading the wiki let to me to beleive I should use some of the scripts that use a state list? If that is correct, is that
something that one declares in a python script?
User avatar
ametist
 
Posts: 319
Joined: Fri Dec 28, 2007 6:55 am

Re: Korman - how to write python for puzzle code?

Postby Tsar Hoikas » Thu Sep 17, 2020 11:50 am

I did a quick look and couldn't find any built-in script for what you're asking. I've got something drafted, but it's going to need a sample Age to go with it (and to be tested). I uh, also need to rewrite parts of the code to work on the ancient python versions that most Uru installs use :|. Anyway, all this to say you're not being ignored :geek: :geek:
Image
User avatar
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 2072
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: Korman - how to write python for puzzle code?

Postby ametist » Fri Sep 18, 2020 9:16 am

Thank you! Looking forward to that, will be great to have a sample age for puzzle-coding! I know you have a lot on your plate so I will wait patiently. :)
And I still have to test if the nodes I have will work multiplayer ;)
User avatar
ametist
 
Posts: 319
Joined: Fri Dec 28, 2007 6:55 am

Re: Korman - how to write python for puzzle code?

Postby Tsar Hoikas » Wed Sep 23, 2020 4:26 pm

Ok, here it is: KormanPuzzle01 an, uh, "official" puzzle sample Age.

This sample Age is a bit more detailed than the previous blends I've released in that it's, what I would consider, almost worthy of being released as a standalone Age for people to play. The puzzle is quite real - it's integrated into the environment, and you get a reward for solving it. I hope everyone who decides to take a look will play the Age to completion before snooping in the blend file too much :). I'd recommend playing on Destiny - Mystler has already put the age and SDL files up on the server - because there are some bugs with the sound effects in PotS that I didn't feel like debugging. Those bugs make it difficult to know if you're completing the puzzle correctly.

Anyway, some detail on how the puzzle is set up... In the Age, there are five buttons that have to be pressed in a certain order to open the door. This is accomplished with two scripts.

First, the new script that I wrote for this type of puzzle: xAgeSDLBoolActivatorComboSet.py. You'll want to look at the node tree "PuzzleBrain" for this one. It needs three SDL variables in the age -- one to track if the puzzle is solved ("solvedVariableName"), one to track if a button is being pressed ("butsInUseVariableName"), and on to track the number of correct button presses ("numCorrectVariableName"). You have to supply the combination to the script as a comma separated list of buttons. Note that the buttons start at "0" and increase in order that you've hooked them up to "ID: 7 Act Buttons". Optionally, you can play a responder when a button has been pressed -- the script will run the state ID corresponding to the ID of the button that has been pressed.

The new script only handles interactions with the buttons and setting the solved/unsolved puzzle state. If you want to open a door, play a sound effect, or whatever... You'll need to use xAgeSDLBoolRespond.py. The "solvedVariableName" will be set to true when the puzzle is solved and false when not solved. I did make a small edit to this script so that responders could be "fastforwarded" by other scripts. This is done in the node tree "PuzzleSolved". Also, you'll notice that the sound-based feedback is done in the "PuzzleFeedbackSfx" tree using the same script. There are only two forms of feedback, so I'm taking advantage of the fact that an integer (eg 0, 1, 2, etc) implicitly becomes the boolean "false" when the value is "0" and "true" when the value is not "0". Meaning you get a nice rejection sound when pressing the wrong button. You could do a more precise feedback effect with something like xAgeSDLIntStateListResp.py.

If these scripts do what you need, I'll submit them to diafero for inclusion in the OfflineKI so everyone can use them more easily :).
Image
User avatar
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 2072
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: Korman - how to write python for puzzle code?

Postby ametist » Wed Sep 23, 2020 10:18 pm

Fantastic! Now I will have to install Destiny so I can play the age properly ( I have not considered building for moula so have not needed Destiny), so I will come back with comments about the KormanPuzzle01 asap.

Thank you! :)
User avatar
ametist
 
Posts: 319
Joined: Fri Dec 28, 2007 6:55 am

Re: Korman - how to write python for puzzle code?

Postby ametist » Sat Sep 26, 2020 7:34 am

After a day of struggling with Destiny I could not wait so I decided to export KormanPuzzle01 to URUoffline and it is really a little age in itself! Quite dramatic in fact :o . I had a good laugh while reading the journal though :lol: and I managed to solve the puzzle by using the clever clues in the age. There are also quite a few other things in the blend file that can benefit an agewriter to see and learn from.

Then I looked at the node trees and I understand how they are set up. That new file of yours xAgeSDLBoolActivatorComboSet.py is what I need, and I think it is very useful for everyone wanting to set up a puzzle. Together with xAgeBoolRespond.py
so many actions can be done. It was quite fun to read through those python scripts as well, some of the comments :lol:

So can I use those scripts by extracting your .pak and point my python nodes to those rather than to URUoffline - python - src (which I do now) for the time being? Or would it be better to wait until diafero have had time to update? Edit: A little bit of thinking and I figured it out 8-)

Thanks again!
User avatar
ametist
 
Posts: 319
Joined: Fri Dec 28, 2007 6:55 am

Re: Korman - how to write python for puzzle code?

Postby ametist » Thu Oct 08, 2020 8:19 am

I have successfully built the node trees with xAgeSDLBoolActivatorCombo.py and xAgeSDLBoolRespond.py and tested the ages. I am now ready to send them to diafero for upload to DI.

So when you have time -
Tsar Hoikas wrote: If these scripts do what you need, I'll submit them to diafero for inclusion in the OfflineKI so everyone can use them more easily :).


:)
User avatar
ametist
 
Posts: 319
Joined: Fri Dec 28, 2007 6:55 am

Re: Korman - how to write python for puzzle code?

Postby Tsar Hoikas » Thu Oct 08, 2020 11:53 am

Image
User avatar
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 2072
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest