Wiki
Clone wikiTiny_Text_Worlds / World XML Overview
To help anyone thinking of writing a story using Tiny Text Worlds (including me), here is a node by node introduction to the XML file the stories are written in.
#actionPrompt
<actionPrompt defaultText="Choose an action for " />
#cancel
<cancel defaultText="Cancel" />
#startUpAction
<startUpAction objectId="exampleObject" actionId="introduction"/>
#player
<player location="Place_ID"/>
#userGlobalObjects
<useGlobalObjects flag="false"/>
#places
<places> <place id="global" > <object id="exampleGlobalObject" /> </place> <place id="Place_ID" > <object id="exampleObject" /> </place> </places>
#objects Inside the <objects> node we put all the objects we will use in our story. Objects can be anything that we want the player to be able to see text for like an apple, table or car or the description of a place.
The first object is the generalActions object which is used by TTW internally, it's best not to alter these. So let's skip them for now.
<!-- System objects used by all worlds --> <object id="generalActions" name="Hidden" state="start"> <state id="start" visible="false"> </state> <action id="ok" name="Hidden" visibleStates=""> </action> </object>
Here is the exampleObject from tutorialWorld.xml
<!-- An Example Object --> <object id="exampleObject" name="ExampleObject" state="start"> <state id="start" visible="true"> <preNameText>This text goes before the name of the object. Then the objectName comes next: </preNameText> <postNameText>. Then this text comes after the object name.</postNameText> </state> ... SHORTENED ... </object>
Inside the object node are descriptions of that object's possible states. Above we can see the state with id "start" which has a visible="true" attribute. When the exampleObject's state is "start" TTW will look for a state with id="start" for more information. Once found it uses the visible to determine whether to show anything to the player. In this case exampleObjects "start" state has visible="true" so TTW will look inside the state node for test to display. TTW will then displays the preNameText:
This text goes before the name of the object. Then the objectName comes next:
ExampleObject
. Then this text comes after the object name.
#action Objects can have actions which are performed by clicking on their name in the browser. These actions are defined inside the object's node. There is currently no limit to the number of actions that can be defined on an object. There are two actions in tutorialWorld.xml let's take a look at the second action node in exampleObject:
<action id="exampleAction" name="Example action" visibleStates="exampleObject:start" > <say> <text>When the exampleAction is clicked. It has a "say" node which prints this text to the screen... </text> <option type="object" text="OK" visibleStates="*" targetObjectId="generalActions" actionId="ok" /> </say> <set targetObjectId="exampleObject" targetAttribute="state" acceptableStartValues="*" newValue ="notStartAnymore"/> </action>
visibleStates="object1:ready object2:ready"
We can also use && (and) if we need to different object states to have specific states:
visibleStates="object1:ready&&object2:ready"
Finally we can use } ( Used as a stand in for the > greater than symbol) and { ( Used as a stand in for the < less than symbol) to work with numerical states:
visibleStates="score:}5"
There are currently two things an action node can do say and set which are described below.
#say
<say> <text>When the exampleAction is clicked. It has a "say" node which prints this text to the screen... </text> <option type="object" text="OK" visibleStates="*" targetObjectId="generalActions" actionId="ok" /> </say>
TTW displays an option if the objects state matches one of the values in visibleStates this works the same as the visibleStates described under the action heading.
#set
<set targetObjectId="exampleObject" targetAttribute="state" acceptableStartValues="*" newValue ="notStartAnymore"/>
TTW will find the the target object whose id is listed in targetObjectId
Then TTW looks at the targetAtribute of the target object and find what if it matched one of the acceptableStartValues ( * means any value is fine). We can set multiple acceptableStartValues by separating them with spaces:
acceptableStartValues="awake asleep dead"
acceptableStartValues=}5"
If the target objects attribute is OK then TTW sets the target objects attribute to what ever we have listed in newValue. We can do basic arithmetic using set by using + or - in the newValue attribute:
<set targetObjectId="elevator" targetAttribute="state" acceptableStartValues="{3" newValue ="+1"/>
We can use set to change the state, name and also the players location.
Updated