Skip to content

Commit

Permalink
Merge pull request #793 from dpogue/shroomie-gate
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoikas committed Jan 28, 2021
2 parents 4dedee0 + 7e1df89 commit c292a8a
Showing 1 changed file with 33 additions and 20 deletions.
53 changes: 33 additions & 20 deletions Scripts/Python/tldnShroomieGate.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,48 +56,61 @@
respGateDown = ptAttribResponder(3, "resp: Gate Down", netForce=1)
respGateUp = ptAttribResponder(4, "resp: Gate Up", netForce=1)

kGateVariable = "tldnShroomieGateUp"

class tldnShroomieGate(ptResponder):

def __init__(self):
# run parent class init
ptResponder.__init__(self)
self.id = 5042

version = 1
self.version = version
PtDebugPrint("__init__tldnShroomieGate v.", version)

def OnNotify(self,state,id,events):
if id == clkLever.id and state:
PtDebugPrint("tldnShroomieGate:\t---Someone Pulled the Lever")
respLeverPull.run(self.key,avatar=PtFindAvatar(events))

elif id == respLeverPull.id:
ageSDL = PtGetAgeSDL()
PtDebugPrint("tldnShroomieGate:\t---Shroomie Gate Up SDL: %d" % (ageSDL["tldnShroomieGateUp"][0]))
if ageSDL["tldnShroomieGatePowerOn"][0] and self.sceneobject.isLocallyOwned():
if ageSDL["tldnShroomieGateUp"][0]:
respGateDown.run(self.key)
PtDebugPrint("tldnShroomieGate:\t---Shroomie Gate Going Down")
else:
respGateUp.run(self.key)
PtDebugPrint("tldnShroomieGate:\t---Shroomie Gate Going Up")
ageSDL["tldnShroomieGateUp"] = (not ageSDL["tldnShroomieGateUp"][0],)


PtDebugPrint(f"tldnShroomieGate:\t---Shroomie Gate Up SDL: {ageSDL[kGateVariable][0]}")
if ageSDL["tldnShroomieGatePowerOn"][0] and self.sceneobject.isLocallyOwned():
ageSDL[kGateVariable] = (not ageSDL[kGateVariable][0],)

def OnSDLNotify(self, VARname, SDLname, playerID, tag):
if VARname != kGateVariable:
return

ageSDL = PtGetAgeSDL()
value = ageSDL[kGateVariable][0]

avatarKey = PtGetAvatarKeyFromClientID(playerID)
avatar = avatarKey.getSceneObject() if avatarKey else None
ff = avatar is None

if value:
respGateUp.run(self.key, avatar=avatar, fastforward=ff)
PtDebugPrint("tldnShroomieGate:\t---Shroomie Gate Going Up")
else:
respGateDown.run(self.key, avatar=avatar, fastforward=ff)
PtDebugPrint("tldnShroomieGate:\t---Shroomie Gate Going Down")

def OnServerInitComplete(self):
try:
ageSDL = PtGetAgeSDL()
except:
PtDebugPrint("tldnShroomieGate:\tERROR---Cannot find the Teledahn Age SDL")

ageSDL.sendToClients("tldnShroomieGateUp")
ageSDL.setFlags("tldnShroomieGateUp", 1, 1)
ageSDL.setNotify(self.key, "tldnShroomieGateUp", 0.0)
if ageSDL["tldnShroomieGateUp"][0]:
ageSDL.sendToClients(kGateVariable)
ageSDL.setFlags(kGateVariable, 1, 1)
ageSDL.setNotify(self.key, kGateVariable, 0.0)

if ageSDL[kGateVariable][0]:
PtDebugPrint("tldnShroomieGate:\tInit---Shroomie Gate Up")
respGateUp.run(self.key,fastforward=1)
respGateUp.run(self.key, fastforward=True)
else:
PtDebugPrint("tldnShroomieGate:\tInit---Shroomie Gate Down")
respGateDown.run(self.key,fastforward=1)
respGateDown.run(self.key, fastforward=True)

0 comments on commit c292a8a

Please sign in to comment.