pip3 install arena-py
Ok, now let’s get started!
Replace [host], [realm], and [scene] with your desired ARENA webserver main host, realm, and scene name, respectively.
export MQTTH=[host] # ARENA webserver main host export REALM=[realm] export SCENE=[scene]
from arena import *
arena = Scene()
You can also pass host and scene as arguments, if you don’t want to use environmental variables. These must be keyword arguments:
scene = Scene(host=[host], scene=[scene])
Note: arena-py will always favor environmental variables over arguments.
arena-py works by running tasks in an event loop, so we need a main task for our sample program.
Inside main(), lets make a box!
box = Box(object_id="my_box", position=Position(0,4,-2), scale=Scale(2,2,2))
Note the input arguments. The names must match what they will be in the ARENA JSON specification. We don’t have to worry too much about that now, but keep this in mind, as typos will be very bad!
Box is a type of “Object”. See objects.
Position and Scale are what we call “Attributes”. See attributes.
Now, outside of main, we will write:
Now, go into the scene to see your box!
from arena import * # setup library scene = Scene(host="arenaxr.org", scene="example") def main(): # make a box box = Box(object_id="my_box", position=Position(0,4,-2), scale=Scale(2,2,2)) # add the box scene.add_object(box) # add and start tasks scene.run_once(main) scene.run_tasks()