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"
(5 intermediate revisions by 2 users not shown) | |||
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. The rule for what can be used and what can't is very simple: Anything that begins with a "_" can't be used, and everything else can! (This applies to [[UamVars]] too.) So don't import any UAM modules that begin with "_" and don't use any functions that begin with "_". It's thus easy to keep clear what is reliable and cross-platform, and what isn't! | ||
=Commands= | =Commands= | ||
Line 7: | Line 10: | ||
Here's an example of setting the value to "red" if it is currently set to "green": | Here's an example of setting the value to "red" if it is currently set to "green": | ||
<source lang="python"> | <source lang="python"> | ||
− | + | import uam | |
− | + | puzcolor = uam.GetAgeChronicle("PuzzleColour") | |
− | + | if puzcolor=="green": | |
− | + | puzcolor = "red" | |
− | + | uam.SetAgeChronicle("PuzzleColour",puzcolor) | |
</source> | </source> | ||
+ | |||
==LinkToAge== | ==LinkToAge== | ||
Line 19: | Line 23: | ||
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. | 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. | ||
<source lang="python"> | <source lang="python"> | ||
− | + | import uam | |
− | + | uam.LinkToAge("EderRiltehInaltahv","LinkInPointDefault") | |
</source> | </source> | ||
Line 29: | Line 33: | ||
E.g. | E.g. | ||
<source lang="python"> | <source lang="python"> | ||
− | + | import uam | |
− | + | 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"> | ||
+ | import uam | ||
+ | def SayHello(): | ||
+ | uam.PrintKiMessage("Ah my friend, you've returned!") | ||
+ | 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> | ||
+ | |||
+ | |||
+ | ==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 earn 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. For more information, see [[UAM/ReltoPages]] | ||
+ | |||
+ | 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"> | <source lang="python"> | ||
− | + | import uam | |
− | + | if puzzlesolved==True: | |
− | + | uam.EnableReltoPage("DustinsFancyReltoThing") | |
− | |||
</source> | </source> |
Latest revision as of 04:15, 24 October 2010
This page lists some of the many things you can do with the "uam" Python module!
Contents
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. The rule for what can be used and what can't is very simple: Anything that begins with a "_" can't be used, and everything else can! (This applies to UamVars too.) So don't import any UAM modules that begin with "_" and don't use any functions that begin with "_". It's thus easy to keep clear what is reliable and cross-platform, and what isn't!
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 earn 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. For more information, see UAM/ReltoPages
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")