Global variables?

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

Global variables?

Postby Egon » Mon Apr 19, 2010 10:21 am

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?
Egon #2052375
Who You gonna call? Guild of Doorcallers! #5356672
Eder Tsogal/Delin Marathon
Image
User avatar
Egon
 
Posts: 284
Joined: Fri Nov 16, 2007 9:45 pm

Re: Global variables?

Postby Branan » Mon Apr 19, 2010 10:26 am

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.
Image
Your friendly neighborhood shard admin
User avatar
Branan
Gehn Shard Admin
 
Posts: 694
Joined: Fri Nov 16, 2007 9:45 pm
Location: Portland, OR

Re: Global variables?

Postby Egon » Mon Apr 19, 2010 10:49 am

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.
Egon #2052375
Who You gonna call? Guild of Doorcallers! #5356672
Eder Tsogal/Delin Marathon
Image
User avatar
Egon
 
Posts: 284
Joined: Fri Nov 16, 2007 9:45 pm

Re: Global variables?

Postby diafero » Mon Apr 19, 2010 12:19 pm

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.
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
diafero
Deep Island Admin
 
Posts: 2966
Joined: Mon May 05, 2008 5:50 am
Location: Germany

Re: Global variables?

Postby Egon » Mon Apr 19, 2010 12:38 pm

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" ?
Egon #2052375
Who You gonna call? Guild of Doorcallers! #5356672
Eder Tsogal/Delin Marathon
Image
User avatar
Egon
 
Posts: 284
Joined: Fri Nov 16, 2007 9:45 pm

Re: Global variables?

Postby Paradox » Mon Apr 19, 2010 1:14 pm

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.
Paradox
 
Posts: 1290
Joined: Fri Sep 28, 2007 6:48 pm
Location: Canada

Re: Global variables?

Postby D'Lanor » Mon Apr 19, 2010 2:14 pm

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.
"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: Global variables?

Postby diafero » Tue Apr 20, 2010 3:05 am

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).
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
diafero
Deep Island Admin
 
Posts: 2966
Joined: Mon May 05, 2008 5:50 am
Location: Germany


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron