Room description with cloned objects?

onimike
Hello all, I have made a clone and refer to the main item as "this" so all features work like normal. The only problem is that the in-room descriptions I put in for the items don't work when cloned so I erased all descriptions but the rock and still nothing. Is there a way to fix this or make where it pops up the description of the item even if cloned?

The Pixie
It looks like the problem is that you do not actually do anything with the rock except check it is held. You need to remove it somehow. What I would do is change the "rock crafting" function to accept a parameter and then send it the rock object (so you need to change both the function and the script that calls the function). If the boulder is there, destroy the rock object (note that destory needs the name of the object, not the object itself, and the name of the clone will not be rock!).

onimike
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.

Avantar
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
It seems I need the StackLibrary.aslx to open the the attached file?

onimike
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.


Lol they really are guru's when It comes to quest. Thanks for the help im trying to get this figured out so I can give my update, also having troubles with wording to check all objects "boulder" to run script. So basically I want to sharpen rock but only around a boulder. Problem is every cloned boulder is different, how do I word it to read all of the "boulder" objects? Should I make a object type and have it read for that?
Well thanks again man this gets more intriguing every day lol :)

Avantar
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.

onimike
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.



yes you will be able to see I have put in smashrock object type to try and read that but no success. I have tried to tell it to run object attribute when you use sharpen but that didn't work either, I know their is a way to code it in even in GUI its just a name game lol.

Avantar
When I want to open the file you attached I get:
"Failed to load game due to the following errors:
*Error: Cannot find 'StackLibrary.aslx' in current path or application/resource path"

So I will need the library in order to open the demo file.

HegemonKhan
Try reading this thread, I try to explain what and how parameters work in my posts in this thread (scroll down a few posts):

viewtopic.php?f=10&t=4423&hilit=parameters

hopefully this helps you, if you got any questions about it, or still don't understand, then ask, and I'll try to help you further.

err... I don't explain parameters much in this thread... (I thought I made some posts that explained parameters well... maybe need to keep searching for more posts of mine about parameters, lol, argh)...

read through this thread (I try to explain parameters in the bottom-half of my last posts, after about commands, so look carefully for it):

viewtopic.php?f=10&t=3700&hilit=parameters

hope this helps

-----

you can also take a look at my (Pertex' code actually) 'combat_code' in my old noobie thread (look at the last~newest posts):

viewtopic.php?t=3348

to see parameters being used, and I think you should be able to understand~follow along it... hopefully.

HegemonKhan
(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>

HegemonKhan
let me try to explain parameters:

they are the means of GETTING+TRANSFERING (and optionally re-naming~labeling) variables~attributes from function to function or command to function or script to function, so in-effect, they act like quasi-global variables (attributes), even though they're local variables.

<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>


Parameters: (position1,position2,position3, etc)

the same positions match up

function_1 (player,monster) to <function name="function_1" parameters="self,enemy">:

self (position 1) = player (position 1)
enemy (position 2) = monster (position 2)

so:

self.alias <==> player.alias <==> HK
enemy.alias <==> monster.alias <==> orc


function_2 (self,enemy) to <function name="function_2" parameters="ugly,more_ugly">:

ugly (position 1) = self (position 1)
more_ugly (position 2) = orc (position 2)

so:

ugly.alias <==> self.alias <==> player.alias <==> HK
more_ugly.alias <==> enemy.alias <==> monster.alias <==> orc

The Pixie
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.

I have not tested this, as I do not have the stack library, but this should work.

Add a parameter to your function. Parameters is the third thing down on the function, click the "Add" and make up a name. Say "obj", for object, without quotes. This adds a parameter, and "obj" is the name of it.

In the function itself, do "Remove object" (seems to be better than destroy, which I said last time). Select expression, and type "obj", without quotes. I think you need that twice in your code. This is using the parameter called "obj".

In the script on the rock, add a parameter. Where it says "Call function", on the right is an "Add". Click that, and type in "this", without quotes. This will send the rock object itself to the function (as the script is attached to the rock, "this" refers to the rock), and will become "obj" once in the function.

onimike
Oh wow I got this morning and seen the Calvary arrived lol. Thank you all so much It will take me a lil to understand every thing here but is much appreciated. I am going to study the codes HK posted and look into parameters Pixie shown. I was going to take out stack lib but can't almost lost my game lol so I will up load stack lib also so if you guys wanted to see for yourselfs. Thanks again to all of you.

onimike
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>


Alright HK im really trying to understand this and have it to where at least an error does not show up but the script is not doing any thing. Is there any way you could post a small demo so I can SEE how its actually put in because all I see is obj_type, obj = type string and im sorry I just don't see where I put what. I made an object_type=smashrock: In smashrock I gave attribute=rock_string=true. I just want to call on the obj_type but not sure what to use in GUI and defiantly don't know the actual coding. I was able to add the coding you posted and put what I thought needs to be in there but didn't work.
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.")
}
}
}
}

This is my base just trying to call the right obj_type.

onimike
Ok so I got this line of script to "work" but for some reason its reading it twice. Here the code and the function.
foreach (boulder, AllObjects ()) {
if (HasString (boulder, "rock") = true) {
sharp stone crafting
}
}


Here is the sharp stone crafting function
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.")
}


So it crafts the item just not sure why it pulls the function twice. Also when I sharpen stone how do I make it read the rock that I am carrying to move to stash room? I have tried AllObject (rock) but I get errors.
Thanks

HegemonKhan
here's a demo game code (if this works in version="550", as I'm still using version="540", lol):

(You may need to change the 'gameid' value, if mine doesn't work for you)

(let me know if this doesn't work due to errors, as I've not tested it, lol)

(create a new Text Adventure game, go into code view, delete all of the default code there, and copy and past my code below into it, save it, play it)

<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>


------------------------------

GUI~Editor help for your comprehension~understanding (match up the below to the~my scripts in the~my code above):

(sorry for not explaining this to you earlier, that was my mistake and cause for your confusion and mistakes in trying to do the coding yourself)

--

Object (it's 'name', ID, string attribute): player

(has no attributes, except for it's Inherited, Object Type, Type Attributes: 'editor_object' and 'editor_player' )

--

Object (it's 'name', ID, string attribute): room

(has no attributes, except for it's Inherited, Object Type, Type Attribute: 'editor_room' )

--

Object (it's 'name', ID, string attribute): object_1

'object_1' Object -> Attributes (Tab) -> Attributes -> Add -> (set up, see below)

(a built-in, non-custom, string attribute)
Attribute 1 Name (ID): alias
Attribute 1 Type: string
Attribute 1 Value: small rock

again: 'object_1' Object -> Attributes (Tab) -> Attributes -> Add -> (set up, see below)

(my own custom string attribute)
Attribute 2 Name: object_type_string
Attribute 2 Type: string
Attribute 2 Value: rock

--

Object: object_2

'object_2' Object -> Attributes (Tab) -> Attributes -> Add -> (set up, see below)

(a built-in, non-custom, string attribute)
Attribute 1 Name (ID): alias
Attribute 1 Type: string
Attribute 1 Value: big boulder

again: 'object_2' Object -> Attributes (Tab) -> Attributes -> Add -> (set up, see below)

(my own custom string attribute)
Attribute 2 Name: object_type_string
Attribute 2 Type: string
Attribute 2 Value: boulder

--

Object: object_3

'object_3' Object -> Attributes (Tab) -> Attributes -> Add -> (set up, see below)

(a built-in, non-custom, string attribute)
Attribute 1 Name (ID): alias
Attribute 1 Type: string
Attribute 1 Value: tall tree

again: 'object_3' Object -> Attributes (Tab) -> Attributes -> Add -> (set up, see below)

(my own custom string attribute)
Attribute 2 Name: object_type_string
Attribute 2 Type: string
Attribute 2 Value: tree

--

Object: object_4

'object_4' Object -> Attributes (Tab) -> Attributes -> Add -> (set up, see below)

(a built-in, non-custom, string attribute)
Attribute 1 Name (ID): alias
Attribute 1 Type: string
Attribute 1 Value: HK

again: 'object_4' Object -> Attributes (Tab) -> Attributes -> Add -> (set up, see below)

(my own custom string attribute)
Attribute 2 Name: object_type_string
Attribute 2 Type: string
Attribute 2 Value: super awesomely cool

HegemonKhan
(ignoring my just posted now demo game code in the post above~prior to this post, in looking at your attempts)

you almost have it right!!!, where you're messing up:

your code (first attempt post of yours):

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.")
}
}
}
}


the mess up (my fault for not explaining this better):

  if (HasString (boulder, "rock") = true) {
if (boulder.object_type_string = "rock") {


explanations:

foreach (this_is_just_a_temporary_placeholder_variable, AllObjects ()) {

You do NOT have to use the 'AllObjects()' Scope, you can use the other Scopes too:

http://docs.textadventures.co.uk/quest/ ... tions.html (the 'S' category: alphabetically organized)

a good conceptual example of the 'foreach' Function:

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
}
}


and, your mistake~confusion (due to me not explaining it):

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") {


about the 'placeholder' variable:

game.team_objectlist = split ("HK;Onimike;Bob;Bill;Bubba", ";")

foreach (team_member, game.team_objeclist) {
-> //
-> // it will run through all of these variables:
-> // team_member = HK
-> // team_member = Onimike
-> // team_member = Bob
-> // team_member = Bill
-> // team_member = Bubba
-> //
-> if (team_member.name = "HK") {

and the same thing (to further explain the 'placeholder' variable):

game.team_objectlist = split ("HK;Onimike;Bob;Bill;Bubba", ";")

foreach (W, game.team_objeclist) {
-> //
-> // it will run through all of these variables:
-> // W = HK
-> // W = Onimike
-> // W = Bob
-> // W = Bill
-> // W = Bubba
-> //
-> if (W.name = "HK") {

---------

it's more complicated if you do:

foreach {
-> 'sharp stone' function

as you got to work with parameters... it'll be hard for me to help you... as I'll need to know exactly what you're trying to do with your code... (or to see your entire game code, or to play your game, lol)

so, instead, don't have that scripting inside of the 'stone smash (or whatever it is called)' function, put it ALL inside of the 'foreach' Function:

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.")
}
}
}


and I think your 'double' results have to do with the messing up of the:

  if (HasString (boulder, "rock") = true) {
if (boulder.object_type_string = "rock") {


which, I've already adressed above.

otherwise, the 'double' (or times x, lol) results that you're getting, is from that the 'foreach' will execute it's scripts (if their conditions are met) for EVERY item in your list used (that meets those scripts' conditions).

for example:

<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

Avantar
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! :lol:

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
You can create a "BoulderType" type. Then have your boulders inherit from it. That allows you to do this (I'm following your lead about how to reference the objects - all objects in the room. You might want a different scope. Reachable? Inventory?)


foreach (obj, GetDirectChildren(game.pov.parent)()) {
if (DoesInherit(obj, "BoulderType") {
// Do whatever you wanted to do with obj.
}
}


If you want to know about the different scopes, check out this page:
http://docs.textadventures.co.uk/quest/scopes.html

Just replace the GetDirectChildren call with the desired scope function.

onimike
Sorry guys been busy and trying to fix pc. No HK I haven't fixed it yet, I have not touched it in days. Thank you HK I will check that demo out tonight some time also I will be going and addressing the issue tomorrow so as soon as I do I will have the fix code up. And Jay I do like the GetDirecrtChildren script but one question, I have a problem inputing "TYPES" so when I use if(DoesInherit(boulder, "boulder")){ Will that read my object boulder and the type being "boulder" or do I need "bouldertype"? Thanks again guys great stuff, also been learning more with scripting so this should start getting easier lol.

onimike
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! :lol:

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.


Yeah I was wondering about that so I will probably use GetDirectChildren script then if script to do all my functions from. Looks like it really saves time and massive scripts :)

Avantar
So in essence: You expand Advanced in the left column of Quest and click on 'Object types' Then you add a object type and call it boulder. You will do your scripts and attributes on that object.
In the room that you have the boulder, click on the bolder, click on the 'Attributes' tab and add the object type 'boulder' that you have created.
(This will add all the attributes and script to that object that was put on the object type)
Now use Jaynabonnes script(In essence it will just check if there is a boulder object in the room) :
foreach (obj, GetDirectChildren(game.pov.parent)()) {
if (DoesInherit(obj, "BoulderType") {
// Do whatever you wanted to do with obj.
}
}
You can add an else statement at the bottom saying perhaps that you cannot craft the stone since there is no boulder.
So that is what I was trying to say in my post and assumed that you have object types mastered and maybe you do - just in case - this is my 2 cents.

jaynabonne
Just be sure to call the boulder type "BoulderType" (or something unique). It must have a different name from your "boulder" object.

onimike
jaynabonne wrote:Just be sure to call the boulder type "BoulderType" (or something unique). It must have a different name from your "boulder" object.

Very awesome thats exactly what i was doing and wondered why i was having a hard time lol i thought i was crazy cause i knew i was calling it right just need to rename it. Thanks a million.

HegemonKhan
all 'NAME' String Attributes must be unique, be they Object 'names', Attribute 'names', Function 'names', Command 'names', Timer 'names', Turnscript 'names', Object Type 'names', Verb 'names', Exit 'names', and etc.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums