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 57: Line 57:
 
     import uam
 
     import uam
 
     uam.DisplayJournal("Thanks for reading me!", True)
 
     uam.DisplayJournal("Thanks for reading me!", True)
 +
</source>
 +
 +
 +
==DisplayLinkingBook==
 +
This will display the linking book to another fan Ages.  It will automatically show the appropriate linking image from Uru's /img folder, and it will automatically link the player there if they click on the image.  It's as simple as that!
 +
 +
To show the linking book for Aerie, using the standard link-in point:
 +
<source lang="python">
 +
    import uam
 +
    uam.DisplayLinkingBook("Aerie", "LinkInPointDefault")
 +
</source>
 +
 +
 +
==EnableReltoPage==
 +
This is only to be used on Relto Pages that *you* have yourself made.  Most Relto pages will probably be had by players by default.  But a fan-made Relto page can be set to be "unattained" by default, so that the player must ear it, and calling this will give it to them.  So you would want to call this after they have solved a puzzle or such.  It will cause their Relto book to flash too, just like when collecting one of Cyan's Relto pages.
 +
 +
If your Relto page is called "Personal_District_UamPage-DustinsFancyReltoThing.prp", you might do this example.  (Note that the name of the page does not include the "UamPage-" part.)
 +
<source lang="python">
 +
    import uam
 +
    if puzzlesolved==True:
 +
        uam.EnableReltoPage("DustinsFancyReltoThing")
 
</source>
 
</source>

Revision as of 23:56, 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)


DisplayLinkingBook

This will display the linking book to another fan Ages. It will automatically show the appropriate linking image from Uru's /img folder, and it will automatically link the player there if they click on the image. It's as simple as that!

To show the linking book for Aerie, using the standard link-in point:

    import uam
    uam.DisplayLinkingBook("Aerie", "LinkInPointDefault")


EnableReltoPage

This is only to be used on Relto Pages that *you* have yourself made. Most Relto pages will probably be had by players by default. But a fan-made Relto page can be set to be "unattained" by default, so that the player must ear it, and calling this will give it to them. So you would want to call this after they have solved a puzzle or such. It will cause their Relto book to flash too, just like when collecting one of Cyan's Relto pages.

If your Relto page is called "Personal_District_UamPage-DustinsFancyReltoThing.prp", you might do this example. (Note that the name of the page does not include the "UamPage-" part.)

    import uam
    if puzzlesolved==True:
        uam.EnableReltoPage("DustinsFancyReltoThing")