Avantar wrote:I will look at your file - parameters is a curse word for me too. I guess (I did not open the file) the reason the description is not showing is because the name of cloned objects are incremented by one. So I'll try and help, else the guru's like The Pixie, Jaynabonne, HK and the rest will have to lend a hand.
Avantar wrote:What I sometimes do is to use a 'for each' loop to go through all the direct children of the room to check for an alias like 'boulder' If it is found then do stuff...
Something like:
foreach (obj, GetDirectChildren("room")) {
if (DoesInherit (obj, "boulder")) {
do stuff
}
}
Above instead of checking against alias, I have checked against an inherit type. So if you have an object type named boulder and each boulder has inherited the boulder object, it might be as simple as that.
Could you perhaps re-upload a demo file I can look at - I can not open the one above.
<object name="object_1">
<alias>small rock</alias>
<attr name="object_type_string" type="string">rock</attr>
</object>
<object name="object_2">
<alias>big boulder</alias>
<attr name="object_type_string" type="string">boulder</attr>
</object>
<object name="object_3">
<alias>tall tree</alias>
<attr name="object_type_string" type="string">tree</attr>
</object>
<object name="object_4">
<alias>HK</alias>
<attr name="coolness_string" type="string">super awesomely cool</attr>
</object>
<function name="check_and act_upon_object_type_string_function">
foreach (object_x, AllObjects () ) {
if (HasString (object_x, "object_type_string") = true) {
if (object_x.object_type_string = "rock") {
// do script 1
} else if (object_x.object_type_string = "boulder") {
// do script 2
} else {
// do script 3
}
} else if (HasString (object_x, "object_type_string") = false) {
// do script 4
}
}
</function>
<game name="blah">
<start type="script">
function_1 (player,monster)
</start>
</game>
<object name="room">
<object name="player">
</alias>HK</alias>
</object>
<object name="monster">
<alias>orc</alias>
</object>
</object>
<function name="function_1" parameters="self, enemy">
msg (self.alias)
msg (enemy.alias)
function_2 (self,enemy)
</function>
<function name="function_2" parameters="ugly,more_ugly">
msg (ugly.alias)
msg (more_ugly.alias)
</function>
onimike wrote:I have no idea about parameters and how to use them, if you could easily explain that would be appreciated. How do I call all objects "boulder" even clone in one instance? Like I want the "rock" to read any object "boulder then sharpen how would I do that with the clones besides reading each one separately? Thanks for your time and help.
HegemonKhan wrote:(Avantar already beat me to it, hehe)
a simple method for getting specific Objects (as an alternative to using Commands'~Functions' parameters):
simply give the Object an unique String attribute value (or an Object Type, but let's ignore these to keep this simple for you):
an example:<object name="object_1">
<alias>small rock</alias>
<attr name="object_type_string" type="string">rock</attr>
</object>
<object name="object_2">
<alias>big boulder</alias>
<attr name="object_type_string" type="string">boulder</attr>
</object>
<object name="object_3">
<alias>tall tree</alias>
<attr name="object_type_string" type="string">tree</attr>
</object>
<object name="object_4">
<alias>HK</alias>
<attr name="coolness_string" type="string">super awesomely cool</attr>
</object>
<function name="check_and act_upon_object_type_string_function">
foreach (object_x, AllObjects () ) {
if (HasString (object_x, "object_type_string") = true) {
if (object_x.object_type_string = "rock") {
// do script 1
} else if (object_x.object_type_string = "boulder") {
// do script 2
} else {
// do script 3
}
} else if (HasString (object_x, "object_type_string") = false) {
// do script 4
}
}
</function>
foreach (boulder, AllObjects ()) {
if (HasString (boulder, "rock") = true) {
if (boulder.object_type_string = "rock") {
if (not Got(sharp stone)) {
IncreaseObjectCounter (sharp stone, "volume")
AddToInventory (sharp stone)
msg ("Pounding on the side of the boulder for a few seconds<br/>a chunk falls off leaving a perfect hatchet shaped blade, <br/>now to find a way to tie it to a handle.")
}
else if (Got(sharp stone)) {
IncreaseObjectCounter (sharp stone, "volume")
msg ("Pounding on the side of the boulder for a few seconds<br/>a chunk falls off leaving a perfect hatchet shaped blade, <br/>now to find a way to tie it to a handle.")
}
}
}
}
foreach (boulder, AllObjects ()) {
if (HasString (boulder, "rock") = true) {
sharp stone crafting
}
}
if (not Got(sharp stone)) {
IncreaseObjectCounter (sharp stone, "volume")
AddToInventory (sharp stone)
msg ("Pounding on the side of the boulder for a few seconds<br/>a chunk falls off leaving a perfect sharp stone, <br/>now to find a way to tie it to a handle.")
}
else if (Got(sharp stone)) {
IncreaseObjectCounter (sharp stone, "volume")
msg ("Smashing rock against the boulder a chuck falls off leaving you a sharp stone.")
}
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="testing game stuff">
<gameif>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
<author>HegemonKhan</author>
<start type="script">
check_and act_upon_object_type_string_function
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="object_1">
<inherit name="editor_object" />
<alias>small rock</alias>
<attr name="object_type_string" type="string">rock</attr>
</object>
<object name="object_2">
<inherit name="editor_object" />
<alias>big boulder</alias>
<attr name="object_type_string" type="string">boulder</attr>
</object>
<object name="object_3">
<inherit name="editor_object" />
<alias>tall tree</alias>
<attr name="object_type_string" type="string">tree</attr>
</object>
<object name="object_4">
<inherit name="editor_object" />
<alias>HK</alias>
<attr name="coolness_string" type="string">super awesomely cool</attr>
</object>
</object>
<function name="check_and act_upon_object_type_string_function">
foreach (object_x, AllObjects () ) {
if (HasString (object_x, "object_type_string") = true) {
if (object_x.object_type_string = "rock") {
msg ("11111")
} else if (object_x.object_type_string = "boulder") {
msg ("22222")
} else {
msg ("33333")
}
} else if (HasString (object_x, "object_type_string") = false) {
msg ("44444")
}
}
</function>
</asl>
foreach (boulder, AllObjects ()) {
if (HasString (boulder, "rock") = true) {
if (boulder.object_type_string = "rock") {
if (not Got(sharp stone)) {
IncreaseObjectCounter (sharp stone, "volume")
AddToInventory (sharp stone)
msg ("Pounding on the side of the boulder for a few seconds<br/>a chunk falls off leaving a perfect hatchet shaped blade, <br/>now to find a way to tie it to a handle.")
}
else if (Got(sharp stone)) {
IncreaseObjectCounter (sharp stone, "volume")
msg ("Pounding on the side of the boulder for a few seconds<br/>a chunk falls off leaving a perfect hatchet shaped blade, <br/>now to find a way to tie it to a handle.")
}
}
}
}
if (HasString (boulder, "rock") = true) {
if (boulder.object_type_string = "rock") {
game.team_objectlist = split ("HK;Onimike;Bob;Bill;Bubba", ";")
foreach (team_member, game.team_objectlist) {
if (team_member.name = "HK") {
invoke (team_member.run_laps_script)
// HK is so cruel to himself, lol
} else if (team_member.name = "Onimike") {
invoke (team_member.eat_ice_cream_and_watch_HK_running_laps_laughing_at_him_script)
// LUCKY !!!
} else if (team_member.name ="Bob") {
invoke (team_member.death_script)
// HK is evil to Bob, hehe :D
} else {
invoke (team_member.rest_script)
// HK needs to move on, to finish this post... lol
}
}
if (HasString (this_is_just_a_temporary_placeholder_variable, "the_string_attribute's_NAME") = true) {
if (this_is_just_a_temporary_placeholder_variable.string_attribute's_NAME = "the_string_attribute's_VALUE") {
foreach (W, AllObjects ()) {
if (HasString (W, "rock") = true) {
if (not Got(sharp stone)) {
IncreaseObjectCounter (sharp stone, "volume")
AddToInventory (sharp stone)
msg ("Pounding on the side of the boulder for a few seconds<br/>a chunk falls off leaving a perfect sharp stone, <br/>now to find a way to tie it to a handle.")
}
else if (Got(sharp stone)) {
IncreaseObjectCounter (sharp stone, "volume")
msg ("Smashing rock against the boulder a chuck falls off leaving you a sharp stone.")
}
}
}
if (HasString (boulder, "rock") = true) {
if (boulder.object_type_string = "rock") {
<object name="apple">
<attr name="color_string" type="string">red</attr>
</object>
<object name="berry">
<attr name="color_string" type="string">blue</attr>
</object>
<object name="lemon">
<attr name="color_string" type="string">yellow</attr>
</object>
game.mylist = split ("apple;berry;lemon", ";")
foreach (K, game.mylist) {
if (HasString (K, "color_string") {
msg ("color")
if (K.color_string = "red") {
msg ("red apple")
} else if (K.color_string = "blue") {
msg ("blue berry")
} else if (K.color_string = "yellow") {
msg (" yellow lemon")
}
}
}
outputs:
color
color
color
red apple
blue berry
yellow lemon
foreach (boulder, AllObjects ()) {
if (HasString (boulder, "rock") = true) {
sharp stone crafting
}
}
foreach (obj, GetDirectChildren(game.pov.parent)()) {
if (DoesInherit(obj, "BoulderType") {
// Do whatever you wanted to do with obj.
}
}
Avantar wrote:Did you manage to get this sorted?foreach (boulder, AllObjects ()) {
if (HasString (boulder, "rock") = true) {
sharp stone crafting
}
}
AllObjects() will check for all objects in the entire game. I would rather use another Scope like HK said. Maybe like GetDirectChildren("room") or something.
Even the 'if' statement I would check against something else to make it more logical - so I can understand it!
The basic idea imo is just to check if there is a boulder present in that room and if so craft a sharp stone or something.
jaynabonne wrote:Just be sure to call the boulder type "BoulderType" (or something unique). It must have a different name from your "boulder" object.