something strange with clickables objects

Help bring our custom Ages to life! Share tips and tricks, as well as code samples with other developers.

something strange with clickables objects

Postby Gbadji » Wed Apr 02, 2008 1:21 pm

*==================
* 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
The French's Mystpedia age Project - http://www.mystpedia.net
To find me in the Cavern: Gbadji KI #6911493 or Alatan KI#7869109
User avatar
Gbadji
 
Posts: 73
Joined: Sat Feb 02, 2008 5:59 am

Re: something strange with clickables objects

Postby D'Lanor » Wed Apr 02, 2008 2:29 pm

Is the clickable the same object you suppress the physics of? If that is true then that might be the cause.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: something strange with clickables objects

Postby Aloys » Wed Apr 02, 2008 4:47 pm

Bonjour Gbadji,

J'aimerai bien t'aidé, mais j'ai de n'y connaitre absolument rien à Python :) (ou à la programation en général)..
J'espère qu'un des autres collègues ici pourra t'aider.
User avatar
Aloys
 
Posts: 1968
Joined: Sun Oct 21, 2007 7:57 pm
Location: France (GMT +1)

Re: something strange with clickables objects

Postby Paradox » Wed Apr 02, 2008 7:29 pm

Alors tu peux faire cliquer ton objet quand il y a des erreurs dans ton fichier de Python? C'est un situation vraiment unique :?
Je pense wue peut-etre l'AlcScript est le probleme ici. Peux-tu copier ton AlcScript et faire poster dans le forum?

So the object is clickable when there's an error in the Python file? That's a very unique situation :?
I think that maybe your AlcScript is the problem here. Could you copy it into a post on the forum?
Paradox
 
Posts: 1290
Joined: Fri Sep 28, 2007 6:48 pm
Location: Canada

Re: something strange with clickables objects

Postby Gbadji » Thu Apr 03, 2008 12:35 pm

Merci Aloys, je ne doute pas qu'un jour tu pourras répondre à une de mes questions. ;)

Paradox that wasn't an error in the alcscript, D'Lanor was right: I misunderstood a comment in FunChk01Clickables.py example and I have not to add

self.Cristal[cristal].physics.suppress(true)

in my python file. When I suppress that line my crystals are still clickable objects. I have corrected more than one error and now my first crystal up and down perfectly (too much but it's not the problem and I know how to solve that, the code in functions xxFire doesn't work but that will be an other step).

For now I have problem with the four others crystals as you can see in the end of the Python.0.elf file:


Code: Select all
...
(04/03 21:03:21) ULM: Activating book Link20
(04/03 21:03:24) __init__MystpediaBookGUI v.2.1
(04/03 21:03:24) __init__MystpediaFocus1 v.1.0
(04/03 21:03:24) __init__MystpediaFocus1 v.1.0
(04/03 21:03:24) __init__MystpediaFocus1 v.1.0
(04/03 21:03:24) __init__MystpediaFocus1 v.1.0
(04/03 21:03:24) __init__MystpediaFocus1 v.1.0
(04/03 21:03:24) __init__MystpediaBookGUI v.2.1
(04/03 21:03:25) Mystpedia.OnFirstUpdate(): AgeName= Mystpedia
(04/03 21:03:25) MystpediaFocus1.OnFirstUpdate(): AgeName= Mystpedia
(04/03 21:03:25) MystpediaFocus1.OnFirstUpdate(): AgeName= Mystpedia
(04/03 21:03:25) MystpediaFocus1.OnFirstUpdate(): AgeName= Mystpedia
(04/03 21:03:25) MystpediaFocus1.OnFirstUpdate(): AgeName= Mystpedia
(04/03 21:03:25) MystpediaFocus1.OnFirstUpdate(): AgeName= Mystpedia
(04/03 21:03:25) MystpediaFocus1: OnServerInitComplete called
(04/03 21:03:25) MystpediaFocus1: OnServerInitComplete called
(04/03 21:03:25) MystpediaFocus1: OnServerInitComplete called
(04/03 21:03:25) MystpediaFocus1: OnServerInitComplete called
(04/03 21:03:25) MystpediaFocus1: OnServerInitComplete called
(04/03 21:03:30) MystpediaFocus1: OnNotify called
(04/03 21:03:30) Someone clicked on object Cristal2
(04/03 21:03:30) It was you
(04/03 21:03:30) Try cristal Cristal1
(04/03 21:03:30) Try cristal Cristal2
(04/03 21:03:30) Match found! start moving...
(04/03 21:03:30) MystpediaFocus1: IMoveCristalcalled
(04/03 21:03:30) with Cristal2
(04/03 21:03:30) Traceback (most recent call last):
(04/03 21:03:30)   File "G:/DATA_Mystpedia/Mystpedia_pourtest_080330/Python_source/MystpediaFocus1.py", line 107, in OnNotify
(04/03 21:03:30)     self.IMoveCristal(c)
(04/03 21:03:30)   File "G:/DATA_Mystpedia/Mystpedia_pourtest_080330/Python_source/MystpediaFocus1.py", line 114, in IMoveCristal
(04/03 21:03:30)     oldPos = self.Cristal[c].position()
(04/03 21:03:30) RuntimeError: Sceneobject Cristal2 does not have a coordinate interface.
(04/03 21:03:31) MystpediaFocus1: OnNotify called


