1 2 3 4 5 6 7 8 9
1 S
2
3
4
5
6 P
7
8
9
1 2 3 4 5 6 7 8 9
1
2
3 P
4
5
6 S
7
8
9
An example (combining the "if" script with an "setting an Attribute" script):
if (orc.dead = true) {
msg ("The orc is already dead, silly.")
} else if (orc.dead = false) {
msg ("The orc is still alive.")
}
the wise owl Object's 'inquire about' (custom~self-made) Verb:
show menu ("What topic?", split ("dragon;sword;princess", ";"), false) {
// you choose: "dragon"
// for 'show menu' and 'get input' built-in functions, quest internally automaticallys sets the variable: result = your_choice
invoke (ScriptDictionaryItem (global_data_object.topic_string_dictionary, result)
// "dragon" -> msg ("The evil dragon kidnapped the princess.")
// outputs: The evil dragon kidnapped the princess.
}
and our "global_data_object" ('info~data storage object'):
<object name="global_data_object">
<inherit name="editor_object" />
<attr name="topic_string_dictionary">
// this is probably the wrong syntax~format, but I'm too lazy to look it up:
<item key="dragon">
msg ("The evil dragon kidnapped the princess.")
</item>
<item key="sword">
msg ("only the legendary dragon slayer sword can kill the evil dragon.")
</item>
<item key="princess">
msg ("if you rescue her, you'll become the new king, and have many kids with the beautiful princess, happily ever after.")
</item>
</attr>
</object>
Shmabz wrote:but just maybe a code which will find the room values and store them?
<!--Saved by Quest 5.4.4873.16527-->
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="SlenderQUEST">
<gameid>b8c83e8c-3aa9-4646-905f-797fb4a8f96c</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
<start type="script">
grid_size_x = 9
grid_size_y = 9
//
msg ("Generating " + grid_size_x + "x" + grid_size_y + " grid of rooms...")
//
coords_list = NewList()
for (coord_y, 0, grid_size_y - 1) {
for (coord_x, 0, grid_size_x - 1) {
temp = NewList()
list add (temp, coord_x)
list add (temp, coord_y)
list add (coords_list, temp)
}
}
//
room_list = NewObjectList()
foreach (coords, coords_list) {
x = ListItem(coords, 0)
y = ListItem(coords, 1)
room_name = "Room" + x + y
create (room_name, "editor_room")
room_obj = GetObject(room_name)
room_obj.x = x
room_obj.y = y
room_obj.alias = "dark forest"
list add (room_list, room_obj)
}
//
dirs = NewStringDictionary()
dictionary add (dirs, "north", "0 -1")
dictionary add (dirs, "east", "1 0")
dictionary add (dirs, "south", "0 1")
dictionary add (dirs, "west", "-1 0")
//
foreach (room, room_list) {
foreach (dir, dirs) {
xy = Split(StringDictionaryItem(dirs, dir), " ")
dx = ToInt(StringListItem(xy, 0))
dy = ToInt(StringListItem(xy, 1))
target_x = room.x + dx
target_y = room.y + dy
target_room = "Room" + target_x + target_y
target_room_obj = GetObject(target_room)
if (not target_room_obj = null) {
create exit (dir, room, target_room_obj, dir + "direction")
}
}
}
//
MoveObject (player, Room00)
slenderman_starts_in = "Room" + GetRandomInt(0, grid_size_x - 1) + GetRandomInt(1, grid_size_y -1)
MoveObject (slenderman, GetObject(slenderman_starts_in))
</start>
<gridmap type="boolean">false</gridmap>
</game>
<object name="limbo">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="slenderman">
<inherit name="editor_object" />
<inherit name="male" />
</object>
</object>
<turnscript name="chase">
<enabled />
<script><![CDATA[
player_x = game.pov.parent.x
player_y = game.pov.parent.y
//
slenderman_x = slenderman.parent.x
slenderman_y = slenderman.parent.y
//
dx = player_x - slenderman_x
if (dx > 0) {
new_slenderman_x = slenderman_x + 1
}
else if (dx = 0) {
new_slenderman_x = slenderman_x
}
else {
new_slenderman_x = slenderman_x - 1
}
//
dy = player_y - slenderman_y
if (dy > 0) {
new_slenderman_y = slenderman_y + 1
}
else if (dy = 0) {
new_slenderman_y = slenderman_y
}
else {
new_slenderman_y = slenderman_y - 1
}
slenderman_moves_to = "Room" + new_slenderman_x + new_slenderman_y
MoveObject (slenderman, GetObject(slenderman_moves_to))
msg ("You are at " + game.pov.parent.x + " " + game.pov.parent.y)
msg ("And slenderman is at " + slenderman.parent.x + " " + slenderman.parent.y + ", watch out!")
if (slenderman.parent = game.pov.parent) {
msg ("slenderman catches you!")
finish
}
]]></script>
</turnscript>
</asl>
<turnscript name="global_turnscript">
<enabled />
<script>
game.turns = game.turns + 1
</script>
</turnscript>
<object name="game">
// attributes~scripts
<attr name="turns" type="int">0</attr>
<attr name="changedturns" type="script">
if (game.turns = 5 or game.turns = 10 or // etc etc etc) {
move_slenderman_function
}
</attr>
<attr name="statusattributes" type="simplestringdictionary">turns =</attr>
// attributes~scripts
</object>
shmabz wrote:Anyway, you suggested using a dictionary to index the rooms with stuff already in them? Well im gonna be honest, i have no idea how to do that :/ Could you maybe send me an example or something to help me along or start me off? I just have no idea on what the syntax is and how to call things back from dictionaries or use the "if" command to check up etc. Sorry
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>eef801a1-4e6b-4b0a-bdbf-8f3ecfa8389c</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<turns type="int">0</turns>
<statusattributes type="simplestringdictionary">turns=</statusattributes>
<start type="script">
msg ("Important Note:")
msg ("Type in: help")
</start>
</game>
<object name="homeland">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<object name="grassland">
<inherit name="editor_room" />
</object>
<object name="plains">
<inherit name="editor_room" />
</object>
<object name="desert">
<inherit name="editor_room" />
</object>
<object name="tundra">
<inherit name="editor_room" />
</object>
<object name="swampland">
<inherit name="editor_room" />
</object>
<object name="mountains">
<inherit name="editor_room" />
</object>
<object name="forest">
<inherit name="editor_room" />
</object>
<object name="wasteland">
<inherit name="editor_room" />
</object>
<object name="coastland">
<inherit name="editor_room" />
</object>
<object name="hills">
<inherit name="editor_room" />
</object>
<command name="help_command">
<pattern>help</pattern>
<script>
help_function
</script>
</command>
<command name="explore_command">
<pattern>explore</pattern>
<script>
explore_function
</script>
</command>
<command name="travel_command">
<pattern>travel</pattern>
<script>
travel_function
</script>
</command>
<object name="data_object">
<inherit name="editor_object" />
<travel_string_list type="simplestringlist">homeland</travel_string_list>
<homeland_events_string_list type="simplestringlist">grassland_discovery;plains_discovery;desert_discovery;tundra_discovery;swampland_discovery;forest_discovery;mountains_discovery;hills_discovery;wasteland_discovery;coastland_discovery</homeland_events_string_list>
<homeland_events_script_dictionary type="scriptdictionary">
<item key="grassland_discovery">
list add (data_object.travel_string_list, "grassland")
msg ("You've discovered the grassland! Now, you can travel to the grassland and explore it!")
</item>
<item key="plains_discovery">
list add (data_object.travel_string_list, "plains")
msg ("You've discovered the plains! Now, you can travel to the plains and explore it!")
</item>
<item key="desert_discovery">
list add (data_object.travel_string_list, "desert")
msg ("You've discovered the desert! Now, you can travel to the desert and explore it!")
</item>
<item key="tundra_discovery">
list add (data_object.travel_string_list, "tundra")
msg ("You've discovered the tundra! Now, you can travel to the tundra and explore it!")
</item>
<item key="swampland_discovery">
list add (data_object.travel_string_list, "swampland")
msg ("You've discovered the swampland! Now, you can travel to the swampland and explore it!")
</item>
<item key="forest_discovery">
list add (data_object.travel_string_list, "forest")
msg ("You've discovered the forest! Now, you can travel to the forest and explore it!")
</item>
<item key="mountains_discovery">
list add (data_object.travel_string_list, "mountains")
msg ("You've discovered the mountains! Now, you can travel to the mountains and explore it!")
</item>
<item key="hills_discovery">
list add (data_object.travel_string_list, "hills")
msg ("You've discovered the hills! Now, you can travel to the hills and explore it!")
</item>
<item key="wasteland_discovery">
list add (data_object.travel_string_list, "wasteland")
msg ("You've discovered the wasteland! Now, you can travel to the wasteland and explore it!")
</item>
<item key="coastland_discovery">
list add (data_object.travel_string_list, "coastland")
msg ("You've discovered the coastland! Now, you can travel to the coastland and explore it!")
</item>
</homeland_events_script_dictionary>
</object>
<turnscript name="global_turnscript">
<enabled />
<script>
game.turns = game.turns + 1
</script>
</turnscript>
<function name="help_function">
msg ("Type 'explore' to explore your area.")
msg ("Type 'travel' to travel to different areas.")
</function>
<function name="explore_function"><![CDATA[
switch (game.pov.parent) {
case (homeland) {
result_1 = ListCount (data_object.homeland_events_string_list) - 1
if (result_1 >= 0) {
result_2 = StringListItem (data_object.homeland_events_string_list,GetRandomInt(0,result_1))
invoke (ScriptDictionaryItem (data_object.homeland_events_script_dictionary,result_2))
on ready {
foreach (item_x, split ("grassland_discovery;plains_discovery;desert_discovery;tundra_discovery;swampland_discovery;forest_discovery;mountains_discovery;hills_discovery;wasteland_discovery;coastland_discovery",";")) {
if (result_2 = item_x) {
list remove (data_object.homeland_events_string_list, result_2)
}
}
}
} else {
msg ("There seemingly is nothing left to explore in this area.")
}
}
}
]]></function>
<function name="travel_function">
show menu ("Where do you wish to travel?",data_object.travel_string_list,false) {
if (not game.pov.parent = GetObject (result)) {
game.pov.parent = GetObject (result)
} else {
msg ("You are already at this area.")
ask ("Try again?") {
if (result=true) {
travel_function
} else {
msg ("You realize that you need to discover a new area to travel to first, before you can travel to that place.")
}
}
}
}
</function>
</asl>
myRoomList = NewObjectList()
foreach (obj, AllObjects()) {
if (DoesInherit(obj, "editor_room") = true) {
list add (myRoomList, obj)
}
}
If you have them in a list, you need a new copy of the list, so just newList = oldLIst.
newList = ListCombine(NewObjectList(), oldList)
If you don't have them in a list, you could do it by hand. But that sounds kind of tedious, so I think this would work:
Code: Select allmyRoomList = NewObjectList()
foreach (obj, AllObjects()) {
if (DoesInherit(obj, "editor_room") = true) {
list add (myRoomList, obj)
}
}
grid_size_x = 9
grid_size_y = 9
//
msg ("Generating environment...")
//
coords_list = NewList()
for (coord_y, 0, grid_size_y - 1) {
for (coord_x, 0, grid_size_x - 1) {
temp = NewList()
list add (temp, coord_x)
list add (temp, coord_y)
list add (coords_list, temp)
}
}
//
-----> room_list = NewObjectList()
foreach (coords, coords_list) {
x = ListItem(coords, 0)
y = ListItem(coords, 1)
room_name = "Room" + x + y
create (room_name, "editor_room")
room_obj = GetObject(room_name)
room_obj.x = x
room_obj.y = y
room_obj.alias = "Dark Forest"
room_obj.description = "Countless rows of tall trees extend in all direction with no immediate landmarks in sight. There is a strong feeling of isolation emmanating from the forest itself."
list add (room_list, room_obj)
}
//
dirs = NewStringDictionary()
dictionary add (dirs, "north", "0 -1")
dictionary add (dirs, "east", "1 0")
dictionary add (dirs, "south", "0 1")
dictionary add (dirs, "west", "-1 0")
//
foreach (room, room_list) {
foreach (dir, dirs) {
xy = Split(StringDictionaryItem(dirs, dir), " ")
dx = ToInt(StringListItem(xy, 0))
dy = ToInt(StringListItem(xy, 1))
target_x = room.x + dx
target_y = room.y + dy
target_room = "Room" + target_x + target_y
target_room_obj = GetObject(target_room)
if (not target_room_obj = null) {
create exit (dir, room, target_room_obj, dir + "direction")
}
}
}
//
Room00.description = "There appears to be a path leading to the south."
Room01.description = "There appears to be a path leading to the north and south."
Room02.description = "There appears to be a path leading to the north and east."
Room07.description = "There appears to be a path leading to the east."
//
Room12.description = "There appears to be a path leading to the east and west."
Room15.description = "There appears to be a path leading to the east and south."
Room16.description = "There appears to be a path leading to the north and south."
Room17.description = "There appears to be a path leading to the north, east and west."
//
Room21.description = "There appears to be a path leading to the east and south."
Room22.description = "There appears to be a path leading to the north, south and west."
Room23.description = "There appears to be a path leading to the north and south."
Room24.description = "There appears to be a path leading to the north and south."
Room25.description = "There appears to be a path leading to the north and west."
Room27.description = "There appears to be a path leading to the east and west."
//
Room31.description = "There appears to be a path leading to the east and west."
Room37.description = "There appears to be a path leading to the east and west."
//
Room41.description = "There appears to be a path leading to the east, south and west."
Room42.description = "There appears to be a path leading to the north and south."
Room43.description = "There appears to be a path leading to the north and south."
Room44.description = "There appears to be a path leading to the north and east."
Room47.description = "There appears to be a path leading to the east and west."
//
Room50.description = "There appears to be a path leading to the east and south."
Room51.description = "There appears to be a path leading to the north and west."
Room54.description = "There appears to be a path leading to the east and west."
Room57.description = "There appears to be a path leading to the east and west."
//
Room60.description = "There appears to be a path leading to the east and west."
Room64.description = "There appears to be a path leading to the east and west."
Room66.description = "There appears to be a path leading to the east and south."
Room67.description = "There appears to be a path leading to the north, south and west."
Room68.description = "There appears to be a path leading to the north."
//
Room70.description = "There appears to be a path leading to the south and west."
Room71.description = "There appears to be a path leading to the north and south."
Room72.description = "There appears to be a path leading to the north and south."
Room73.description = "There appears to be a path leading to the north and south."
Room74.description = "There appears to be a path leading to the north, east and west."
Room76.description = "There appears to be a path leading to the east and west."
//
Room84.description = "There appears to be a path leading to the south and west."
Room85.description = "There appears to be a path leading to the north and south."
Room86.description = "There appears to be a path leading to the north and west."
//
msg ("Building terrain...")
msg ("Adding movement...")
msg ("Finalising transitions...")
msg ("Inserting player...")
msg ("Inserting Slenderman...")
//
object_starts_in = "Room" + GetRandomInt(0, grid_size_x - 1) + GetRandomInt(1, grid_size_y - 1)
MoveObject (bigtree, GetObject(object_starts_in))
msg (object_starts_in)
object_starts_in = "Room" + GetRandomInt(0, grid_size_x - 1) + GetRandomInt(1, grid_size_y - 1)
MoveObject (slenderman, GetObject(object_starts_in))
//
MoveObject (player, Room44)
----> placementList = ListCombine(NewObjectList(), room_List)
listLength = ListCount (placementList)
index = GetRandomInt(0, listLength - 1)
placementRoom = ObjectListItem (placementList, index)
MoveObject (friend, GetObject(placementRoom))
msg (placementRoom)
list remove (placementList, placementRoom)