Problem with PythonFileMod parameter reference to other page

If you feel like you're up to the challenge of building your own Ages in Blender or 3ds Max, this is the place for you!
Post Reply
The.Modificator
Posts: 14
Joined: Wed Mar 10, 2010 8:40 am

Problem with PythonFileMod parameter reference to other page

Post by The.Modificator »

Hi everybody!

I'm trying to use a PythonFileMod parameter reference to an object in another page:

Code: Select all

veryclickycube:
    logic:
        modifiers:
          - name: cubedialogopenmod
            cursor: poised
            flags:
              - localelement
            conditions:
              - type: activator
                activators:
                  - type: picking
            actions:
              - type: pythonfile
                ref: $PythDialog
        actions:
          - type: pythonfile
            tag: PythDialog
            pythonfile:
                file: myOwnGuiTest
                parameters:
                  - type: responder
                    ref: respondermod:animstartresp
                  - type: guidialog
                    ref: 0098:guiTestCam@leftGUI         # <-- look here


My problem is: When exporting my age with PyPRP a new (empty) GUI Dialog Mod object is created in the same page in which the Python File Mod is located, i.e. the object in the other page is actually not being referenced.

I already did some digging in the PyPRP code and found this piece of code: (from ScriptRefParser.RefString_FindCreate in prp_RefParser.py)

Code: Select all

                # Try to find the page referenced...
                # If not possible, we default back to the current page
                if not keyinfo["pagename"] is None:
                    page=resmgr.findPrp(str(keyinfo["pagename"]))
                    if page is None:
                        page = self.page
                else:
                    page = self.page


However, resmgr.findPrp(str(keyinfo["pagename"])) returns a correct value, so the code in the if block followed by this line doesn't get executed. I therefore came to the conclusion that the problem must lie somewhere in page.find(). I wasn't able to find the exact cause of the problem yet though. Is there anybody here who might be able to point me into the right direction to solve that problem?


Cheers,

The.Modificator
D'Lanor
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Problem with PythonFileMod parameter reference to other page

Post by D'Lanor »

Referencing objects in other pages has always been problematic, although if I remember correctly it was supposedly fixed in PyPYP 1.6.

Is there any particular reason why you are not using a plain string reference to open the GUI by name, similar to xDialogToggle?
"It is in self-limitation that a master first shows himself." - Goethe
The.Modificator
Posts: 14
Joined: Wed Mar 10, 2010 8:40 am

Re: Problem with PythonFileMod parameter reference to other page

Post by The.Modificator »

D'Lanor wrote:Referencing objects in other pages has always been problematic, although if I remember correctly it was supposedly fixed in PyPYP 1.6.

Well, apparently that doesn't seem to be the case then. :( Do you know who worked on that?


D'Lanor wrote:Is there any particular reason why you are not using a plain string reference to open the GUI by name, similar to xDialogToggle?


I need to do something like this: clickMap = ptGUIControlValue(MyGui.dialog.getControlFromTag(101))
...i.e. getting access to a specific dialog control. But while writing this post I checked the Plasma.py and found a function called PtGetDialogFromString(). I think, I'll give that one a try.

Thanks for your reply!


Modi
D'Lanor
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Problem with PythonFileMod parameter reference to other page

Post by D'Lanor »

The.Modificator wrote:Well, apparently that doesn't seem to be the case then. :( Do you know who worked on that?


The fix was merged from the contrib of Paradox. It replaced one line in _RefString_Decode

PyPRP 1.5

Code: Select all

                    return { 'type': keytype, "name": name,"pagename": None }


PyPRP 1.6

Code: Select all

                    return { 'type': keytype, "name": name,"pagename": pagename }
"It is in self-limitation that a master first shows himself." - Goethe
D'Lanor
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Problem with PythonFileMod parameter reference to other page

Post by D'Lanor »

I think I found something: guidialog is commented out as allowed ScriptValueType in prp_LogicClasses
"It is in self-limitation that a master first shows himself." - Goethe
The.Modificator
Posts: 14
Joined: Wed Mar 10, 2010 8:40 am

Re: Problem with PythonFileMod parameter reference to other page

Post by The.Modificator »

D'Lanor wrote:It replaced one line in _RefString_Decode[...]

Hm, in this specific case it doesn't seem to be enough. Don't ask my why though.

Concerning the commented out ScriptValueType: I already removed the # sign from the prp_LogicClasses in my local PyPRP version before creating this thread. Otherwise I wouldn't have come that far I think. (The Python File Mod would not have exported any kind of GUI dialog.)


PtGetDialogFromString() works fine by the way... so until another type of an intra-page reference in a Python File Mod becomes necessary, my problem can be called 'solved'.

Thanks again, D'Lanor!
Post Reply

Return to “Building”