How to start writing Python script for UrU

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

How to start writing Python script for UrU

Postby Marcello » Sat Jun 28, 2008 1:20 pm

Hi all,

I am well voiced in PhP and can do a fair bit of Javascript and even know some Java syntax. I have an enormous book on Python here and don't think basic syntax, conditions, etc. should be a problem. But... I have no clue how to start working all of this into Uru. Is there a list of object, references, etc. that I can use? Sample script even maybe? For starters i would like to be able to start and stop texture animations, change the colors of light or objects in general, etc.

Any directions are helpful!

thnx

Marcello
User avatar
Marcello
 
Posts: 374
Joined: Sun Nov 04, 2007 8:59 am
Location: Haarlem, The Netherlands

Re: How to start writing Python script for UrU

Postby Grogyan » Sat Jun 28, 2008 3:12 pm

I'm learning by attempting to write a script for Blender, then i'll move onto Uru.

D'Lanor's journal template could be a start, or just decompile the .py files from the python.pak in your uru install
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

Re: How to start writing Python script for UrU

Postby Tsar Hoikas » Sat Jun 28, 2008 6:34 pm

Python in Uru is pretty simple, you can get a great grasp of it by reading some of Cyan's code. For starters, you might look at something like xAgeSDLBoolShowHide.py

However, I'll summarize some things here.

Python classes used in Plasma need to derive from ptModifier or ptResponders. ptModifiers are usually only reffed from the plSceneObject while ptResponders are usually called through complex logic interfaces.

In your class, you can override the following methods

    OnServerInitComplete
    This is called when (in multiplayer) you are done talking to the server and the script is loaded.

    OnFirstUpdate
    This seems to be called sometime after OnServerInitComplete yet before linkin occurs

    OnSDLNotify
    This is called when an SDL Variable that you have registered for notify is changed

    OnBehaviorNotify
    This is called when a ptAvatar who you have registered for behavior notify has done a behavior

    OnNotify
    This is called when a registered notify (ptAttribute i.e.) throws a message

    OnTimer
    This happens on a scheduled time from PtAtTimeCallback

Anyway, those are the basics. There are a few more methods that you could use, but they're likely not to be too useful right now (I don't see you needing to fetch the public age list)... Have fun!
Image
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 2180
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: How to start writing Python script for UrU

Postby MustardJeep » Sun Jun 29, 2008 9:22 am

Thanks Hoikas that helps me a bit also. :D
MustardJeep
 
Posts: 129
Joined: Thu Oct 04, 2007 1:31 pm

Re: How to start writing Python script for UrU

Postby Marcello » Sun Jun 29, 2008 11:58 am

Thnx guys that should give me a start.
User avatar
Marcello
 
Posts: 374
Joined: Sun Nov 04, 2007 8:59 am
Location: Haarlem, The Netherlands


Return to Scripting

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron