|
OK, so you want to get started programming in Jython. How do you do it? There's a lot of documentation on this website, and we're writing tons more, but you have to read this first, or you'll be totally lost. Contents
Step 1: Stuff You NeedYou need:
That's all you need. You do not need Jython or Python or Java on your home computer. You can download them if you like, to practice writing code, but you won't be able to call any game functions. Step 2: Start CodingWe use "Python" and "Jython" interchangeably. We use Jython, which is a version of Python written for Java. Confused yet? You can create your own game objects in Jython, ones that do all sorts of neat things. The steps are:
OK, that's the basic overview — let's go into some more details. Create a Jython FileWe've got lots of tutorials, so we won't go into the coding here. Just follow these instructions to try your first "Hello, World!" program. First, copy the following code into your Text Editor, and save it in a file called hello.py, somewhere on your home computer. The best place to put it would be in wyvern/wiz/yourname/py/hello.py, wherever you have wyvern installed, because that's where you will put it on the server. It's nice to have the files in the same places on both computers.
OK, now that you've created hello.py, it's time to upload it to the server.
Upload The FileNow go to the Upload Files dialog in the Map Editor, and fill out the fields like so:
Make sure the path in the File: field is wherever you saved the file on your home machine. Then hit Upload and watch it go. It will be placed in your wiz directory, in a subdirectory called py/, which is a nice place to keep all your python files. Clone the ObjectOK, now log into Wyvern, if you weren't already there, and type:
clone wiz/myname/py/hello.py
It should say:
A new hello tester has been placed in your inventory.
If it doesn't say that, then you've done something wrong — go back to the top and start over again. Now you have a "hello tester" in your inventory. It should look like a jade key, since that's what we set the appearance to. Now type:
hello
And it should tell you:
Hello, World!
That's all there is to it! Using your jython class in an archetypeIf you want to use your object in a map, you can create an archetype to wrap your class. Using the your text editor, create a file called wiz/yourname/arch/hello.arch, and put this inside it:
Just that one line, exactly like it's typed above, except with your wiz name instead of "yourname". Upload it as follows:
Now you can clone the archetype directly:
clone wiz/yourname/arch/hello
You can also see the archetype in the Map Editor, and put it into the map. Now you're ready to go read about coding in Wyvern, which is nontrivial (but at least we have lots of tutorials).
|