Displaying Attribute Integers :)

Anonynn
08 Dec 2015, 23:54
I just wanted to know if there is a way to display...

Player.object
Attributes
sarcasm - integer 0

for example:

In the player.tab of the player.object, in the "Look at" description ((run a script)) and have it keep a sort of "tally" for the player to look at and keep track of.

For example...

{player.sarcasm=}

or something like that.

I'd rather not do it in the "Status Attribute" since the color gets all wonky if the Status Attribute bar has to get extended past the normal boundary.

angklungmann
09 Dec 2015, 02:26
Hope this will help you.

My solutions for this situation is adding new command object with code:
<command name="stats">
<pattern>stats #object#; #object# stats;</pattern>
<script>
msg ("Status")
if (object=player) {
msg ("Your current stamina is " + object.stamina)
}
else {
msg ("Current " + object.alias + " stamina is " + object.stamina)
}
</script>
<unresolved>"ERROR"</unresolved>
</command>

Lets suppose my player object has stamina attribute with value 25 and another object named object1 with alias 'John' also have stamina with value 77, then if i type 'my stats' or 'stats my' the game will output:
Status
Your current stamina is 25

otherwise when i type 'john stats' or 'stats john', the output will be:
Status
Current John stamina is 77

and when i'm type wrong object name like 'jonh stats' or 'stats jnoh' the game will output
"ERROR"

The code will more complicated and long when object has more attributtes, maybe it will easy if adding specific function which handle multiple attributes input and return string values, but im not good add advanced coding (im newbie in Quest), so i'm letting anyone else to find it out..

Anonynn
09 Dec 2015, 02:35
That sounds like a good alternative and will be useful if what I'm looking for doesn't work, or can't be done in the Text Processor.

I'd rather use a more simple means though if it exists. I have the player.object, player.tab displaying several things about the character ((in the text processor language)), and really just want to see if there is a way to display attributes through that means. Thank you very much though for the sexay alternative!

angklungmann
09 Dec 2015, 02:40
Okay.
Lets wait another replies.

HegemonKhan
09 Dec 2015, 06:16
A warning:

there's two different 'look~lookat' textbox areas with Player Objects, one for when the Player Object is currently being controlled by you, and one for when the Player Object isn't being currently controlled by you. Many people go to the normal Tab, and start adding stuff to the 'look', but then they've no idea why it's not working, well that's because that area will only work when you're NOT in control of your Player Object (you switch to another Player Object, and then talk to your original Player Object, now as an uncontrolled npc in the game).

So, instead of the normal Tab, you go to the 'Player' Tab (I think) for finding the correct area-n-'look' that will work for when you're controlling your Player Object, which is the default for most people, unless they make a game where you switch between multiple Player Objects.

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

you can use the Command method as Angk already showed (I have a slightly different formatting for how I like to display it), or you can do the same but with a Verb (Script Attribute) of your Player Object, such as the built-in 'look~lookat' or a custom one you made.

(the problem with Verbs, while I believe you can type in an input to activate the Verb as if it were a Command, is if you want to have a button to click on... a way tha I like to do it, is to instead create~add an Object into the player's inventory, and then add the Verb to that Object, for example, I add an Object named 'character' to my player's inventory, and I make it so that it can't be dropped, I then add a Verb to the 'character' Object, named 'stats', which has the below scripts. I could then add another Verb, named "equipment", to handle equipment, and etc. See, how I'm using the Object as a broader button category, and the Verbs as the sub-categories of each of the Objects. I would add another Object, named 'action', which I would add Verbs to, named 'explore', 'travel', 'rest', 'sleep', 'buy', 'sell', etc etc. Is this making sense?)

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

this is how I like to format mine:

(you can use the text processor commands, if you like using them better)

ClearScreen
msg ("Character Information Screen")
msg ("")
msg ("Name: " + player.alias)
msg ("Age: " + player.age)
msg ("Sex: " + player.sex)
msg ("Life: + player.life)
msg ("Strength: + player.strength)
// etc etc etc stats
wait {
ClearScreen
}

Anonynn
09 Dec 2015, 22:23
Yeah, I just use the player.object, player.tab --- not the player.object, setup.tab. It would be too confusing for me to go back and forth between them!

Anyway. Well, that's kinda what I want....but here's a better explanation of what I would like to happen. Basically in the beginning the player can pick their starting dominant personality type. It's split between 5 choices. Which ever they pick they will receive a +5 toward. Here are the choices...

Sexy
Sympathy
Sarcasm
Snoopy
Serious

So once the game begins, certain items and clothing, or conversation replies will give a +1 toward whatever personality they want to reply with. For example, by the first conversation response they might have something like...

Sexy 5
Sympathy 3
Sarcasm 6
Snoopy 2
Serious 1

But unless I make ^---- those 'Status Attributes' (since they are integers in the player.attributes) the player would have to keep track of these numbers themselves, which will get really tedious and confusing as the game goes on. So what I wanted to do was take those integer values and update them via Text Processor in the Player.object, Player.tab, "Look at" object description where the rest of the character's description is. Like...

Current Personality Stats
Sexy
Sympathy
Sarcasm
Snoopy
Serious

I just don't know how that would be set up in the Text Processor. I know like {if player.height=5.4:Blahblah} but is there a way to like...

{display sarcasm.integer} or something like that?

HegemonKhan
09 Dec 2015, 23:04
do you mean having your stats displayed permanently~constantly in the big text area (left side of the screen during game play) ???

or is it okay to type in a command, such as 'stats', whenever the person playing the game needs to see them?

or is it okay to click on a verb button or hyperlink, named such as 'stats', whenever the person playing the game needs to see them?

--------

here's the syntax with using text processor commands:

ClearScreen
msg ("Character Information Screen")
msg ("")
msg ("Name: {player.alias}")
msg ("Age: {player.age}")
msg ("Sex: {player.sex}")
msg ("Life: {player.life}")
msg ("Strength: {player.strength}")
// etc etc etc stats
wait {
ClearScreen
}


Displayed:

Character Information Screen

Name: HK
Age: 18 // I wish
Sex: male
Life: 999/999
Strength: 100
etc etc etc stats

this has the exact same display too:

ClearScreen
msg ("Character Information Screen")
msg ("")
msg ("Name: " + player.alias)
msg ("Age: " + player.age)
msg ("Sex: " + player.sex)
msg ("Life: + player.life)
msg ("Strength: + player.strength)
// etc etc etc stats
wait {
ClearScreen
}

Anonynn
10 Dec 2015, 00:13

do you mean having your stats displayed permanently~constantly in the big text area (left side of the screen during game play) ???


Nope! I think you're talking about Status Attributes. The little box where the player status attributes are stored on the right side above the compass?

or is it okay to type in a command, such as 'stats', whenever the person playing the game needs to see them?


Eh, rather avoid an unnecessary step if I can :)


or is it okay to click on a verb button or hyperlink, named such as 'stats', whenever the person playing the game needs to see them?


Ditto!

You solved my question though! With this!

Strength: {player.strength}

All I had to do was type in the player description box...

Sympathy: {player.sympathy} and it shows the updated integer values! Thank you so much, HK! You are wonderful!

Sympathy: 0

Anonynn
10 Dec 2015, 04:09
I have another question regarding these personalities and integers. Is there a way to set up like ....the dominant integer winning?

For example...

Sexy 1
Sympathy 5
Sarcasm 7
Snoopy 6
Serious 4

{if player.sarcasm>=7:do this}
{if player.snoopy>=5:do this}

But let's say they are conflicting scenes. Is there a way for the game to recognize which personality has the highest integer and then run with that one?

HegemonKhan
10 Dec 2015, 05:59
wow... this is a fun challenge! (no sarcasm, I love these coding logic problems - well as long as they don't totally stump me and give me a headache, lol), as the problem is that they're Attributes...

the normal logic for this (finding~getting a max~largest or min~smallest value from a collection of values), is:

1. to first have those values in some collection that you can iterate (quest: foreach or for) through (in quest: List Attributes)

2. set the first value to a variable named such as: smallest or minimum, or largest or maximum

3. to iterate through them (quest: foreach) and compare (quest: if) each value to the variable, if the value is larger, or smaller, then that value becomes (is set or assigned: variable = new_value), and when you go through all of the values, you'll have the largest or smallest value stored in that variable for your desired use.

you can google this (programming finding largest/smallest value in a collection), as this is one of the basics of any programming language 101 class, finding~getting the largest or smallest value in a data collection, laughs.

so, in quest, here's an example, finding~getting the smallest value:

(actually, it's better to use 'for', so you can specify what items you iterate through, as you can skip the first value, as it's already assigned initially to the variable: code efficiency)

http://docs.textadventures.co.uk/quest/scripts/for.html

(laughs, I forgotten like every quest command, it's been so long, and my brain is C++, Python, and Java brainwashed, lol ... I had to look up like everything you see in this post)

// data_list = split ("10;9;8;7;6;5;4;3;2;1", ";")

// (I'm assuming Lists can be passed as Parameters)

game.smallest_value = get_smallest_function (data_list)

<function name="get_smallest_function" type="int" parameter="list_parameter">
smallest = ToInt (StringListItem (list_parameter, 0))
for (x, 1, ListCount (list_parameter) - 1) {
if (ToInt (StringListItem (list_parameter, x)) < smallest) {
smallest = ToInt (StringListItem (list_parameter, x))
}
}
return (smallest)
</function>


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

HOWEVER, since your values are Attributes... this doesn't work in quest (correct me if wrong):

(pseuocode)

// stat_list = split ("sexy; serious; etc", ";")
largest = player.sexy
for (x, 1, etc) {
-> if (player.x > largest) {
->-> largest = player.x
-> }
}
return (largest)

---

so, I think you're going to have to use a Script Dictionary in order to be able to get the Attribute... (this may not work either, but I think it would)

It'd take too long to do the code right now... it's late and I'm tired (and I'm lazy), lol.

if this is something you're interested in... I can get the code up tomarrow for you.

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

anyways, this is a bit challenging of a logic concept, but I'm curious if you get it or not, Neonayon?

here's a non-code example of the concept (as the code is more difficult to understand):

10,9,5,7,2,4,1,8,2

get the smallest number!

smallest = 10 // (if you only have a single number, it's the smallest! and if not, then we're using this as the initial comparison of our function)
is 9 < smallest ? -> yes -> smallest = 9
is 5 < smallest ? -> yes -> smallest = 5
is 7 < smallest ? -> no
is 2 < smallest ? -> yes -> smallest = 2
is 4 < smallest ? -> no
is 1 < smallest ? -> yes -> smallest = 1
is 8 < smallest ? -> no
is 2 < smallest ? -> no

smallest = 1

is 1 the smallest value in the collection ? -> yes -> the function works!

does this make sense to you, Neonayon ?

Anonynn
12 Dec 2015, 05:24
Sorry, it took so long getting back to you, I was knee deep in coding and making my game today. Literally ALL day adding in a second gender.

So yes! I get the concept. I actually use the "to and from" thing already.

Like I have a "height" object for example with a "string list" from 3.0 feet tall to 7.0 ((every 2 inches)). The player has the options to choose between 12 and 19, max and low for all the races, but some races have even more restrictions like 12 to 16, and so on.

So I definitely get that.

What I need though is just the "largest" integer of the 5 personalities taking over "descriptions" when it's relevent. And the largest could change from one personality to the other.

Like if...the personality.object, integers are...

Sexy: 5
Sympathy: 4
Sarcasm: 6
Snoopy: 2
Serious: 3

Sarcasm would take the description.

HegemonKhan
12 Dec 2015, 08:18
HK EDIT:

IGNORE THIS: Have you used Lists before and understand them? How about Dictionaries, have you tried using them, specifically the Script Dictionary?

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

HK EDIT:

haha... I was way over thinking this... we don't need a Scriptdictionary Attribute, all we need is a Stringlist Attribute and the 'GetInt' Function, laughs

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

for use in example below:

player.sexy = 6
player.sarcastic = 7
player.serious = 8
player.etc = 9

================================
// this let's use you them anywhere in your game, such as for your descriptions~msgs:

game.largest = -1 // or: game.largest = {whatever is the Value of the first item in your stringlist}

game.personality = null // or: game.personality = "" // or: game.personality = "{whatever is the first item (sexy,serious,sarcastic,etc) in your Stringlist Attribute}"

// the values of these Attributes above, will be replaced, they're just initial~placeholder values
===================================

game.personality_stringlist = split ("sexy; sarcastic; serious; etc", ";")

the general idea is to put your personalities (sexy, sarcastic, serious, etc) into a Stringlist Attribute (see directly above), as this allows you to 'for' through each of them:

sexy
sarcastic
serious
etc

with these strings, through the 'for' iteration's variable, we can use them in our 'GetInt()' Function:

game.largest = player.sexy // or whatever your first added (or left most) item in your list
game.personality = "sexy" // or whatever your first added (or left most) item in your list
// largest = 6
for (personality_x, 1, ListCount (personality_stringlist) - 1) {
-> value_x = GetInt (player, personality_x)
-> if (value_x > game.largest) {
->-> game.largest = value_x
->-> game.personality = personality_x
-> }
}

// you now got the highest personality stat value in 'game.largest' (ie: 9), for your use anywhere you want~need to use it

// you now got the name of the personality stat with the highest value in 'game.personality' (ie: etc), for you use anywhere you want~need to use it. You can use either: 'game.largest' or 'GetInt (game, game.personality)', to get the largest Value. And again, 'game.personality', gives you the name of this personality stat (that is currently having~storing the highest Value).

Anonynn
13 Dec 2015, 20:00
Okay! This is what I have so far...

Function: GetInt

Return Type: String List

Parameters:
sexy
sympathy
sarcasm
snoopy
serious


Script:
game.personality_stringlist = split ("sexy; sympathy; sarcasm; snoopy; serious", ";")

But I'm lost now!

HegemonKhan
13 Dec 2015, 22:26
<game name="xxx">
<attr name="largest_value" type="int">-1</attr>
<attr name="largest_name" type="string">unknown</attr>
<attr name="personality_list" type="simplestringlist">sexy;sympathy;sarcasm;snoopy;serious</attr>
<attr name="start" type="script">
character_creation_function
on ready {
largest_function
on ready {
response_function
}
}
</attr>
</game>

<object name="player">
// pretending that after your 'character creation', you start with these stats, for an example:
<attr name="sexy" type="int">5</attr>
<attr name="sympathy" type="int">6</attr>
<attr name="sarcasm" type="int">7</attr>
<attr name="snoopy" type="int">8</attr>
<attr name="serious" type="int">9</attr>
</object>

<function name="character_creation_function">
// blah scripts
</function>

<function name="largest_function">
game.largest_value = player.sexy
game.largest_name = "sexy"
for (personality_x, 1, ListCount(personality_list) - 1) {
value_x = GetInt (player, personality_x)
if (value_x > game.largest_value) {
game.largest_value = value_x
game.largest_name = personality_x
}
}
</function>

<function name="response_function">
switch (game.largest_name) {
case ("sexy") {
msg ("You're dominant personality is sexiness, at " + game.largest_value)
}
case ("sympathy") {
msg ("You're dominant personality is sympathetic, at " + game.largest_value)
}
case ("sarcasm") {
msg ("You're dominant personality is sarcastic, at " + game.largest_value)
}
case ("snoopy") {
msg ("You're dominant personality is snoopiness, at " + game.largest_value)
}
case ("serious") {
msg ("You're dominant personality is seriousness, at " + game.largest_value)
}
}
</function>