Ok, I took a look at the Kinekulle combination puzzle python file (KinekulleLayers.py). A lot of it seems pretty self explanatory, but please correct me if I interpreted it wrong.
Code: Select all
from Plasma import *
from PlasmaTypes import *
import string
actButton1 = ptAttribActivator(1, 'Act: Button 01')
actButton2 = ptAttribActivator(2, 'Act: Button 02')
actButton3 = ptAttribActivator(3, 'Act: Button 03')
actButton4 = ptAttribActivator(4, 'Act: Button 04')
actButton5 = ptAttribActivator(5, 'Act: Button 05')
actButton6 = ptAttribActivator(6, 'Act: Button 06')
respButton1 = ptAttribResponder(7, 'Resp: Button 01 Down')
respButton2 = ptAttribResponder(8, 'Resp: Button 02 Down')
respButton3 = ptAttribResponder(9, 'Resp: Button 03 Down')
respButton4 = ptAttribResponder(10, 'Resp: Button 04 Down')
respButton5 = ptAttribResponder(11, 'Resp: Button 05 Down')
respButton6 = ptAttribResponder(12, 'Resp: Button 06 Down')
respResetButtons = ptAttribResponder(13, 'Reset All Buttons')
solution = 123456
buttonSDL = 'KFossilsPushed'
unlockSDL = 'knnkTrsLidOpen'
class KinnekulleLayers(ptResponder,):
__module__ = __name__
__module__ = __name__
def __init__(self):
ptResponder.__init__(self)
self.version = 1
self.me = self.__class__.__name__
print ('__init__%s v.%s' % (self.me,
self.version))
def OnServerInitComplete(self):
ageSDL = PtGetAgeSDL()
ageSDL.sendToClients(buttonSDL)
ageSDL.sendToClients(unlockSDL)
ageSDL.setFlags(buttonSDL, 1, 1)
ageSDL.setFlags(unlockSDL, 1, 1)
ageSDL.setNotify(self.key, buttonSDL, 0.0)
ageSDL.setNotify(self.key, unlockSDL, 0.0)
ButtonsPushed = ageSDL[buttonSDL][0]
ButtonsPushed = str(ButtonsPushed)
print ('%s.OnServerInitComplete: When I got here: ' % self.me),
print ('%s = ' % buttonSDL),
print ButtonsPushed
if (len(ButtonsPushed) >= 6):
print 'All 6 buttons were already pushed. Resetting.'
respResetButtons.run(self.key, fastforward=1)
ageSDL[buttonSDL] = (0,)
return
if ('1' in ButtonsPushed):
print 'fast forwarding button 1'
respButton1.run(self.key, fastforward=1)
if ('2' in ButtonsPushed):
print 'fast forwarding button 2'
respButton2.run(self.key, fastforward=1)
if ('3' in ButtonsPushed):
print 'fast forwarding button 3'
respButton3.run(self.key, fastforward=1)
if ('4' in ButtonsPushed):
print 'fast forwarding button 4'
respButton4.run(self.key, fastforward=1)
if ('5' in ButtonsPushed):
print 'fast forwarding button 5'
respButton5.run(self.key, fastforward=1)
if ('6' in ButtonsPushed):
print 'fast forwarding button 6'
respButton6.run(self.key, fastforward=1)
if ('0' in ButtonsPushed):
print 'No buttons have been pushed.'
ageSDL[buttonSDL] = (0,)
def OnNotify(self, state, id, events):
ageSDL = PtGetAgeSDL()
if (state and ((id in [1,
2,
3,
4,
5,
6]) and PtWasLocallyNotified(self.key))):
PtSetGlobalClickability(0)
PtAtTimeCallback(self.key, 1.2, 1)
print ('%s.OnNotify: Button #%d pushed' % (self.me,
id))
wasUnlocked = ageSDL[unlockSDL][0]
if wasUnlocked:
print ('%s.OnNotify: Oops... you have reset the puzzle!' % self.me)
ageSDL[unlockSDL] = (0,)
ButtonsPushed = ageSDL[buttonSDL][0]
ButtonsPushed = str(ButtonsPushed)
print ('%s.OnNotify: Before, ButtonsPushed was ' % self.me),
print ButtonsPushed
ButtonsPushed = string.atoi((ButtonsPushed + str(id)))
print ('%s.OnNotify: Now, ButtonsPushed = ' % self.me),
print ButtonsPushed
ageSDL[buttonSDL] = (ButtonsPushed,)
if (len(str(ButtonsPushed)) >= 6):
PtAtTimeCallback(self.key, 1, 2)
def OnSDLNotify(self, VARname, SDLname, playerID, tag):
ageSDL = PtGetAgeSDL()
print ('%s.OnSDLNotify:\tVARname=' % self.me),
print VARname,
print ' value=',
print ageSDL[VARname][0]
if (VARname == buttonSDL):
ButtonsPushed = ageSDL[buttonSDL][0]
if (ButtonsPushed == 0):
return
ButtonsPushed = str(ButtonsPushed)
lastbuttonpushed = ButtonsPushed[-1:]
print ('%s.OnSDLNotify: new ButtonsPushed = ' % self.me),
print ButtonsPushed
code = (('respButton' + str(lastbuttonpushed)) + '.run(self.key, netPropagate=0)')
exec code
def OnTimer(self, id):
if (id == 1):
PtSetGlobalClickability(1)
elif (id == 2):
ageSDL = PtGetAgeSDL()
ButtonsPushed = ageSDL[buttonSDL][0]
print ('%s.OnTimer: Check solution. ButtonsPushed = ' % self.me),
print ButtonsPushed
if (ButtonsPushed == solution):
print ('%s.OnTimer: Puzzle solved. Unlocking!' % self.me)
ageSDL[unlockSDL] = (1,)
respResetButtons.run(self.key)
ageSDL[buttonSDL] = (0,)
glue_cl = None
glue_inst = None
glue_params = None
glue_paramKeys = None
try:
x = glue_verbose
except NameError:
glue_verbose = 0
def glue_getClass():
global glue_cl
if (glue_cl == None):
try:
cl = eval(glue_name)
if issubclass(cl, ptModifier):
glue_cl = cl
elif glue_verbose:
print ('Class %s is not derived from modifier' % cl.__name__)
except NameError:
if glue_verbose:
try:
print ('Could not find class %s' % glue_name)
except NameError:
print 'Filename/classname not set!'
return glue_cl
def glue_getInst():
global glue_inst
if (type(glue_inst) == type(None)):
cl = glue_getClass()
if (cl != None):
glue_inst = cl()
return glue_inst
def glue_delInst():
global glue_inst
global glue_cl
global glue_paramKeys
global glue_params
if (type(glue_inst) != type(None)):
del glue_inst
glue_cl = None
glue_params = None
glue_paramKeys = None
def glue_getVersion():
inst = glue_getInst()
ver = inst.version
glue_delInst()
return ver
def glue_getParamDict():
global glue_paramKeys
global glue_params
if (type(glue_params) == type(None)):
glue_params = {}
gd = globals()
for obj in gd.values():
if isinstance(obj, ptAttribute):
if glue_params.has_key(obj.id):
if glue_verbose:
print 'WARNING: Duplicate attribute ids!'
print ('%s has id %d which is already defined in %s' % (obj.name,
obj.id,
glue_params[obj.id].name))
else:
glue_params[obj.id] = obj
glue_paramKeys = glue_params.keys()
glue_paramKeys.sort()
glue_paramKeys.reverse()
return glue_params
def glue_getClassName():
cl = glue_getClass()
if (cl != None):
return cl.__name__
if glue_verbose:
print ('Class not found in %s.py' % glue_name)
return None
def glue_getBlockID():
inst = glue_getInst()
if (inst != None):
return inst.id
if glue_verbose:
print ('Instance could not be created in %s.py' % glue_name)
return None
def glue_getNumParams():
pd = glue_getParamDict()
if (pd != None):
return len(pd)
if glue_verbose:
print ('No attributes found in %s.py' % glue_name)
return 0
def glue_getParam(number):
pd = glue_getParamDict()
if (pd != None):
if (type(glue_paramKeys) == type([])):
if ((number >= 0) and (number < len(glue_paramKeys))):
return pd[glue_paramKeys[number]].getdef()
else:
print ('glue_getParam: Error! %d out of range of attribute list' % number)
else:
pl = pd.values()
if ((number >= 0) and (number < len(pl))):
return pl[number].getdef()
elif glue_verbose:
print ('glue_getParam: Error! %d out of range of attribute list' % number)
if glue_verbose:
print 'GLUE: Attribute list error'
return None
def glue_setParam(id, value):
pd = glue_getParamDict()
if (pd != None):
if pd.has_key(id):
try:
pd[id].__setvalue__(value)
except AttributeError:
if isinstance(pd[id], ptAttributeList):
try:
if (type(pd[id].value) != type([])):
pd[id].value = []
except AttributeError:
pd[id].value = []
pd[id].value.append(value)
else:
pd[id].value = value
elif glue_verbose:
print "setParam: can't find id=",
print id
else:
print 'setParma: Something terribly has gone wrong. Head for the cover.'
def glue_isNamedAttribute(id):
pd = glue_getParamDict()
if (pd != None):
try:
if isinstance(pd[id], ptAttribNamedActivator):
return 1
if isinstance(pd[id], ptAttribNamedResponder):
return 2
except KeyError:
if glue_verbose:
print ('Could not find id=%d attribute' % id)
return 0
def glue_isMultiModifier():
inst = glue_getInst()
if isinstance(inst, ptMultiModifier):
return 1
return 0
For the first part, it seems there is a list of the buttons, each is assigned a number, and the second part has the button object name. ('Act: MyButton01') or in the case of this file ('Act: Button 01'). The first 6 buttons are for telling it that the buttons are part of the combination (defining it's name etc.) The second 1-6 are the same buttons, but telling it that when a button is down it responds. Then I'm assuming #13 is the reset button. The solution is the sequence of numbers in which the buttons must be pushed to open the door.
Not sure what the 'buttonSDL' Variable is for, perhaps so that when you leave the age while in the middle of pressing buttons it won't reset? Then the UnlockSDL must be so that once opened, the door opened by the combination will stay open unless reset by the reset button. From there on I'm lost as to what to change, or what's going on below that.
Could I just change everywhere it says "Kinekulle" to "SparklingPalace" (my age), change the combination and button names, and it would work once the AlcScript is there? Or are there a bunch of tiny details that I have to tailor to my age perfectly? If so, what would I have to change to fit my age?
Also, what would I do for AlcScript? I know to use a single clickregion, but should I just give the buttons a normal clickable AlcScript, and link them to the Buttons Python file? Then how does the reset button work into this all? Should I use a normal animation quickscript for the door that opens, or is it more complicated?
Sorry about so many questions, hope they're not too much to answer all at once
