* la version française
* the english version is following
*===========================
Comme ce qui se passe est un peu confus, je préfère l'expliquer d'abord en français et comme d'habitude, si quelqu'un voit une différence dans la version anglaise, merci de l'indiquer.
Dans mon âge, j'ai des objets auxquels est associé un fichier python.
Quand j'ai une erreur dans ce fichier python qui fait qu'au chargement de l'âge il n'est pas interprété jusqu'à la fin, mes objets sont cliquables (curseur actif). Quand je n'ai pas d'erreur, les objets ne le sont plus (pas de curseur actif).
La question est : y comprenez-vous quelque chose ?
Qu'est-ce qui peut supprimer le curseur actif ?
Merci.
(le fichier python est après la version anglaise)
*==============
* now the english version
*=====================
In my age, I have objects with a python file associated to them.
When I have a programming error in the python file, the end of the file is not interpreted and the objects are clickable (active pointer).
When I have no error, the objects are not clickable (no active pointer).
The question is: do you understand something?
what can suppress the active pointer?
Thanks.
The python file without the mistake (to have it, comment for example the line self.EtatCristal = {}) and without the glue functions. That's not perfect python programming file but it's my first one so be indulgent.
- Code: Select all
from Plasma import *
from PlasmaTypes import *
from PlasmaKITypes import *
from PlasmaNetConstants import *
import xLocalization
import string
import time
actClickableObject = ptAttribActivator(1, 'Act: Clickable Object')
ObjectMsg = ptAttribString(2, 'Object String')
# les noms des objets dans le modele blender
Cristal1 = 'Cristal1'
Cristal2 = 'Cristal2'
Cristal3 = 'Cristal3'
Cristal4 = 'Cristal4'
Cristal5 = 'Cristal5'
Foyer1 = 'Foyer1'
Foyer2 = 'Foyer2'
Foyer3 = 'Foyer3'
# quelques constantes
zDelta = 0.5
nomCristaux = [Cristal1, Cristal2, Cristal3, Cristal4, Cristal5]
nomFoyer = [Foyer1, Foyer2, Foyer3]
cR = 0
cG = 1
cB = 2
cO = 3
lesCouleurs = [cR, cG, cB]
# acces: couleurCristaux[cristal][foyer][couleur]
couleurCristaux = {Cristal1: {Foyer1: [0.27, 0.22, 0.12], Foyer2: [0.27, 0.22, 0.12], Foyer3: [0.27, 0.22, 0.12]}, \
Cristal2: {Foyer1: [0.27, 0.0, 0.12], Foyer2: [0.54, 0.22, 0.12], Foyer3: [0.27, 0.22, 0.12]}, \
Cristal3: {Foyer1: [0.27, 0.22, 0.12], Foyer2: [0.27, 0.22, 0.12], Foyer3: [0.27, 0.22, 0.0]}, \
Cristal4: {Foyer1: [0.27, 0.44, 0.12], Foyer2: [0.0, 0.22, 0.12], Foyer3: [0.27, 0.22, 0.12]}, \
Cristal5: {Foyer1: [0.27, 0.22, 0.12], Foyer2: [0.27, 0.22, 0.12], Foyer3: [0.27, 0.22, 0.12]}}
class MystpediaFocus1(ptModifier,):
def __init__(self):
ptModifier.__init__(self)
self.version = '1.0'
self.id = 9430003
self.EtatCristal = {}
self.Cristal = {}
self.Foyer = {}
print ('__init__%s v.%s' % (self.__class__.__name__, self.version))
# NOTE_TODO: tenir compte de variables SDL pour retrouver l'état au chargement
# (Ã faire dans Mystpedia.py)?
for cristal in nomCristaux:
self.EtatCristal[cristal] = 'Haut'
#
self.AgeNAme = None
for cristal in nomCristaux:
self.Cristal[cristal] = None
for foyer in nomFoyer:
self.Foyer[foyer] = [0.0, 0.0, 0.0, None]
def OnFirstUpdate(self):
self.AgeName = PtGetAgeName()
print 'MystpediaFocus1.OnFirstUpdate(): AgeName=', self.AgeName
def OnServerInitComplete(self):
print ('%s: OnServerInitComplete called' % self.__class__.__name__)
# recuperation des Objets correspondant aux cristaux
for cristal in nomCristaux:
self.Cristal[cristal] = PtFindSceneobject(cristal,self.AgeName)
if self.Cristal[cristal] == None:
print 'OnServerInitComplete - could not find ', cristal ,'!'
else:
# on modifie sa propriete physique pour pouvoir le déplacer
self.Cristal[cristal].physics.suppress(true)
for foyer in nomFoyer:
self.Foyer[foyer] = PtFindSceneobject(foyer, self.AgeName)
if self.Foyer[foyer] == None:
print 'OnServerInitComplete - could not find ', foyer ,'!'
def OnNotify(self, state, id, events):
print ('%s: OnNotify called' % self.__class__.__name__)
if ((id == actClickableObject.id) and state):
print ('Someone clicked on object %s' % ObjectMsg.value)
if (PtWasLocallyNotified(self.key)):
print 'It was you'
for c in nomCristaux:
print ('Try cristal %s ' % c)
if (ObjectMsg.value == c):
print 'Match found! start moving...'
self.IMoveCristal(c)
break
def IMoveCristal(self, c):
if self.Cristal[c] != None:
oldPos = sel.Cristal[c].position()
# pour l'instant on ne fait que monter ou descendre le cristal
if self.EtatCristal[c] == 'Haut':
newPos = ptPoint3(oldPos.getX(), oldPos.getY(), oldPos.getZ()-zDelta)
self.EtatCristal[c].physics.warp(newPos)
self.EtatCristal[c] = 'Bas'
ISupFire(c)
else:
newPos = ptPoint3(oldPos.getX(), oldPos.getY(), oldPos.getZ()+zDelta)
self.EtatCristal[c].physics.warp(newPos)
self.EtatCristal[c] = 'Haut'
IAddFire(c)
def IAddFire(self, c):
print ('%s: On verifie l\'impact des cristaux sur le feu' % self.__class__.__name__)
for foyer in nomFoyer:
for couleur in lesCouleurs:
self.Foyer[foyer][couleur] = couleurCristaux[c][foyer][couleur] + self.Foyer[foyer][couleur]
IUpdateFire()
def ISubFire(self, c):
print ('%s: On verifie l\'impact des cristaux sur le feu' % self.__class__.__name__)
for foyer in nomFoyer:
for couleur in lesCouleurs:
self.Foyer[foyer][couleur] = couleurCristaux[c][foyer][couleur] - self.Foyer[foyer][couleur]
IUpdateFire()
def IUpdateFire(self):
print ('%s: Le feu brule-t-il?' % self.__class__.__name__)
for foyer in nomFoyer:
PtSetLightValue(Foyer[foyer][cO].getKey(), Foyer[foyer][cR], Foyer[foyer][cG], Foyer[foyer][cG], 5.0)
def OnSDLNotify(self, VARname, SDLname, playerID, tag):
pass
def OnTimer(self, id):
pass
#--- fin de la class MystpediaFocus1