Important! Please read the announcement at http://myst.dustbird.net/uru-account.htm
Also! Please read the retirement announcement at http://myst.dustbird.net/uru-retirement.htm

Difference between revisions of "UAM/Python"

From UamWiki
Line 1: Line 1:
 
This page lists some of the many things you can do with the "uam" Python module!
 
This page lists some of the many things you can do with the "uam" Python module!
 +
 +
=General Information=
 +
Although the examples show the "import uam" line all the time, you can normally just write that one time, at the top of the file.
  
 
=Commands=
 
=Commands=
Line 13: Line 16:
 
         uam.SetAgeChronicle("PuzzleColour",puzcolor)
 
         uam.SetAgeChronicle("PuzzleColour",puzcolor)
 
</source>
 
</source>
 +
  
 
==LinkToAge==
 
==LinkToAge==
Line 32: Line 36:
 
     uam.PrintKiMessage("Hello player!")
 
     uam.PrintKiMessage("Hello player!")
 
</source>
 
</source>
 +
  
 
==SetTimer==
 
==SetTimer==
 
This is a sane alternative to Cyan's PtAtTimeCallback function.  This is much cleaner and simpler to use.  Just tell it when you want it to call you back, and what function to call at that time.
 
This is a sane alternative to Cyan's PtAtTimeCallback function.  This is much cleaner and simpler to use.  Just tell it when you want it to call you back, and what function to call at that time.
  
This example will have it wait 4.0 seconds, at which time it will print a message to the screen.  Notice that the function "SayHello" takes no arguments.
+
This example will have it wait 4.0 seconds, at which time it will print a message to the screen.  Notice that the function "SayHello" takes no arguments.  Note that all of this, including the definition for "SayHello", can all be inside another function.
 
<source lang="python">
 
<source lang="python">
 
     import uam
 
     import uam
Line 42: Line 47:
 
         uam.PrintKiMessage("Ah my friend, you've returned!")
 
         uam.PrintKiMessage("Ah my friend, you've returned!")
 
     uam.SetTimer(SayHello, 4.0)
 
     uam.SetTimer(SayHello, 4.0)
 +
</source>
 +
 +
 +
==DisplayJournal and DisplayBook==
 +
This will display a journal to the player.  DisplayJournal shows the version that has lined paper inside, whereas DisplayBook shows the old brown papered book.  The "isOpen" argument tells it whether to show the journal already open or not.  You can only have one book open at a time.
 +
 +
To show an open journal:
 +
<source lang="python">
 +
    import uam
 +
    uam.DisplayJournal("Thanks for reading me!", True)
 
</source>
 
</source>

Revision as of 23:48, 19 October 2010

This page lists some of the many things you can do with the "uam" Python module!

General Information

Although the examples show the "import uam" line all the time, you can normally just write that one time, at the top of the file.

Commands

SetAgeChronicle and GetAgeChronicle

These are variables that are stored in an Age. They are shared between all players in an Age. If one of them hasn't been set, and you try to get it, you'll get "".

Here's an example of setting the value to "red" if it is currently set to "green":

    import uam
    puzcolor = uam.GetAgeChronicle("PuzzleColour")
    if puzcolor=="green":
        puzcolor = "red"
        uam.SetAgeChronicle("PuzzleColour",puzcolor)


LinkToAge

This links the player to an Age immediately.

Here is an example, for if you want to link to the Age "EderRiltehInaltahv". You could also have specified another spawnpoint, but LinkInPointDefault is the normal starting point in an Age.

    import uam
    uam.LinkToAge("EderRiltehInaltahv","LinkInPointDefault")


PrintKiMessage

Print's a message onto the player's KI.

E.g.

    import uam
    uam.PrintKiMessage("Hello player!")


SetTimer

This is a sane alternative to Cyan's PtAtTimeCallback function. This is much cleaner and simpler to use. Just tell it when you want it to call you back, and what function to call at that time.

This example will have it wait 4.0 seconds, at which time it will print a message to the screen. Notice that the function "SayHello" takes no arguments. Note that all of this, including the definition for "SayHello", can all be inside another function.

    import uam
    def SayHello():
        uam.PrintKiMessage("Ah my friend, you've returned!")
    uam.SetTimer(SayHello, 4.0)


DisplayJournal and DisplayBook

This will display a journal to the player. DisplayJournal shows the version that has lined paper inside, whereas DisplayBook shows the old brown papered book. The "isOpen" argument tells it whether to show the journal already open or not. You can only have one book open at a time.

To show an open journal:

    import uam
    uam.DisplayJournal("Thanks for reading me!", True)