Page 9 of 12
Re: Converting Python Scripts to meet PEP-8
Posted: Fri Aug 02, 2013 8:46 am
by johnsojc
I'm getting very uneasy about simplifying some of these type comparison tests... if (type(var) != type(None): or if type(var) != type(None) and var != "":.
In many cases, I am not sure what values might be returned in var to be tested. Simplifying these to just if var: creates the chance that if var is not None but var returns the value zero or "" or () or [] or {}, then the test will fail.
It would be helpful is anyone who reviews these changes I'm making in the scripts take a second closer look at whether there is a chance that the simplified code will fail because I did not foresee a value that will make the test fail.
Re: Converting Python Scripts to meet PEP-8
Posted: Sat Aug 03, 2013 5:47 am
by johnsojc
Lost my server so I'm down for while while I try to rebuild from scratch. (Anyway, I needed a break from going cross-eyed reading scripts all day

)
Re: Converting Python Scripts to meet PEP-8
Posted: Sat Aug 03, 2013 5:59 am
by Lyrositor
johnsojc wrote:I'm getting very uneasy about simplifying some of these type comparison tests... if (type(var) != type(None): or if type(var) != type(None) and var != "":.
In many cases, I am not sure what values might be returned in var to be tested. Simplifying these to just if var: creates the chance that if var is not None but var returns the value zero or "" or () or [] or {}, then the test will fail.
It would be helpful is anyone who reviews these changes I'm making in the scripts take a second closer look at whether there is a chance that the simplified code will fail because I did not foresee a value that will make the test fail.
Then you might want to substitute it for "if var is not None:", for example; if you're checking for something that is certain to be a string, though, you can just do "if var:".
Re: Converting Python Scripts to meet PEP-8
Posted: Thu Aug 08, 2013 8:32 am
by johnsojc
I've run into what appears to be o logic error in tldnSlavePrisonDoors.py. The SDL for the levers and pressure plates is not being read in tldnSlavePrisonDoors.OnServerInitComplete (deliberately). If you are the only player in the age, the code explicity does not get the state for the plates and levers. I added a couple of debug statements to check the code looking for the player list and if the SDL was read:
Code: Select all
(08/08 11:17:55) tldnSlavePrisonDoors.OnServerInitComplete: The list of players is []
(08/08 11:17:55) tldnSlavePrisonDoors.OnServerInitComplete: The SDL was NOT read... this is really stupid
[/color]
Not sure why the player is not listed as a player in the Age nor do I understand the logic of NOT reading the state of the prison puzzle unless a second person enters the Age. This was not supposed to be a multiplayer Age AFAIK.
Re: Converting Python Scripts to meet PEP-8
Posted: Thu Aug 08, 2013 11:06 am
by Acorn
johnsojc wrote:I've run into what appears to be o logic error in tldnSlavePrisonDoors.py. The SDL for the levers and pressure plates is not being read in tldnSlavePrisonDoors.OnServerInitComplete (deliberately). If you are the only player in the age, the code explicity does not get the state for the plates and levers. I added a couple of debug statements to check the code looking for the player list and if the SDL was read:
Code: Select all
(08/08 11:17:55) tldnSlavePrisonDoors.OnServerInitComplete: The list of players is []
(08/08 11:17:55) tldnSlavePrisonDoors.OnServerInitComplete: The SDL was NOT read... this is really stupid
[/color]
Not sure why the player is not listed as a player in the Age nor do I understand the logic of NOT reading the state of the prison puzzle unless a second person enters the Age. This was not supposed to be a multiplayer Age AFAIK.
ooh,

might this be the source of the bug I keep boring everyone with?

If so, great work!
Re: Converting Python Scripts to meet PEP-8
Posted: Thu Aug 08, 2013 11:42 am
by johnsojc
LOL, I'm on to a bunch of problems as I just found a new one with the bucket brain when a 2nd avatar enters the Age. The script crashes for the 2nd avvie... it tried to get the state of the door at the top of the bucket ride and blew up with a tuple index out of range.
Code: Select all
(08/08 14:24:08) cPythBucketsBrain - Traceback (most recent call last):
(08/08 14:24:08) File ".\python\tldnBucketBrain.py", line 909, in OnNotify
(08/08 14:24:08) shrmDoorOpen = ageSDL[kStringAgeSDLShrmDoorOpen][0]
(08/08 14:24:08) IndexError: tuple index out of range
[/color]
Re: Converting Python Scripts to meet PEP-8 (and bugs)
Posted: Fri Aug 09, 2013 7:49 am
by johnsojc
<gag> Teledahn is a logic nightmare!
Here is an update on what I see happening. Using the internal client console (somewhat useful) I was able to view the AgeSDLs after each action I performed.
First, the state of the prison pressure plates is preserved (tldnSlaveActivePlate0<n>). However, leaving and returning to the Age does not run the code to depress the plates visually. if you exit the Age standing on a plate, that plate's state remains "true" (depressed)... big problem. I assume flying off a plate causes a similar problem.
Second, the levers (paddles) are incredibly broken. Turning one off turns them ALL off in the SDL even though they visually look on. I will play with this more to see if you can actually recover the code but changing one lever should not affect all the levers' SDL values.
UPDATE: Even worse problems with the levers... if you turn all the levers off (down), the SDLs are reset to the initial values indicated that 2, 4 ,6, and 7 are up even though visually they are down. At this point the doors open if the pressure plates are correct (even though they visually are not depressed). After you mess with the levers, they work exactly opposite to the way you want them to... setting them to 1, 3, 5 up solves the puzzle again and opens the doors. However, if you leave the Age and return, even though the SDL values are set correctly to solve the puzzle, the code never reads the SDL if you are the only (or first) person in the Age so the doors are shut even though the puzzle is solved.
Did I not say the logic was a nightmare? ENOUGH testing. Time to tinker with the code and fix it!
Re: Converting Python Scripts to meet PEP-8 (and bugs)
Posted: Fri Aug 09, 2013 10:31 am
by Acorn
johnsojc wrote:
Time to tinker with the code and fix it!
I like the sound of that!
Re: Converting Python Scripts to meet PEP-8 (and bugs)
Posted: Fri Aug 09, 2013 10:55 am
by Wamduskasapa
Acorn wrote:johnsojc wrote:
Time to tinker with the code and fix it!
I like the sound of that!
I second that!!
Re: Converting Python Scripts to meet PEP-8 (and bugs)
Posted: Fri Aug 09, 2013 2:04 pm
by johnsojc
I've been banging around in this code for about 11 hours now and I've reached burnout. At least I (mostly) understand what the heek was the original intent of the code and I've doubled the script size with DEBUG prints.
I've narrowed it down to the event responders... I kick a rock off plate 2 and I get an event from both plate 1 and 7 which immediately breaks the game. Since no one else was there but me and I was on the other side of the room, something else triggered this anomaly.
When my eyes uncross and I can sit up straight in the chair again, I'll focus on that part of the code.
(And once I figure out this little problem, I still have to test multiplayer mode)
EDIT: Ack! It wasn't the responders. Digging a little deeper showed the two events I was concerned about were the for the plate I stepped on and and one for setting the state of the secret door. The path is leading me to find if the AgeSDL's are being reset properly. The code is written to bail on the first occurrence of a plate lever mismatch. Thinking it might be in there if the code is ignoring checking every plate/lever setting.
EDIT2: Everything works just like it's supposed to... but the response to throwing a switch works exactly once. When you get the inner doors open and walk to the switch panel, throwing a switch causes the outer doors to open. For some reason thereafter, tldnSlavePrisonDoors.IEvalPlateAndPaddles() fails to react to any other switch change. The tldnSlavePrisonDoors.OnNotify faithfully intercepts the change in the lever state and passes it to IEvalPlateAndPaddles but something goes wrong after the first time. Too tired to see it tonight... need mo' debug statements.