Converting Python Scripts to meet PEP-8 (and bugs)

Announcements and discussion regarding any projects related to Cyan Worlds' Plasma Engine including (but not limited to) CyanWorlds.com Engine, Drizzle, OfflineKI, PyPRP, and libHSPlasma.

Re: Converting Python Scripts to meet PEP-8 (and bugs)

Postby johnsojc » Sat Aug 10, 2013 12:24 pm

And the winner is:

plate = resp.value[0].getSceneObject().getResponderState()

This is in tldnSlavePrisonDoors.py in the IEvalPlateAndPaddles section. Testing revealed that this is returning values that do not match the "supposedly" corresponding values for the pressure plates in the AgeSDL. The SDL values might be correct but this routine returns erroneous values that give a mismatch between the plates and paddles.

I'm not sure how to proceed at this point. I don't know how to figure out which sceneobject is which or know why Cyan wrote the routine this way. It could probably be rewritten to just use the AgeSDL (brute force method.. ugly, but it works).

The only other thing is purely cosmetic... getting the plates the SDL says are depressed to appear depressed.

EDIT: replacing this statement with one to use just the SDL variables seems to work... I can now open and close the gate using the levers. I need to test more to see if anything else breaks because of the change.

fix: plate = ageSDL[padSDLToplateSDL[PadSDL]][0]
Note: this fixes the paddles but does not handle you stepping on a plate that is supposed to be already depressed. This breaks the game. Stepping on a plate that is not already depressed causes the inner doors to close but stepping off makes them open again. Now I know why they tried to use responder states.
Last edited by johnsojc on Sat Aug 10, 2013 1:10 pm, edited 1 time in total.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8 (and bugs)

Postby Acorn » Sat Aug 10, 2013 1:09 pm

johnsojc wrote:And the winner is:

plate = resp.value[0].getSceneObject().getResponderState()

EDIT: replacing this statement with one to use just the SDL variables seems to work... I can now open and close the gate using the levers. I need to test more to see if anything else breaks because of the change.

fix: plate = ageSDL[padSDLToplateSDL[PadSDL]][0]



sounds encouraging...thanks for all the blood, toil, tears and sweat!
Image
Acorn
 
Posts: 697
Joined: Sun Feb 26, 2012 9:56 am

Re: Converting Python Scripts to meet PEP-8 (and bugs)

Postby johnsojc » Sat Aug 10, 2013 1:13 pm

Don't thank me yet. Refer to edit I made above your post. This fixes one problem but not others. (Nothing is ever easy, is it?)

I'm toying with an idea to break up the part of the code dealing with responders into two parts: one to handle someone throwing a switch (use AgeSDL values), and one to handle the plates (responder states). If there is some fundamental flaw in using responder states, then I don't know how to solve the problem.
Last edited by johnsojc on Sat Aug 10, 2013 1:26 pm, edited 1 time in total.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8 (and bugs)

Postby Acorn » Sat Aug 10, 2013 1:23 pm

johnsojc wrote:Don't thank me yet. Refer to edit I made above your post. This fixes one problem but not others. (Nothing is ever easy, is it?)


Hopefully, though, you're taking more steps forwards than steps back. ;)
Image
Acorn
 
Posts: 697
Joined: Sun Feb 26, 2012 9:56 am

Re: Converting Python Scripts to meet PEP-8 (and bugs)

Postby johnsojc » Sat Aug 10, 2013 3:18 pm

Postmortem on Teledahn.

Sad news is that the original code works exactly as it's supposed to. As long as you do not leave the Age while you are solving the prison puzzle, it works fine. As soon as you leave and return, the state of the plates and weights you put on them become indeterminate. That's what led me to the previous conclusion concerning the responder states. While testing, I would leave and return over and over after making little tweaks to the code. Each time I did this, I broke the puzzle requiring me to resolve it from scratch. Flipping a switch without resetting the plates is what gave me the bad values from plate = resp.value[0].getSceneObject().getResponderState().

The main problem which vexes me (and probably everyone else) is not being able to leave and return and still have the puzzle in the same state I left it in. I can't see a way to do this but that is what needs to be done. I'm not sure it's worth the time to try to do it.

