Solution parser python needed

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

Solution parser python needed

Postby Render » Mon Apr 08, 2013 2:08 pm

Hi again,

Sorry to keep bugging, but I desperately need a pythonfile to send a solution from a puzzle to a responder as well as a reset.
Trying myself, but can't succeed on my own.

What I need is this:
python file that reads 5 Integer SDL values and compares them with the solution values if all 5 are correct, start solution responder.
This is not an xSimplePanel, so I can't use that (I think).
My SDL variables are called:
R1Pos, R2Pos, R3Pos, R4Pos and R5Pos

The second thing i'd like to do is to reset forementioned SDL variables to zero when the activator buttons have been pressed a number of times.
I monitor this via the SDL Integer variable RButton.

If someone could be so kind as to tell me how to set up the python, I can work out the Alcscript myself.

As usual, thanks in advance.
User avatar
Render
 
Posts: 55
Joined: Thu Jul 28, 2011 7:37 am

Re: Solution parser python needed

Postby Render » Wed Apr 10, 2013 5:32 am

Anybody??
User avatar
Render
 
Posts: 55
Joined: Thu Jul 28, 2011 7:37 am

Re: Solution parser python needed

Postby D'Lanor » Wed Apr 10, 2013 11:25 am

I could probably make something. Give me a few days.

One question: Are you already setting the variables elsewhere?
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Solution parser python needed

Postby Render » Wed Apr 10, 2013 2:30 pm

Yes I am, I've got the Rpos variables set through AgeSDLIntChange and managed to tweek the IntRespList to handle the responders, now I only need the solution script.
By the way, you can leave the reset out if that is to hard to make, as I don't think I realy need it
(could always do it with another button rather than force it.)

I did notice that the kadish pillar puzle has the solution within the python file itself like this:
Code: Select all
    def CheckSolution(self):
        ageSDL = PtGetAgeSDL()
        if ((ageSDL['pheight01'][0] == 1) and ((ageSDL['pheight02'][0] == 4) and ((ageSDL['pheight03'][0] == 1) and (ageSDL['pheight04'][0] == 2)))):
            print 'kdshPillarRoom: Puzzle solved. \n'
            ageSDL['PillarRoomSolved'] = (1,)


In my case this would end up being if ((ageSDL['R1Pos'][0] ==.... and etc. upto R5Pos either hardcoded or through aclscript variables (strings? or int) for flexibility and reuse.
That much I understand, what I don't know is what to do with onserverinit and so on.

As usual, I would be grateful if you could help me out, sofar you have always managed to get me the right files or solutions.
Thanks
User avatar
Render
 
Posts: 55
Joined: Thu Jul 28, 2011 7:37 am

Re: Solution parser python needed

Postby D'Lanor » Thu Apr 11, 2013 12:03 pm

A reset should be easy. I can make it optional if you like.

One more thing: Since IntRespList receives SDL changes at he same time as the solution parser the solution responder will try to kick in at the same time as well. It won't wait for the IntRespList responders to finish, unless we add a delay (the same goes for the reset). I will make a Python timer for this with a variable delay which you can set through an Alcscript parameter. OK?
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Solution parser python needed

Postby Render » Thu Apr 11, 2013 12:13 pm

That would be perfect, thanks!
User avatar
Render
 
Posts: 55
Joined: Thu Jul 28, 2011 7:37 am

Re: Solution parser python needed

Postby D'Lanor » Fri Apr 12, 2013 10:13 am

Here is the python file.
Rendercity1SolutionParser.zip
(2.61 KiB) Downloaded 506 times

Let me know if you find any bugs.

And this is an example alcscript:
Code: Select all
          - type: pythonfile
            name: SolutionParser
            pythonfile:
                file: Rendercity1SolutionParser
                parameters:
                  - type: string
                    value: "R1Pos,R2Pos,R3Pos,R4Pos,R5Pos"
                  - type: string
                    value: RButton
                  - type: int
                    value: 8
                  - type: string
                    value: "1,2,3,4,5"
                  - type: float
                    value: 4.4
                  - type: bool
                    value: true
                    #solution responder
                  - type: responder
                    ref: <name or $tag>
                    #backwards responder
                  - type: responder
                    ref: <name or $tag>

The lists are in parameters 1 (SDL names) and 4 (solution values). They can be of any length as long as they are equally long. SDL name 1 corresponds to solution value 1 etc.

The backwards responder should be used to reset the solution responder. It is optional and whether you need it or not depends on what exactly the responder does. If it is some kind of door opening animation you'll probably need that backwards responder in order to avoid multiplayer sync issues.
I'll give you an example: Once the puzzle is solved and someone messes with the buttons again the solution code is no longer valid. However, without a backwards responder the puzzle reward remains in its solved state. On the other hand, new explorers who link in will see the puzzle reward in its unsolved default state, because their client checks the solution code on arrival. And since that code is now wrong the solution responder refuses to run for them.

A few words of caution about the reset. If the responders controlled by IntRespList contain avatar animations the SDL reset will cause all of those to run and warp the avatar around like crazy. Unfortunately that is how IntRespList works.
If this happens we can fix it by adding a new SDL tag 'skipavatar' to IntRespList. IntRespList already has a 'fastforward' tag, but that will skip the entire responder to its end state.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Solution parser python needed

Postby Render » Fri Apr 12, 2013 11:22 am

Great! I will be trying this over the weekend, will report back soon.
Thanks again D'Lanor
User avatar
Render
 
Posts: 55
Joined: Thu Jul 28, 2011 7:37 am

Re: Solution parser python needed

Postby Render » Sat Apr 13, 2013 5:54 am

Quick update, not tested everything yet, but the solution parser is working like a charm.
Still need to script the reset, but this is kind of complex, so it will take a while.
Also haven't got my puzzle completely build, but as said, so far all is working as intended.

Will let you know when i've got it all tested.

Thanks!
User avatar
Render
 
Posts: 55
Joined: Thu Jul 28, 2011 7:37 am


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron