ADRIFT Forum


The place to discuss the ADRIFT Interactive Fiction toolkit

Setting a variable to an object, character, or room?

This forum is the place to learn about and discuss ADRIFT 5. Feel free to mention any bugs you find here, but please also add these to the Bugs & Enhancements list.

Please also refer to the ADRIFT 5 Wiki for more information.

Setting a variable to an object, character, or room?

Postby Kennedy » Sat Sep 17, 2016 2:44 am

Is it possible to set a variable to an object, character, or room, or they strictly limited to text and numbers? My idea is that I want to make it so whenever a player drops an object or gives it to a character a variable is set to that room or character.
Kennedy
 
Posts: 149
Joined: Tue Apr 29, 2003 7:12 pm
Location: Oregon
Points: 10

Re: Setting a variable to an object, character, or room?

Postby saabie » Sat Sep 17, 2016 5:27 am

You could create a new item property for characters and set that property of the player character to the last place that they left an object.
saabie
 
Posts: 901
Joined: Fri Aug 12, 2011 2:07 am
Location: Adelaide, South Australia
Points: 10

Re: Setting a variable to an object, character, or room?

Postby ElliotM » Sat Sep 17, 2016 6:32 am

Properties are more flexible than variables in what they can hold, so I would second Saabie's suggestion. Just to be clear though, it sounds like you want each object to remember where the player left it or to who it was last given? Or is that you want the player character to remember the location of just the last object they dropped or the last person to whom they last gave a object?
ElliotM
 
Posts: 1227
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA
Points: 13

Re: Setting a variable to an object, character, or room?

Postby Kennedy » Sat Sep 17, 2016 8:27 pm

Well my idea was to have a 'find' task that would tell the character where they last saw the object or person. Having a property sounds like the way to go, and I'd likely want it for all dynamic objects and characters. The tricky part though would be that I'd likely have to modify the general 'give' and 'drop' tasks to add a line to set the property.
Kennedy
 
Posts: 149
Joined: Tue Apr 29, 2003 7:12 pm
Location: Oregon
Points: 10

Re: Setting a variable to an object, character, or room?

Postby ElliotM » Sat Sep 17, 2016 9:23 pm

You could make a task using the input syntax of

adrift Code: Select all
find %object%


which prints the message:

adrift Code: Select all
You last saw the %object%.Name at %object%.Parent


though that will probably need some tweaking to produce grammatical output using Alternate Descriptions because Parent will return an object, character, or a location depending on where the object is located. As long as nothing but the player will move objects around, this should work. You'll also want to add restrictions that the player has seen the object, etc., and never move anything the player has seen into the hidden room.

%object%.Parent.Name might be what you need if the output of %object%.Parent isn't what you expected.
ElliotM
 
Posts: 1227
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA
Points: 13

Re: Setting a variable to an object, character, or room?

Postby ParadoxGames » Sun Sep 18, 2016 11:50 pm

I'll leave the technical advice to the other, more talented programmers, but I jsut wanted to say that "find" is an interesting device to add to a game.
ParadoxGames
 
Posts: 161
Joined: Sat Sep 05, 2015 2:33 am
Points: 10

Re: Setting a variable to an object, character, or room?

Postby Kennedy » Mon Sep 19, 2016 4:59 am

ElliotM wrote:You could make a task using the input syntax of

adrift Code: Select all
find %object%


which prints the message:

adrift Code: Select all
You last saw the %object%.Name at %object%.Parent


though that will probably need some tweaking to produce grammatical output using Alternate Descriptions because Parent will return an object, character, or a location depending on where the object is located. As long as nothing but the player will move objects around, this should work. You'll also want to add restrictions that the player has seen the object, etc., and never move anything the player has seen into the hidden room.

%object%.Parent.Name might be what you need if the output of %object%.Parent isn't what you expected.


That would likely be the simplest solution. If for some reason the object or character gets moved by something other than the player I could just create a specific task to find that particular object/character.
Kennedy
 
Posts: 149
Joined: Tue Apr 29, 2003 7:12 pm
Location: Oregon
Points: 10

Re: Setting a variable to an object, character, or room?

Postby ElliotM » Mon Sep 19, 2016 5:24 pm

Find or remember? Though I agree that this is probably the easiest, the task I described will always be able to display the parent of something as long as it exists, but it won't account for what the player should or should not know/remember if objects don't stay put where the player puts them or the npc's don't hang onto items given to them.
ElliotM
 
Posts: 1227
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA
Points: 13

Re: Setting a variable to an object, character, or room?

Postby Apocca » Thu Sep 22, 2016 10:25 pm

On the subject of object functions, why will %object%.Name not work for me at all? It always just straight up prints "%object%.Name" in the text no matter what i do. I have tried some demo files from the forum too, and even in those it never prints the actual object's name. I have other issues with references too, like my player's custom name always has quotation marks around it. These are such simple things and my newbie brain just cant understand what it's doing wrong.
Apocca
 
Posts: 4
Joined: Thu Sep 22, 2016 12:51 am

Re: Setting a variable to an object, character, or room?

Postby ElliotM » Fri Sep 23, 2016 7:33 pm

%object% is a reference that only has meaning in tasks where the input includes it, otherwise %object% is empty and doesn't point to anything. If you want to use an object function in a non-task or where %object% isn't going to be a part of the input, then you will need to use an object key instead so Adrift knows which object you are referring to. See link below.

http://wiki.adrift.co/Key

If the key of your character is character1, then to get his name you would try character1.Name instead of %object%.Name. Name is the key of a character property. If you made a custom name property, find out what its key is and you can use it in the same fashion. For example, if the key were CustomName, then you would be able to write character1.CustomName in that character's description.

If you are still stuck, then please upload a demo showing what you are trying to do.
ElliotM
 
Posts: 1227
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA
Points: 13

Re: Setting a variable to an object, character, or room?

Postby Apocca » Fri Sep 23, 2016 8:06 pm

By input i assume you mean the action field, like "search object" or "remove object"? Pretty sure i understand how it's supposed to work, but i must be missing something. As i understand it, if i use "remove object" and i in the completion message use the %object%.Name, it should write the referenced object, right? For some reason it won't. There was a demo of a clothing system that i looked at that used the tag in the same way and it had the same problem, oddly enough. It's the only tag i have used that just won't work at all for me.

Thanks for the help by the way!
Apocca
 
Posts: 4
Joined: Thu Sep 22, 2016 12:51 am

Re: Setting a variable to an object, character, or room?

Postby ElliotM » Fri Sep 23, 2016 8:19 pm

Take a look at the standard library tasks and it should be a bit clearer how to use it.

"search object" should be "search %object%" in the command syntax though, otherwise there is no object reference and it won't work.

http://wiki.adrift.co/General_tasks#References
ElliotM
 
Posts: 1227
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA
Points: 13

Re: Setting a variable to an object, character, or room?

Postby Apocca » Fri Sep 23, 2016 8:27 pm

ElliotM wrote:Take a look at the standard library tasks and it should be a bit clearer how to use it.

"search object" should be "search %object%" in the command syntax though, otherwise there is no object reference and it won't work.

http://wiki.adrift.co/General_tasks#References


Oh, i was using "specific" commands instead of "general". I figured it would work the same either way. It works now! Thanks <3
Apocca
 
Posts: 4
Joined: Thu Sep 22, 2016 12:51 am


Return to ADRIFT 5.0

Who is online

Users browsing this forum: No registered users and 6 guests