At least I had a great experience bug chasing, learning how the code works, and improving my Python knowledge. I guess it was worth a few days of frustration.

I haven't quite given up on finding a fix for this. Assuming that the plate responder state comes up not depressed by default (I have to run a test to confirm) and if there is a way to programmatically set the responder state without actually moving the rock off and back on, it might be possible to set the plate responder states to match the SDL values. Even so, the program still would not know about the rocks on the plates unless you actually interacted with them. This would still be a bug of sorts... if you step on a plate and don't touch the rock, the plate would pop up again when you stepped off. It's a nasty little problem.

There is a workaround you can try... When you solve the puzzle and move into the next room to flip a lever to open the outer door, make sure you set ALL 7 of the panels down (gray). if you leave and return, the solution to the puzzle is to have no plates depressed. If the inner door is closed, stepping on then off any plate should open them. If the outer door is closed, operating any lever should open them.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8 (and bugs)

Postby johnsojc » Mon Aug 12, 2013 12:04 pm

I finally solved my problem getting to the spyroom.

It appears that the filename for the SDL file and the name in each STATEDESC therein has to match the ageName. After wiping my vault to get rid of corrupted data (from earlier testing) and making the name changes to the SDL files, I had no trouble getting into the spyroom. I would probably never have seen this problem except I was using an internal client on my own game server test bed. I have no idea how it works on an production but there, at least, the SDL is downloaded for external clients... internal clients may still have an issue depending on whether or not they are using /localdata.

Things I ended up changing:

    ahnonay.sdl to Ahnonay.sdl
    ahnonaycathefral.sdl to AhnonayCathedral.sdl
    SpyRoom.sdl to spyroom.sdl
      (in spyroom.sdl) STATEDESC SpyRoom to STATEDESC spyroom

WARNING: Changing these values on a working server will probably break something... this change is only good for a new server. (Why I ended up having to do a vault wipe :()

My impression of what may be wrong is that the server cannot find the correct SDL file since *nix names are case sensitive. For the Spy Room, this ended up being fatal. Ahnonay creates agedata if it can't find any loaded in the DB so it still works.

(side note: enabling Sharper's hat has no effect... probably why it is commented out in the original file.)
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8 (and bugs)

Postby johnsojc » Wed Aug 14, 2013 7:42 am

Going too fast and making too many mistakes... going to back off this project for a short while and let all the new stuff I've learned settle until I am not so confused.

Not happy that the % operator in formatting printed strings is going to be deprecated... at least not in Py2. I was hoping to get as close to Py3 as possible but I still don't know enough.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8 (and bugs)

Postby Deledrius » Wed Aug 14, 2013 9:41 am

johnsojc wrote:Not happy that the % operator in formatting printed strings is going to be deprecated... at least not in Py2. I was hoping to get as close to Py3 as possible but I still don't know enough.

Don't worry about it. That's something which is trivially easy for us to replace at a later date should the need arise.
User avatar
Deledrius
Gehn Shard Admin
 
Posts: 1377
Joined: Mon Oct 01, 2007 1:21 pm

Re: Converting Python Scripts to meet PEP-8 (and bugs)

Postby johnsojc » Wed Aug 14, 2013 5:14 pm

Updated the Plasma scripts to meet pep8. Enjoy!
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8 (and bugs)

Postby johnsojc » Thu Aug 15, 2013 5:14 pm

Just pushed the last of the pep8 updates up to github. All of the scripts (excepting system) have been gone through at least once now. I am running my clients exclusively with the modified scripts. I will be playing through the entire game to try to find any typos or other errors (found four in the latest batch already). Corrections will be uploaded as I find them.

Of course, not every piece of code can be tested due to some functionality not available on dirtsand yet. There are still a lot of cosmetic updates I can do but I bypassed them for now just to get the basic updates done.

Now I think I'll take a break... maybe read book. :lol:
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

PreviousNext

Return to Plasma Development

Who is online

Users browsing this forum: No registered users and 1 guest