Open Rookfighter opened 8 years ago
A file for a room might look like this:
description : A dark room with old furniture. Everyhing is covered with scratches. After the door closes behind you, the darkness is absolute. You can't see anything.
doors :
WEST:
nextRoom : bathroom
locked : false
NORTH:
nextRoom : livingroom
locked : true
items: []
onEvent :
- name : itemUsed
conditions :
- usedItem : burning candle
actions :
- createItem :
itemName : couch
place : room
- createItem :
itemName : carpet
place : room
- printText : You light the candle and the content of the room becomes visible. You can see an old couch and worn off carpet.
- name : itemUsed
conditions :
- usedItem : key
actions :
- destroyItem : key
- unlockDoor : NORTH
- printText : You unlocked the door to the livingroom.
Actions and conditions are translated into corresponding engine functions and allow a highly flexible way for scripting events.
same in json:
{
"description" : "A dark room with old furniture. Everyhing is covered with scratches. After the door closes behind you, the darkness is absolute. You can't see anything.",
"doors" :
[
{
"direction" : "WEST",
"nextRoom" : "bathroom",
"locked" : false
},
{
"direction" : "NORTH",
"nextRoom" : "livingroom",
"locked" : true
}
],
"items" : [],
"onEvent" :
[
{
"name" : "itemsCombined",
"conditions" :
[
{"usedItem" : "candle"},
{"usedItem" : "lighter"}
],
"actions" :
[
{"destroyItem" : "candle"},
{"destroyItem" : "lighter"},
{
"createItem" :
{
"itemName" : "burning candle",
"place" : "inventory"
}
},
{
"createItem" :
{
"itemName" : "couch",
"place" : "room"
}
},
{
"createItem" :
{
"itemName" : "carpet",
"place" : "room"
}
},
{"printText" : "You light the candle and the content of the room becomes visible. You can see an old couch and worn off carpet."}
]
},
{
"name" : "itemUsed",
"conditions" :
[
{"usedItem" : "key"},
{"usedDoor" : "NORTH"}
],
"actions" :
[
{"destroyItem" : "key"},
{"unlockDoor" : "NORTH"},
{"printText" : "You unlocked the door to the livingroom."}
]
}
]
}
Item file:
items:
key:
takeable : true
useable : true
couch:
takeable : false
useable : false
candle:
takeable : true
useable : false
lighter:
takeable : true
useable : false
burning candle:
takeable : true
useable : true
combinations:
- burning candle: [candle, lighter]