ADRIFT Forum


The place to discuss the ADRIFT Interactive Fiction toolkit

Referencing the value of a character user defined property

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.

Referencing the value of a character user defined property

Postby Matai » Thu Jul 20, 2017 6:05 am

I've been playing with the value of a user defined property today and have been struggling to see how I can then create a function to report back a text description when the value is between various ranges.

For example:

1-50 = happy
50-100 = ecstatic
etc

I can't seem to do nest if commands, and I'm not sure how to go about trying to create that sort of result? Any ideas?

I'm fairly acquainted with basic coding techniques, but I'm new to creating functions in Adrift.

Thanks in advance for any help.

Matai
Matai
 
Posts: 3
Joined: Thu Jul 20, 2017 5:58 am

Re: Referencing the value of a character user defined proper

Postby Denk » Thu Jul 20, 2017 3:51 pm

Hi Matai!

I am not entirely sure what you want to do, but in ADRIFT everything is done through tasks. The restrictions correspond to if-part in basic coding and the message/actions correspond to the then-part. To do nested if's you would have to call a new task if the restrictions are fullfilled.

If you want to check for something every turn, you could create an event, which runs immediately, runs for 1 turn and keeps repeating itself. This event should then run all tasks which need to run every turn.

Since you are using user defined properties, you could have restrictions like:
Property[happiness]for[player character][must be][>][50] AND
Property[happiness]for[player character][must be][<][101]

and the message could be:
You are ecstatic!

Utilizing alternative descriptions, you could handle several states (both happy, ecstatic etc) in the same task.

If this does not answer your question, perhaps you could explain in more detail what you are trying to do. Even better, also attach a small demo-file where you attempt to do it.
-----------------------------------------------------------------------------------------
Out now: The Royal Puzzle, The Way Home & The Dragon Diamond
-----------------------------------------------------------------------------------------
Denk
 
Posts: 73
Joined: Mon Feb 22, 2016 6:21 pm
Location: Hjørring, Denmark

Re: Referencing the value of a character user defined proper

Postby Matai » Thu Jul 20, 2017 7:10 pm

Thanks for the reply Denk. I'll try and explain a bit better. I was running out of time this morning before I headed out the door so didn't get the first message together as clearly as I ought to have done.

I'll do a take two on it... ! :D

First of all, I want this property to apply to both the player and to each character within the story. I intend to have several similar properties that work in the same way.

The idea is that I'll manipulate the value up and down either throw general game play (it progressively goes up or down slightly per turn) or by specific events (I increase significantly up or down).

Then when I 'examine' the character, I want to add the extra information. This is what I've got so far (I've no got any more than this in my game file so far, so it's hardly worth posting :D ):

Property:
Happiness
For characters and is a value. The value list contains six numeric states with a corresponding description:
0 = Blank
50 = Content
150 = Happy
500 = Joyful
750 = Very Joyful
950 = Almost Ecstatic
1000 = Ecstatic

Then in the User Functions I have HappinessState.

My intention (and this is the main issue I'm having and the reason for this post) is that this User Function is referenced when I run the Examine characters Task. I've already got it so it will append something (for now).

But HappinessState is where I'm having the issue. When referencing Happiness I only get the numeric value, not a text description. Plus, since I'm working on the premise that a range equates to a happiness level, then I need the UserFunction to correctly be able to convert the number value into the text description that goes with it.

This is why I was thinking of the nested IF commands, something I can't do.

From your reply are you suggesting creating separate UserFunctions that then reference each other? I'm still getting to grips with the differences in Adrift since I last had a play around with creating usable adventures with Adrift 4. :)

Thanks again for the input. I appreciate it and your time you've take to reply.

Matai :)
Matai
 
Posts: 3
Joined: Thu Jul 20, 2017 5:58 am

Re: Referencing the value of a character user defined proper

Postby Denk » Thu Jul 20, 2017 9:41 pm

I understand now what you are trying to do ( :D ), though I am not sure I 100% understand how you want to apply the user function HappinessState since I do not know how it is defined. As I see it, you do not need a user function.

I don't know if you are aware of this, but since you have made the property Happiness of type "value", the property cannot take on values in between the defined values, e.g. 100 is not a valid value. If you want to allow the property to allow for values in between, it should be of type "integer".

Secondly, to my knowledge, there is no way to refer to the text field of the table, since it is of type value. Thus %character%.happiness returns a number.

One way to convert the number into text I have shown in the attached file. I have made a task for the player (player mood) and a task covering all other NPC's (NPC mood). Since I in this example don't really need the user function (named hapfunc) I made the task "NPC mood" independent of the user function.

Now, if you run the file you get:
>x me
As good-looking as ever. You are content.

>x John
John is an old man. John is joyful.

Are we getting closer to what you are trying to do?
Attachments
mood.taf
(15.16 KiB) Downloaded 18 times
-----------------------------------------------------------------------------------------
Out now: The Royal Puzzle, The Way Home & The Dragon Diamond
-----------------------------------------------------------------------------------------
Denk
 
Posts: 73
Joined: Mon Feb 22, 2016 6:21 pm
Location: Hjørring, Denmark

Re: Referencing the value of a character user defined proper

Postby Matai » Fri Jul 21, 2017 5:45 am

Thanks Denk. :Thanks: That's working great now. :)

Now to figure out how to make a repeating task to change all the characters Happiness level up or down... :|
Matai
 
Posts: 3
Joined: Thu Jul 20, 2017 5:58 am


Return to ADRIFT 5.0

Who is online

Users browsing this forum: Google [Bot] and 4 guests