Page 1 of 1

Global variables?

PostPosted: Mon Apr 19, 2010 10:21 am
by Egon
I want to make a nexus type age. But I want player to be able link to a child ages from my nexus type Age after pressing button in child Age.

With that in mind, I have some questions:

1) in article aboud SDL there is example code:
Code: Select all
   def OnSDLNotify(self, VARname, SDLname, playerID, tag):
       if (SDLname != "MyAge"):
           print 'SDLname =',SDLname,', not MyAge'
           pass
       elif (VARname == "MyState"):
           ageSDL = PtGetAgeSDL()
           getSDL = ageSDL[VARname][0]

Dose checking (SDLname != "MyAge") is required, becouse OnSDLNotify is a static metod, and on setting:
Code: Select all
ageSDL = PtGetAgeSDL()
ageSDL['MyState'] = (1,)
all OnSDLNotify methods, of all plModfier are being launched?
If not: what for is it?

2) Is there a way to change SDL state of one age, from code of another one?
3) Are there some kind of global variables?

Re: Global variables?

PostPosted: Mon Apr 19, 2010 10:26 am
by Branan
The Bahro polls are handled using SDL vars from Relto, accessed from the Bahro cave age. That's a good place to start poking around to figure it out.

Re: Global variables?

PostPosted: Mon Apr 19, 2010 10:49 am
by Egon
Well, after read of "bhroBahroYeeshaCave.py" I stumble upon:

Code: Select all
    def GetAgeNode(self, age):
        vault = ptVault()
        chron = vault.findChronicleEntry('BahroCave')
        ageChronRefList = chron.getChildNodeRefList()
        for ageChron in ageChronRefList:
            ageChild = ageChron.getChild()
            ageChild = ageChild.upcastToChronicleNode()
            if (ageChild.chronicleGetName() == age):
                return ageChild

        return None



    def GetAgeVariable(self, age, variable):
        node = self.GetAgeNode(age)
        if (node != None):
            varlist = node.chronicleGetValue().split(',')
            return varlist[self.varMap[variable]]
        else:
            return None


So I guess I will have to digg this article ;)
Thanks.

Re: Global variables?

PostPosted: Mon Apr 19, 2010 12:19 pm
by diafero
Chronicles are a nice way to implement global variables. One can also access another age's SDL, though - I would recommend the first method.
However, please keep in mind: When two people are in the age, they might have different values for the chronicle as this is a per-player setting. So try to keep your age consistent, somehow.

Re: Global variables?

PostPosted: Mon Apr 19, 2010 12:38 pm
by Egon
diafero wrote:Chronicles are a nice way to implement global variables. One can also access another age's SDL, though - I would recommend the first method.
However, please keep in mind: When two people are in the age, they might have different values for the chronicle as this is a per-player setting. So try to keep your age consistent, somehow.


Hmm, I though that instancing in MOUL is for that: If we are in for example in "my Ercana", then my vault is being analyzed/pared etc. even, on your client (through server). Unless You are talking about "URU:CC" + Alylus server combo?

" One can also access another age's SDL" - are You talking about something different from code which i took from "bhroBahroYeeshaCave.py" ?

Re: Global variables?

PostPosted: Mon Apr 19, 2010 1:14 pm
by Paradox
Chronicles are designed to store player settings, such as KI level, marker progress, and Cleft YeeshaVision stuff. Another player will never see your chronicle values.

SDL values are per-Age instance. Everyone in an Age instance receives the SDL values when linking in to that instance. SDL values are mostly used to store things like open doors, enabled/disabled items, and some animation data.

Now let's look at the hacks:
Any Age can store things in the SDL for Relto. Bahro pillars are stored there, KI GPS coordinates are stored there, and which GuildPub shows up in the Nexus is stored there.
Ages can have chronicles. This is per-Age, not per-Age instance (although sometimes there is a separate Age node for each Age instance). I'm not sure how to access these, since Cyan didn't use them very often (if at all).
MOUL(a) also has a GlobalInbox that stores the MemorialImager and Sharper's Journal, even though those should probably be Age chronicles...

In summary, Cyan developed a great system, but doesn't know how to use it.

Re: Global variables?

PostPosted: Mon Apr 19, 2010 2:14 pm
by D'Lanor
Actually I just added that wiki article about chronicles yesterday. ;)

Chronicles were originally designed to be player specific. Uru has many chronicles and Cyan knows how to use them just fine. However, in MOUL Cyan also used a hack to store chronicle nodes within ages in the AgeData folder. This was done mainly to store age instance GUIDs of the pellet bahro caves so that non-ageowners can also link to the correct instance. (Edit: due to limits of the existing linking rules the pellet bahro caves cannot be anything else than personal ages so Cyan needed a workaround) (Edit 2: This workaround also broke netpropagation of the linking animations and now we often cannot see others place their hands on books :roll: )

The global inbox is a different story. There aren't that many areas in the vault which can easily be read by every player (which is probably a good thing). The global inbox however is accessible for all so it is the logical place to store the global text nodes for memorial imagers and Sharper's journal. If you make these age specific you have to add and modify them manually for each instance. There are far too many Sharper's Office and Ae'gura child age instances for that.


And another edit... spelling.

Re: Global variables?

PostPosted: Tue Apr 20, 2010 3:05 am
by diafero
Ages can have chronicles. This is per-Age, not per-Age instance (although sometimes there is a separate Age node for each Age instance)
I'm quite sure that this is per-instance, because the whole age vault structure builds around an instance, not around an age.

Hmm, I though that instancing in MOUL is for that: If we are in for example in "my Ercana", then my vault is being analyzed/pared etc. even, on your client (through server). Unless You are talking about "URU:CC" + Alylus server combo?
The vault did not change much from UU/Alcugs to MOUL, just like the SDL. So this applies to both versions.

The only multiplayer-safe method I know of to read/write one age's state from another is to make them subages. Both chronicles and getting the age SDL from the AgesIOwnFolder will always get the current player's other age, not the other age belonging to the age you are currently in.
Okay, that "let's save the GUID in the age vault when creating the instance" hack should also work, provided you can access an age's vault specified by the GUID (it's possible in the protocol, but I don't know if Python exposes that).