How my crystals can loose there coordinate interface?

There is my Python file now (without glue code):

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):
        print ('%s: IMoveCristalcalled' % self.__class__.__name__)
        print ('with %s' % c)
        if self.Cristal[c] != None:
            oldPos = self.Cristal[c].position()
            # pour l'instant on ne fait que monter ou descendre le cristal
            # on modifie sa propriete physique pour pouvoir le déplacer
#            self.Cristal[c].physics.suppress(true)
            if self.EtatCristal[c] == 'Haut':
                newPos = ptPoint3(oldPos.getX(), oldPos.getY(), oldPos.getZ()-zDelta)
                self.Cristal[c].physics.warp(newPos)
                self.EtatCristal[c] = 'Bas'
                self.ISupFire(c)
            else:
                newPos = ptPoint3(oldPos.getX(), oldPos.getY(), oldPos.getZ()+zDelta)
                self.Cristal[c].physics.warp(newPos)
                self.EtatCristal[c] = 'Haut'
                self.IAddFire(c)
            # on modifie sa propriete physique pour pouvoir le déplacer
#            self.Cristal[c].physics.suppress(false)

    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]
        self.IUpdateFire()

    def ISupFire(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]
        self.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



There is the AlcScript (just in case, but it's very light)
Code: Select all
# insert AlcScript code here

FootStepRgnGbadji:
    region:
        type: footstep
        surface: stone
         
LivreGbadji1:
    quickscript:
        simpleclick:
            pythonfile: MystpediaBookGUI
            region: RgnLivreGbadji1
         
TheDniBook1:
    quickscript:
        simpleclick:
            pythonfile: MystpediaBookGUI
            region: RngBiblio1

Cristal1:
    quickscript:
        simpleclick:
            pythonfile: MystpediaFocus1
            region: RngCristaux

Cristal2:
    quickscript:
        simpleclick:
            pythonfile: MystpediaFocus1
            region: RngCristaux

Cristal3:
    quickscript:
        simpleclick:
            pythonfile: MystpediaFocus1
            region: RngCristaux

Cristal4:
    quickscript:
        simpleclick:
            pythonfile: MystpediaFocus1
            region: RngCristaux

Cristal5:
    quickscript:
        simpleclick:
            pythonfile: MystpediaFocus1
            region: RngCristaux
            


Thanks for your help.
The French's Mystpedia age Project - http://www.mystpedia.net
To find me in the Cavern: Gbadji KI #6911493 or Alatan KI#7869109
User avatar
Gbadji
 
Posts: 73
Joined: Sat Feb 02, 2008 5:59 am

Re: something strange with clickables objects

Postby D'Lanor » Thu Apr 03, 2008 1:24 pm

One way to make sure your object has a coordinate interface is to turn on Bounds in the logic properties. But I would expect that Bounds are already on if the objects are clickables.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: something strange with clickables objects

Postby Gbadji » Fri Apr 04, 2008 9:58 am

Thanks D'Lanor to remember me that it's not because you put an information in blender that it's always there.
My crystals lost there Actor property.

I can go to the next step now.
See you soon.
The French's Mystpedia age Project - http://www.mystpedia.net
To find me in the Cavern: Gbadji KI #6911493 or Alatan KI#7869109
User avatar
Gbadji
 
Posts: 73
Joined: Sat Feb 02, 2008 5:59 am


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron