Using same objects in multiple rooms?

OurJud
14 Dec 2015, 10:54
Is there a shortcut or easy way to have 'x (object)' throw up the same response for multiple rooms, instead of having to add the same objects to each room they appear in?

For instance, I have two descriptions; one overlooking a field, and one as the player crosses the field. In the first I describe rocks, trees and shrubbery lining the field, and in the second I describe how the trees and shrubbery provide good cover.

If the player types 'x trees' / rocks / shrubbery at the first location, they'll get a description for each, but just supposing some smart arse types it again at the second location. Strictly speaking, and as anal as it might be, those same descriptions should come up again, as I've mentioned them in the location, but unless I laboriously add them again, they'll get "Can't see that."

HegemonKhan
14 Dec 2015, 20:53
I don't know if this is what you want, and it's a bit more advanced, but you might want to take a look at it:

viewtopic.php?f=18&t=5178#p35804

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

Objects and their Attributes (strings, booleans, integers, doubles, *AND SCRIPTS* ~ these are the GUI~EDitor's 'Verbs', and Lists, and Dictionaries, and etc) can be referenced (used) anywhere, as Attributes are GLOBAL VARIABLES (so long as the Object that holds~contains those Attributes, exists, of course).

So, you only need one Object, and it'll have, say various String Attributes or Script Attributes (such as 'look' or your own custom ones), for your various scenery descriptions for your rooms. Now, in your one Object's String or Script Attributes, you'll need some 'if' Scripts to check for what room you're in, and what 'indicator-flag' Attributes each of those rooms have, for what to do for them.

inside of the one~single 'whatever you want to call it' Object's (for example) 'look' Script Attribute (Verb):

checking what room you're in:

if (player.parent = roomX1) {
-> // blah
} else if (player.parent = roomX2) {
-> // blah
}
// etc etc etc

or, if you'd rather use the 'switch' Function~Script:

switch (player.parent) {
-> case (roomX1) {
->-> // blah
-> }
-> case (roomX2) {
->-> // blah
-> }
// etc etc etc

but now we've got to check for the various rooms' added~created 'indicator-flag' Attributes, too:

inside of the one~single 'whatever you want to call it' Object's (for example) 'look' Script Attribute (Verb):

if (GetString (player.parent, "room_type") = "fields") {
-> if (GetString (player.parent, "room_depth") = "entering_room") {
->-> if (player.parent = roomX1) {
->->-> msg ("You see rocks, trees and shrubbery lining the field.")
->-> } else if (player.parent = roomX55) {
->->-> // whatever message
->-> }
-> } else if (GetString (player.parent, "room_depth") = "inside_room") {
->-> if (player.parent = roomX2) {
->->-> msg ("You see trees and shrubbery, which provide good cover.")
->-> } else if (player.parent = roomX3) {
->->-> // whatever message
->-> }
-> }
}
if (GetString (player.parent, "room_type") = "swamp") {
-> // etc etc etc
}

does this code, and its concept design, make sense to you?

---------

And of course, you need to actually add those 'indicator~flag' Attributes to your rooms:

(showing it in code, but I know you can do the same through the GUI~Editor, if you don't understand doing this via code)

<object name="roomX1">
-> <attr name="room_type" type="string">fields</attr>
-> <attr name="room_depth" type="string">entering_room</attr>
</object>

<object name="roomX2">
-> <attr name="room_type" type="string">fields</attr>
-> <attr name="room_depth" type="string">inside_room</attr>
</object>

<object name="roomX3">
-> <attr name="room_type" type="string">swamp</attr>
-> <attr name="room_depth" type="string">entering_room</attr>
</object>

<object name="roomX4">
-> <attr name="room_type" type="string">swamp</attr>
-> <attr name="room_depth" type="string">inside_room</attr>
</object>

let me know if you don't understand any part of this, or if you don't understand the entire thing~Concept of it

(there's better designs for doing this stuff but they're much more fancy~complex~advanced ~ see Pixie's library~ies for example, but this is a design that I think, hope, you understand)

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

lastly you can use this anywhere you want, via this (in code), using the example of using 'look', of course:

do (whatever you named the Object goes here, "look")

but how~where you use~implement this is a bit more tricky...

XanMag
14 Dec 2015, 20:57
Can't you just copy-paste the trees, rocks, shrubbery into the second location? Toggle them as scenery. I'm missing something, aren't I? =)

OurJud
14 Dec 2015, 22:21
HK, I don't really understand any of that (surprise surprise) except possibly just enough to know we're talking about different things. I'm not talking about repeating room descriptions, but repeating the description for 'x (object)'.

Example, assuming the tree and rock objects aren't added to the second location:

You are on top of a hill overlooking a field. Trees and rocks line the edge of the field. You can go north.
>x rocks

More like boulders, really, some as high as ten feet.
>x trees

The trees are mainly pines.
>n

You are in the middle of a field. The rocks and trees provide good cover from the road. You can go north or south.
>x rocks

I can't see that (rocks).



Xan, probably not. How do you mean copy-paste? I didn't know you could copy whole objects and just paste them into another room??

PS Actually HK, I had a look at Pixie's code that you linked to, and we are talking about the same thing. Thanks.

XanMag
14 Dec 2015, 23:25
Click on the object you want copied in the tree. Click the copy button at the top of the tree and click the room you want to put the copied object in. Then click the paste button. =)

OurJud
15 Dec 2015, 09:56
XanMag wrote:Click on the object you want copied in the tree. Click the copy button at the top of the tree and click the room you want to put the copied object in. Then click the paste button. =)

And that will copy the whole shebang over... even the descriptions?

Cool.

Done! Never knew you could do that?

One thing that puzzles me, though. When you copy an object to another room, it gives it the suffix '1' to separate it from the other. So when you type 'x trees' for instance, without the '1', of course, how does the game recognise it if the actual object is called 'trees1' ?

Forgewright
15 Dec 2015, 10:33
I think you just add the alias "tree" to the first tree before copying and quest will use the alias in the command for each copied object in each room. :D

OurJud
15 Dec 2015, 11:12
Forgewright wrote:I think you just add the alias "tree" to the first tree before copying and quest will use the alias in the command for each copied object in each room. :D

Oh, righto.

Thing is, I wasn't saying it didn't recognise it, I was asking how it does. In the second location where I copied the trees, they're listed as 'trees1', but my point is, 'x trees' still throws up the description.

XanMag
15 Dec 2015, 12:08
Hm. Trees or trees1 is still recognized as trees as lamb would be recognized as Lamborghini or Lamborghini1. Does that answer it? Or do I not understand your question?

OurJud
16 Dec 2015, 00:18
XanMag wrote:Trees or trees1 is still recognized as trees as lamb would be recognized as Lamborghini or Lamborghini1.

Seriously? :shock:

So you can't have two objects with the same first four letters, throw out different descriptions??

So "x homestead" would return the same description as "x home', even if you had different descriptions for each?

jdpjdpjdp
16 Dec 2015, 00:47
I just ran "home" versus "homestead" and they worked just fine. ;)

OurJud wrote:Thing is, I wasn't saying it didn't recognise it, I was asking how it does. In the second location where I copied the trees, they're listed as 'trees1', but my point is, 'x trees' still throws up the description.


Because it's not just copying the name, it copies everything stored within the item. If you are in the GUI, click through the tabs and you'll see it's all filled out identically.

Marzipan
16 Dec 2015, 02:40
The player only has one tree object in the location they're standing in. That's the one it gives you the description of.

Now if you had a tree1 and tree2, both with an alias of tree in the same room, I'm not sure what would happen.

jdpjdpjdp
16 Dec 2015, 03:27
You'd get a disambiguation menu. "Which tree did you mean: tree or tree?" (Yes, I've played games where this has happened.)

OurJud
16 Dec 2015, 12:08
Marzipan wrote:The player only has one tree object in the location they're standing in. That's the one it gives you the description of.

jdpjdpjdp wrote:
Because it's not just copying the name, it copies everything stored within the item. If you are in the GUI, click through the tabs and you'll see it's all filled out identically.

Hold on, I'm still not clear on this (not that it really matters, but I'm anal like that).

I have two separate locations; one on the edge of the field where I point out the trees (and give a description on 'x') and the second in the field, where I also mention the same trees (and give a description on 'x').

Now, for the first location I add an object called 'trees' and give it a description - obviously this means that 'x trees' will result in that description.

For the second, separate, location, I copy the tree object over from the first location, but because you can't have two objects with the same name, it calls this object 'trees1'.

You would think, therefore, that while at the second location, 'x trees' would return "I can't see that (trees)" as the object for this location is actually 'trees1'.

So why does 'x trees' work at the second location?

My guess is that it ignores the number suffix, and throws out the description depending on which room you're in.

So...

Room: Side of the road overlooking a field.
Object name: Trees
Command: x trees
Description: The trees here are very tall

Room: Muddy field.
Object name: Trees1
Command: x trees
Description: The trees are short and bushy.

Second location simply ignore the '1' on the end of the object name.

jdpjdpjdp
16 Dec 2015, 21:40
The short explanation is that commands look for the object's alias first, not the object name. Object names all have to be unique, but you can have any number of objects with the same alias. In this example, the original object was called "trees" and likely also had the alias "trees". The copy had the name changed, because objects need unique names, but the alias, just "trees", is the same for both.

That's my understanding of it anyway. If it's wrong, someone with a more intimate knowledge of the program can correct me.

OurJud
16 Dec 2015, 22:24
jdpjdpjdp wrote:The short explanation is that commands look for the object's alias first, not the object name. Object names all have to be unique, but you can have any number of objects with the same alias. In this example, the original object was called "trees" and likely also had the alias "trees". The copy had the name changed, because objects need unique names, but the alias, just "trees", is the same for both.

That's my understanding of it anyway. If it's wrong, someone with a more intimate knowledge of the program can correct me.

This may be the answer, so long as alias are added automatically, as I never use them?

HegemonKhan
17 Dec 2015, 02:32
Since you're using Commands, you got to do the scripting to differentiate the Objects and their Attributes that the Command will use. Verbs on the other hand, do this for you, in that they're designed~programmed to only work upon the Object that you added them to.

Since your tree Objects are in different rooms, than you just need to have scripting that mimics a Verb's scripting: you need to have scripting that tells the Command to use the tree object that is in the same room as you are, for example:

<command name="tree_look_command">
<pattern>tree</patterm> // you just need to type in 'tree', the scripting handles the rest for you
<script>
foreach (object_x, GetDirectChildren (player.parent)) // searches through all the objects in the room that you are in
{
if (object_x.alias = "tree") // if any of the objects have the alias of 'tree', then...
{
do (object_x.look) // run that object's 'look' Verb (Script Attribute)
}
else
{
msg ("You don't see any trees within your level of eyesight.")
}
}
</script>
</command>

Forgewright
19 Dec 2015, 20:50
I also give different descriptions of areas from different view points. If you are using the actual "look" description of the object for both, add a script that checks the players parent to decide the description given. I tend to use commands to look in directions and then give a farther away look at an object or add a "Look description" to the exit itself. Either way works well.

From earlier posts, I see the GUI uses the first 4 letters of an object to determine if it is the referenced object by the player, but I found in some cases it will use the first letter if that is what the player input. X W command will trigger objects like wood, or William (if this is a player or character name, which is aggravating but is work aroundable. Although the player intended to look West, they get a list of all objects that start with W.

The Pixie
19 Dec 2015, 21:27
Forgewright wrote:From earlier posts, I see the GUI uses the first 4 letters of an object to determine if it is the referenced object by the player, but I found in some cases it will use the first letter if that is what the player input. X W command will trigger objects like wood, or William (if this is a player or character name, which is aggravating but is work aroundable. Although the player intended to look West, they get a list of all objects that start with W.

I think it grabs all the objects in scope (held or in the room), and tries to match each, keeping a list of full matches, where the whole word is a match, and a list of partial matches, matching part word. The partial matches are only used if there are no full matches. If you have a ball and a balloon, and the player types X BALL, it will match the ball rather than the balloon, because the latter is only a partial match.

OurJud
19 Dec 2015, 22:18
The Pixie wrote:

"Forgewright"

From earlier posts, I see the GUI uses the first 4 letters of an object to determine if it is the referenced object by the player, but I found in some cases it will use the first letter if that is what the player input. X W command will trigger objects like wood, or William (if this is a player or character name, which is aggravating but is work aroundable. Although the player intended to look West, they get a list of all objects that start with W.


I think it grabs all the objects in scope (held or in the room), and tries to match each, keeping a list of full matches, where the whole word is a match, and a list of partial matches, matching part word.


I wouldn't mind seeing this changed so that the player has to type the full name (or at least the first word if multiple) of the object. I know players like shortcuts, and n e s w are acceptable because of how many times they have to be typed, but is it really that difficult or time-consuming to type the full name of an object when you encounter one?