Integers with Text Value

Anonynn
Okay, so now that other stuff is taken care of. I was wondering if it was possible for an Integer value to display text...or have a text disguise.

For example, I currently have height as a stringlist with the values: 5'8, 5'9, 5'10 and so on. So I was wondering if it's possible to (easily) transfer those values into numerical integer values.

My idea is...

People can choose their own heights and whatnot in the character creation. But later on in the game they can shrink and grow in height, for example, growing one inch or shrinking one inch. Well, as a stringlist if the player is 6'0 feet tall, and they hit one of those instances it'll be a mess of code to try and get the game to understand a universal shrink one inch no matter what height the character is, but as an integer or numerical value, the game would just subtract one inch from the current value....right?

Sounds way easier to me.

Can this be done?

XanMag
Not sure, but it'd probably me easier if you used metric. =)

Changing 1.8m meters to 1.7m is probably a lot easier to write code for than 5'9" to 5'8". Just a thought...

Anonynn

Not sure, but it'd probably me easier if you used metric. =)

Changing 1.8m meters to 1.7m is probably a lot easier to write code for than 5'9" to 5'8". Just a thought...



I would actually love to have both metric and imperial. :D

HegemonKhan
yes (but not via transfering~converting your strings, example 6'9'', into integers), instead you use Integer Attributes, which can then be used to format into the desired strings (String Attributes) that you want, and the simpliest way is to do this, is actually to decide upon a single base unit to use, for example with using height and Norse~American (base 12):

feet or inches

let's say we choose 'inches' as our single base unit:

Reference:

0 inches = 0 feet
12 inches = 1 foot
24 inches = 2 feet
36 inches = 3 feet
48 inches = 4 feet
60 inches = 5 feet
72 inches = 6 feet
84 inches = 7 feet
96 inches = 8 feet
108 inches = 9 feet
120 inches = 10 feet


example1: if you're 5 feet, then you'll input '60' for your height in inches in the code below
example2: if you're 6 feet and a half (6 inches), then you'll input '78' for your height in inches in the code below

<function name="height_function"><![CDATA[
msg ("What is your height (in inches)?")
get input {
if (IsInt (result) and result >= 0 and result <= 120) {
player.inch_height_integer_attribute = result
player.feet_height_integer_attribute = player.inch_height_integer_attribute / 12
player.remaining_inches_integer_attribute = player.inch_height_attribute % 12
player.height_string_attribute = "Height: You are " + player.feet_height_integer_attribute + " feet and " + (player.remaining_inches_integer_attribute + " inches tall"
} else {
msg ("Wrong input, try again")
height_function
}
}
]]></function>


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

we could choose 'feet' as our base unit instead, and do the reverse (feet * 12 = inches, etc etc etc)

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

we could also get two inputs instead (directly getting our 'inch' and 'feet' Integer Attribute VARIABLES):

<function name="height_function"><![CDATA[
msg ("What is your height?")
msg ("(Type in your feet first, then you'll be asked again, for your inches)")
msg ("")
msg ("Feet?")
get input {
if (IsInt (result) and result >= 0 and result < 10) {
player.feet_height_integer_attribute = result
msg ("Inches?")
get input {
if (IsInt (result) and result >= 0 and result < 12) {
player.inches_height_integer_attribute = result
player.height_string_attribute = "Height: You are " + player.feet_height_integer_attribute + " feet and " + player.inches_integer_attribute + " inches tall"
} else {
msg ("Wrong input, try again")
height_function
}
} else {
msg ("Wrong input, try again")
height_function
}
}
]]></function>

HegemonKhan
as for Metric (base 10) vs Norse~American (base 12), see if you can figure out how to do it... there's a few designs, depending on what you want for your game (for example, do you want: at beginning of the game, the person chooses metric or norse~american and that is all that gets displayed to the person throughout the game, or do you want metric and norse~american to both be displayed throughout the game, or do you want to be able to toggle~switch between metric and norse~american throughout the game? Each of these designs determine what and how much coding you need to do for the rest of your entire game code, as well, as the code for just the beginning part of your game)

if not, ask, and we can help.

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

P.S.

this code of mine covers a lot of character creation stuff that you may be interested in for your own game:

viewtopic.php?f=18&t=4988

ask, if you need help with any of it, or need anything explained.

Anonynn
Well, the the height thing was just an example. I can always set up a metric stringlist corresponding to the height to display {if player.height=5'5: 1.6 meters} or {if player.height=5'5: 65 inches} or something like that. That isn't that big of an issue.

I don't think I'd have to change the stringlists of the character creation itself, but I was wondering if I could change the extended stringlists (the ones to be used in the game and not the character creation) into integers, or if that would make it easier to leave it as it is. I suppose I need to explain it a little better...

With using height as an example.

I am 5'6 ....I drink a height potion that will make me 1 inch taller. Well, the problem is, since the player can be anywhere between 5'0 and 6'5 having a potion that makes the player 1 inch taller would confuse the engine, I think. But if I had an integer disguised in there like... and integer of 2 represents a 5'6 person, and an integer of 3 represents a 5'7 person, then all I would have to do is make the potion to +1 height, and the player would see 5'7 instead. Right?

HegemonKhan
yes, for that design, the String List Attribute that you already got, actually does this very thing for you (you just got to learn how to work with 'StringListItem'~Index numbering~positioning of Lists, which I try to guide+explain for you below), for example:

--------

as scripting:

game.height_stringlist_attribute = split ("1.0; 2.0; 3.0; 4.0; 5.0", ";")


as creation tag:

<game name="xxx">
<attr name="height_stringlist_attribute" type="simplestringlist">1.0; 2.0; 3.0; 4.0; 5.0</attr>
</game>


---------

the items~Values (for this example: 1.0, 2.0, 3.0, 4.0, 5.0) of the 'game.height_stringlist_attribute' Stringlist Attribute of the 'game' Game Object, are of 'type:string'

-------

conceptually about String List Attributes:

game.height_stringlist_attribute = split ("index number 0 position; index number 1 position; index number 2 position; index number position 3; index number 4 position", ";")


<game name="xxx">
<attr name="height_stringlist_attribute" type="simplestringlist">index number 0 position; index number 1 position; index number 2 position; index number 3 position; index number 4 position</attr>
</game>


"1.0" <----> index number 0 position
"2.0" <----> index number 1 position
"3.0" <----> index number 2 position
"4.0" <----> index number 3 position
"5.0" <----> index number 4 position

------

http://docs.textadventures.co.uk/quest/ ... lists.html
http://docs.textadventures.co.uk/quest/ ... titem.html

StringListItem (Object_name.Stringlist_Attribute_name, index_number_position)

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 0)
// player.height_string_attribute = "1.0"

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 1)
// player.height_string_attribute = "2.0"

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 2)
// player.height_string_attribute = "3.0"

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 3)
// player.height_string_attribute = "4.0"

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 4)
// player.height_string_attribute = "5.0"

z = 3
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, z)
// player.height_string_attribute = "4.0"

show menu ("Number?", split ("0; 1; 2; 3; 4", ";"), false) {
// for example, you choose 1
// result = 1
}
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, result)
// player.height_string_attribute = "2.0"

msg ("Type in a number from 0 to 4")
get input {
// for example, you type: 2
// result = 2
}
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, result)
// player.height_string_attribute = "3.0"

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, GetRandomInt (0, 4) )
// player.height_string_attribute = StringListItem (game.height_stringlist_attribute, randomly it will select: 0 or 1 or 2 or 3 or 4 )
// player.height_string_attribute = (based on whatever the random choosen index number is, it will be the matching~corresponding: "1.0" or "2.0" or "3.0" or "4.0" or "5.0")

x = GetRandomInt (0, 4)
// for example, let's say it randonly chooses: 4
// x = 4
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, x )
// player.height_string_attribute = "5.0"

player.feet_integer_attribute = 3
// you drink a weak height potion (+1 feet): player.feet_integer_attribute = player.feet_integer_attribute + 1
// player.feet_integer_attribute = 4
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, player.feet_integer_attribute)
// before you drank the weak height potion: player.height_string_attribute = "4.0"
// after you drank the weak height potion: player.height_string_attribute = "5.0"

The Pixie
Why not have the integer as the height in inches?

I would use the integer as the primary attribute, and set a string attribute based on that. If you want to be fancy, set up a change script on the integer to automatically update the string.
viewtopic.php?f=18&t=5307&p=36709#p36709

Script to convert the integer to a string:
player.heightasstring = "" + player.height / 12 + "'" + player.height % 12

Anonynn

"1.0" <----> index number 0 position
"2.0" <----> index number 1 position
"3.0" <----> index number 2 position
"4.0" <----> index number 3 position
"5.0" <----> index number 4 position

------

http://docs.textadventures.co.uk/quest/ ... lists.html
http://docs.textadventures.co.uk/quest/ ... titem.html

StringListItem (Object_name.Stringlist_Attribute_name, index_number_position)

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 0)
// player.height_string_attribute = "1.0"

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 1)
// player.height_string_attribute = "2.0"

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 2)
// player.height_string_attribute = "3.0"

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 3)
// player.height_string_attribute = "4.0"

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, 4)
// player.height_string_attribute = "5.0"

z = 3
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, z)
// player.height_string_attribute = "4.0"

show menu ("Number?", split ("0; 1; 2; 3; 4", ";"), false) {
// for example, you choose 1
// result = 1
}
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, result)
// player.height_string_attribute = "2.0"

msg ("Type in a number from 0 to 4")
get input {
// for example, you type: 2
// result = 2
}
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, result)
// player.height_string_attribute = "3.0"

player.height_string_attribute = StringListItem (game.height_stringlist_attribute, GetRandomInt (0, 4) )
// player.height_string_attribute = StringListItem (game.height_stringlist_attribute, randomly it will select: 0 or 1 or 2 or 3 or 4 )
// player.height_string_attribute = (based on whatever the random choosen index number is, it will be the matching~corresponding: "1.0" or "2.0" or "3.0" or "4.0" or "5.0")

x = GetRandomInt (0, 4)
// for example, let's say it randonly chooses: 4
// x = 4
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, x )
// player.height_string_attribute = "5.0"

player.feet_integer_attribute = 3
// you drink a weak height potion (+1 feet): player.feet_integer_attribute = player.feet_integer_attribute + 1
// player.feet_integer_attribute = 4
player.height_string_attribute = StringListItem (game.height_stringlist_attribute, player.feet_integer_attribute)
// before you drank the weak height potion: player.height_string_attribute = "4.0"
// after you drank the weak height potion: player.height_string_attribute = "5.0"



Okay, so this is completely beyond my understanding lol. Maybe if we can break it up into pieces and do little bits at a time, I might be able to get it. You are saying I can use the extended library we made to work like an integer value?

Why not have the integer as the height in inches?

I would use the integer as the primary attribute, and set a string attribute based on that. If you want to be fancy, set up a change script on the integer to automatically update the string.
viewtopic.php?f=18&t=5307&p=36709#p36709

Script to convert the integer to a string:
player.heightasstring = "" + player.height / 12 + "'" + player.height % 12



Where would I put that? I'm not sure I follow clearly.

HegemonKhan
let's try this analogy:

you're familiar with real-life grociery shopping lists (though excluding the quantity of each item), I presume:

vertically:

1. eggs
2. milk
3. bread
4. meat

or horizontally:

(1) eggs, (2) milk, (3) bread, (4) meat

--------

except, instead of starting with (1), we start with (0):

vertically:

0. eggs
1. milk
2. bread
3. meat

or horizontally:

(0) eggs, (1) milk, (2) bread, (3) meat

------

now, that you know your shopping list's index ordering, let's remove the index ordering, as it's understood (by quest already and hopefully you too now):

vertically:

eggs
milk
bread
meat

or horizontally:

eggs, milk, bread, meat

-------

if I asked you to just~only get the index '0' item on~in the shopping list, what item are you to get?

Answer: eggs

if I asked you to just~only get the index '1' item on~in the shopping list, what item are you to get?

Answer: milk

if I asked you to just~only get the index '2' item on~in the shopping list, what item are you to get?

Answer: bread

if I asked you to just~only get the index '3' item on~in the shopping list, what item are you to get?

Answer: meat

if I asked you to just~only get the index '4' item on~in the shopping list, what item are you to get?

Answer: ERROR, there is no 4th index item (there are 4 items, but they're indexed from starting at 0, not 1, so the 4th item is the '3' index position in the shopping list. Thus the 4th index item would be the 5th item, but there is no 5th item in this shopping list, there's only 4 items)

----------

now, let's write the shopping list as code:

(I'm using the 'game' Game Object, as the Object that has~added the 'shopping_list' Stringlist Attribute for this example post of mine, but you can have~use any Object instead having~added your various Stringlist Attributes)

in scripting:

game.shopping_list = split ("eggs;milk;bread;meat", ";")

------------ and~or --------------------------

as 'creation' tag block:

horizontal, type="simplestringlist", is better for only single word items, such as our shopping list:

<game name="xxx">
<attr name="shopping_list" type="simplestringlist">eggs;milk;bread;meat</attr>
</game>

or

vertical, type="stringlist", is better when you got long sentences for your items, for an example:

<game name="xxx">
<attr name="race_description_list" type="stringlist">
<value>Human Race Description: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah</value>
<value>Dwarf Race Description: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah</value>
<value>Elf Race Description: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah</value>
</attr>
</game>

though you can certainly use vertical for single word items too if you like

here is our shopping list vertically:

<game name="xxx">
<attr name="shopping_list" type="stringlist">
<value>eggs</value>
<value>milk</value>
<value>bread</value>
<value>meat</value>
</attr>
</game>


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

this code line below, gets the (string) item in your String List, based on the index number you provide it:

(caps matter for this, it must be: S-tring L-ist I-tem, see below)

VARIABLE = StringListItem (List_name, index number)

so, for our example:

player.grociery_bag = StringListItem (game.shopping_list, 0)
// Question: what (string) item is in the player's grociery bag ???
// Answer: "eggs"

player.grociery_bag = StringListItem (game.shopping_list, 3)
// Question: what (string) item is in the player's grociery bag ???
// Answer: "meat"

player.grociery_bag = StringListItem (game.shopping_list, 1)
// Question: what (string) item is in the player's grociery bag ???
// Answer: "milk"

player.grociery_bag = StringListItem (game.shopping_list, 2)
// Question: what (string) item is in the player's grociery bag ???
// Answer: "bread"

---------

does this makes sense now?

-----------

the hidden-understood index ordering is always LEFT-TO-RIGHT (or: UP-TO-DOWN) and it starts with ZERO

---------

challenge~tests~practice for you:

(notice that I changed the index number placement of the items from my example above, for this test~challenge~practice for you below)

game.shopping_list = split ("bread;meat;milk;eggs", ";")

------- and~or -------------------------------

<game name="xxx">
<attr name="shopping_list" type="simplestringlist">bread;meat;milk;eggs</attr>
</game>

or

<game name="xxx">
<attr name="shopping_list" type="stringlist">
<value>bread</value>
<value>meat</value>
<value>milk</value>
<value>eggs</value>
</attr>
</game>


Question: the 'eggs' item's index number is? Answer: 3
Question: the 'meat' index number is? Answer: 1
Question: the 'milk' index number is? Answer: 2
Question: the 'bread' index number is? Answer: 0

player.grociery_bag = StringListItem (game.shopping_list, 2)
// Question: what (string) item is in the player's grociery bag?
// Answer: "milk"

player.grociery_bag = StringListItem (game.shopping_list, 0)
// Question: what (string) item is in the player's grociery bag?
// Answer: "bread"

player.grociery_bag = StringListItem (game.shopping_list, 3)
// Question: what (string) item is in the player's grociery bag?
// Answer: "eggs"

player.grociery_bag = StringListItem (game.shopping_list, 1)
// Question: what (string) item is in the player's grociery bag?
// Answer: "meat"

player.grociery_bag = StringListItem (game.shopping_list, 4)
// Question: what (string) item is in the player's grociery bag?
// Answer: ERROR, there is no 4th index item, as your list only contains 4 items, the 4th item is 3rd index

player.grociery_bag = StringListItem (game.shopping_list, GetRandomInt (0,3))
// Question: what (string) item is in the player's grociery bag?
// Answer: (randomly: "eggs" or "milk" or "bread" or "meat")

x = 2
player.grociery_bag = StringListItem (game.shopping_list, x)
// Question: what (string) item is in the player's grociery bag?
// Answer: "milk"

show menu ("Number?", split ("0;1;2;3", ";"), false) {
// let's say you selected: 1
// result = 1
player.grociery_bag = StringListItem (game.shopping_list, result)
}

Question: what (string) item is in the player's grociery bag?
Answer: "meat"

msg ("Type in the number of the item you want")
DisplayList (game.shopping_list, true)
get input {
// let's say you typed in: 4
// result = 4
if (IsInt (result) and result >= 1 and result <= ListCount (game.shopping_list) ) {
player.grociery_bag = StringListItem (game.shopping_list, ToInt (result) - 1)
// this will work, due to the 'ToInt (result) - 1', this code is a bit more advanced, so study it, or ask for help
// hint1: ListCount (List_name) ~~ gets~returns the total number of items in your list, ie: 4 (remember: that this 4th~last item's index number is: 3)
// hint2: ListCount (List_name) - 1 ~~ total number of items in your list - 1 = a correct index number of an item in your list
}
}

Question: what (string) item is in the player's grociery bag?
Answer: "eggs"
Answer Explanation: 4 - 1 = 3 index number = "eggs" ----> "eggs"

if I typed in '3', instead of 4:
Answer: "milk"
Answer Explanation: 3 - 1 = 2 index number = "milk" ----> "milk"

if I typed in '2', instead of 4:
Answer: "meat"
Answer Explanation: 2 - 1 = 1 index number = "meat" ----> "meat"

if I typed in '1', instead of 4:
Answer: "bread"
Answer Explanation: 1 - 1 = 0 index number = "bread" ----> "bread"

Anonynn
Okay! Going to attempt to see if I understood all that.

When making a "Integer List" that refers to a "String List" the items in that String List will always start at the number "0" and move upward from there. If the number referred to doesn't exist, it becomes an ERROR.

You go into the "Game Object" and "Attributes" ((In my case, I'd go to "Object Group, Data Group, fulldata"))

and find the rest of the "Extended String List" items that I already have. Vertical list for short-worded lists, Horizontal lists for long-worded lists.

I think the only thing I don't get is how to make the individual Stringlists into Integer Lists.

From what you said...

Do you...

Click "Attributes", Select the "StringList" I want to start with like..."height", for example, and...?


VARIABLE = StringListItem (List_name, index number)



Add a change-script or something?

I'm lost, lol.

I appreciate the detailed explanation so far though, but you have to remember I'm an idiot.

HegemonKhan
you just create~add a Stringlist Attribute, there is no "integer list" (sorry for the confusion!), but I'll try to explain (hopefully better than last post) below:

we need to first get you familiar with using~working with Lists... then, we'll tackle specifically for what you want to do in your game, with your game's Attributes, Objects, and etc.

let's do this in the GUI~Editor, to make it easier for you.

for example:

create a new game, for using this guide

'game' Game Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)

// you can use any Object, it doesn't have to be the 'game' Game Object, but then everywhere in my code below, you'll have to put in the name of your choosen object, in-place of where you see 'game' in my 'buy' Verb code block below for using this example.

(Object Name: game)
Attribute Name: shopping_list
Attribute Type: stringlist
Attribute Value (Add): (see below)

the first (string) item (let's add: eggs) you add is internally (you never get to see this) stored as index number: 0

the second (string) item (let's add: milk) you add is internally stored as index number: 1

and so forth....

the 'StringListItem' uses the index number (that you specify in its code line) to return the (string) item's name from your String List

first added item to your String List: eggs ~~~~~ 'eggs' is internally matched to index number: 0
second added item to your String List: milk ~~~~~ 'milk' is internally matched to index number: 1
third added item to your String List: bread ~~~~~ 'bread' is internally matched to index number: 2
fourth (and last) added item to your String List: meat ~~~~ 'meat' is internally matched to index number: 3

player.grociery_bag = StringListItem (game.shopping_list, 0)
// we specified the '0' index number as seen above, and thus it returns: "eggs"
// player.grociery_bag = "eggs"

player.grociery_bag = StringListItem (game.shopping_list, 1)
// we specified the '1' index number as seen above, and thus it returns: "milk"
// player.grociery_bag = "milk"

player.grociery_bag = StringListItem (game.shopping_list, 3)
// we specified the '3' index number as seen above, and thus it returns: "meat"
// player.grociery_bag = "meat"

player.grociery_bag = StringListItem (game.shopping_list, 2)
// we specified the '2' index number as seen above, and thus it returns: "bread"
// player.grociery_bag = "bread"

now, there's many ways of specifying what number for the index number in the 'StringListItem', such as using: 'GetRandomInt', or a number input (using 'get input' ---> result), or using a menu selection (using 'show menu' ---> result), and etc...

---------

and real quick, let's create~add the String Attribute to your 'player' Player Object:

'player' Player Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)

(Object Name: player)
Attribute Name: grociery_bag
Attribute Type: string
Attribute Value: empty

---------

now, let's create an Object named 'market' in your 'room' Room Object:

'room' Room Object -> 'Objects' Tab -> Add -> Name: market

'market' Object -> 'Verbs' Tab -> Add -> Name: buy

for your 'buy' Verb (lazy, showing in code):

(this code below is advanced for you right now, so just use it, don't try to understand it yet, we'll get to explaining it, much later on)

(I just want you to create this sample game yourself and see the use of a list in action, to help-start familiarizing you to lists and using lists)

msg ("Type in the number of the item that you want to buy")
DisplayList (game.shopping_list, true)
get input {
if (IsInt (result) and result >= 0 and result <= ListCount (game.shopping_list) - 1) {
player.grociery_bag = StringListItem (game.shopping_list, result)
msg ("You bought: " + player.grociery_bag)
} else {
msg ("Wrong input, try again")
}
}


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

// maybe this will help:
//
// pretend that you have your 4 students get in a line
//
// the first student (Mike) you tell him to remember his number: 0 (because the 1st student in the line is ALWAYS told to remember the number: 0)
// the second student (John) you tell him to remember his number: 1 (because the 2nd student in the line is ALWAYS told to remember the number: 1)
// the third student (Chris) you tell him to remember his number: 2 (because the 3rd student in the line is ALWAYS told to remember the number: 2)
// the fourth (and last) student (Bill) you tell him to remember his number: 3 (because the 4th student in the line is ALWAYS told to remember the number: 3)
//
// when~if using the GUI~Editor, when~by adding items~values to a Stringlist Attribute, the first added item is automatically matched up to index: 0, the second added item is automatically matched up with index: 1, and so forth...
//
// when~if using code, using the horizontal code form (using either: 'split' scripting or the 'creation' tag line), the leftmost item~value is your first item (automatically matched up to index: 0), the second leftmost item~value is your second item (automatically matched up to index: 1), and so forth
//
// when~if using code, using the vertical code form (the 'creation' tag block), the uppermost item~value is your first item (automatically matched up to index: 0), the second uppermost item is your second item (automatically matched up to index: 1), and so forth.
//
// the below is conceptually what 'StringListItem' command~function, as shown in its full usage example of 'player.grociery_bag = StringListItem (game.shopping_list, 0_or_1_or_2_or_3)', is doing:
//
// you speak: "if your number is 0, say your name", and the first student answers: "Mike"
// you speak again: "if your number is 3, say your name", and the fourth (last) student answers: "Bill"
// you speak again: "if your number is 2, say your name", and the third student answers: "Chris"
// you speak again: "if your number is 1, say your name", and the second student answers: "John"
//
// you speak again: "if your number is 4, say your name", and the 4 students all look at each other, as none were told to remember the number 4 by you... after a minute... You realize you made an error!

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

P.S.

you are *NOT* an idiot !!!!

Lists (and even worse: Dictionaries) are a huge huge huge step up in both: comprehension (and comprehension of all of Lists~Dictionaries uses~applications) and coding.

Also, I'm a pathetic guide~explainer (I fail majorly as a teacher), sighs. Pixie or Jay or TM123 could probably have you understanding and using Lists and Dictionaries in like a minute, laughs.

Anonynn
So basically...

What you're saying is when I created the Extended "StringLists" they already had integer values assigned to them (invisible to me but not invisible to the Quest Engine).

The first thing in the StringList is "0"

For example, races.

Race Attribute, StringList, Add...

human (0)
elven (1)
dwarven (2)

and so on?

So if I want the game to refer to one of those Extended StringLists I need to go, for example,

player.race = StringListItem (game.fulldata, 2) ?

((fulldata is where all the Extended Libraries are stored. It is under Objects, Data Group, then fulldata))

HegemonKhan
yea, that's pretty much it... but I believe you want this, approximitely:

player.height = StringListItem (fulldata.height_list, whatever_index_number)

psuedocode (NOT proper syntax):

player.height = 0.0 <--- output <--- StringListItem (fulldata.height_list, input:0)
player.height = 5.0 <--- output <--- StringListItem (fulldata.height_list, input:10)
player.height = 2.5 <--- output <--- StringListItem (fulldata.height_list, input:5)

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

conceptually, with lists, it's this that we're doing with the 'StringListItem' :

input (index number) ---> outputs~returns (item's value~name)

stick -> input (index number) -> into -> StringListItem () Function -> spits out -> output (item's value~name) -> gets assigned to a VARIABLE -> player.height

just like in algebra:

f(x) = y = x + 4
f(8) = y = 8 + 4 = 12
f(8) = y = 12

the 'index number' is 'x', the 'player.height' is 'f(x)'~'y', and the value 'items value~name' is the value '12'

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

now, back to what you originally wanted~asked for ... laughs:

your height list, is something like this (showing it using the horizontal code form, aka: type="simplestringlist" ):

<object name="fulldata">
<attr name="height_list" type="simplestringlist">0.0; 0.5; 1.0; 1.5; 2.0; 2.5; 3.0; etc</attr>
</attr>


let's say you drink your heght potion,
in your 'height potion' Object's 'drink' Verb,
you want approximitely:

old_height = argh
player.height = StringListItem (fulldata.height_list, old_height + argh)

..... great, just great......

now that we took all that time to understand lists and indexes... it looks like we got to use a dictionary instead... HK hits his head on the desk... (well, at least hopefully you might understand using lists better, maybe using 'StringListItem' for something else...)

let me know if~when you're ready to move to learning dictionaries... laughs....

maybe you should just use Pixie's method, and re-design the rest of your game for it (it'll probably be better than trying to keep going with this route)

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

unless...

@PIXIE~JAY~PERTEX~ETC:

can we get (return) the index number from an item in a list (the reverse process of the 'StringListItem' command~function) ???

Anonynn
Sorry it took so long for me to get back to you and thank you! I just want to make sure I understand how to do this. It's been a long week in class. Ugh.

Alrighty so...

In my fulldata extended lists, I would put....

player.height = StringListItem (fulldata.height_list + 2) for example, if I wanted a player to move up plus two steps.....like saying if they had a height of 5.2 feet...and I used + 2 right there, it would move them up to 5.4 feet?

Also, I was curious to know about "height_list" ...do I put "height_list" or do I match it to player.height? Or does "height_list" help the Quest Stringlists to identify that it's pulling from a list?

Thanks again for all the help, hope classes are going well so far!

HegemonKhan
neonayon wrote:player.height = StringListItem (fulldata.height_list + 2) for example, if I wanted a player to move up plus two steps.....like saying if they had a height of 5.2 feet...and I used + 2 right there, it would move them up to 5.4 feet?


no it would not, as this isn't quite how lists work... you can't do the '+2', at least not like that, you can't. It's too difficult and long for me to try to explain how it could be done... too complex to explain...

I really think you should just use Pixie's method (and adjust ~ re-designing parts of your game), and not work with Lists~Dictionaries, as it's unneccessarily a ton of extra work (far beyond adjusting ~ re-designing parts of your game), compared to just using an 'int' or a 'double' for your height. (You can keep the list you got for your character creation, but also have an 'int' or 'double' Attribute on your 'player' for working with your height, it's much easier than trying to use Lists~Dictionary Attributes).

---------

neonayon wrote:Also, I was curious to know about "height_list" ...do I put "height_list" or do I match it to player.height? Or does "height_list" help the Quest Stringlists to identify that it's pulling from a list?


that's just my own labeling~naming, for me to distinguish to you: your 'fulldata' Object's List Attribute (I don't know what you named~labeled it as) from your 'player' Player Object's 'height' Attribute.

-------

neonayon wrote:It's been a long week in class. Ugh.


tell me about it... I'm doing school work 24/7... my "weekend" (thurs to sun) is literally spent doing all of my homework... sighs... and mon to thurs, I'm in class doing school work and also at home... doing homework... fun life I got right now... I love when people ask me how my "weekend" was... as I can answer: "What weekend? I've been doing homework non-stop over all of my weekends. Oh ya, here and there I get to watch tv or play games or eat for like 30 minutes, during my breaks, in-between doing my homework assignments or reading textbooks."

Anonynn
Hmm....well, I definitely need to do something.

I just need a list that I can draw from during the game, and would like those something's to be represented with a number. So that if the player falls into a trap or something I can just do a quick line of code or GUI to increase or decrease whatever attribute was changed like, height, weight, etc.

I'm sure the initial character creation process can remain as it is since I use the exact same values (only extended) in the fulldata object of the game. I'd be fine with List-Dictionaries if I could get them to work like that, but if not then I definitely need to change the lists from string-lists to integers. I'm just at a loss of how.


I went ahead and made my "Race Stringlist" yesterday (for all of the different components of the extended data actually (which took forever)), here are the races, for example...

player.race: human 0, elven 1, dwarven 2, dragon-descented 3, halfling 4, orc-descented 5, gnome 6, dark elf 7, goblin 8, centauress 9, succubus 10, alarune 11, demon 12, cow-girl 13, dryad 14, slime 15, goo-girl 16, incubus 17, minotaur 18, naga 19, centaur 20, neko 21, random 22.

I did this so it would be easier to refer to the Stringlists from what you were talking about before but if it's a ton of work and using integers values is better than I'd rather do less work for more gain! lol




~~~~~~~

As for the school thing, yeah....I know. It's exhausting right now. But keep at it HK! You can do it!

TinFoilMkIV
basically there are two parts to the solution that fits your problem.

#1: the height index value, the integer that refers to the current height

#2: the actual height value to be displayed such as 5'6"

value #1 makes the most sense to save as a player attribute as this tells the game the value to look at whenever you want the players current height. Value #2 is what you pull from the master list of heights when you want to actually display it. You can either save this to another player attribute or just reference it directly whenever you want it displayed, that's up to you.

so for your example above of moving the player's height rating up 2 steps will look more like this


//this is the players height rating
player.height_rating = 4

//this will set the displayed height value to the equivalent from your master list
player.height = ListItem(fulldata.height_list, player.height_rating)

//to modify this alter the players built in height rating then resync with the master list value
player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating)


player.height = StringListItem (fulldata.height_list + 2) for example, if I wanted a player to move up plus two steps.....like saying if they had a height of 5.2 feet...and I used + 2 right there, it would move them up to 5.4 feet?


The first problem here is that you didn't input a value to add the +2 to, also it wasn't separated from the list name, so that would throw an error, but syntax aside you need to grab the "rating" value from the player before you can pick something out of your list. Secondly if you calculated with a +2 you don't change the players actual height rating, you will set the displayed height correctly but as soon as you reference the rating value again it is still unchanged and will reset your height. So you need to put the +2 calculation into changing the player rating as I did in my example and then just run a normal check for the displayed value.

EDIT: as for the racial thing, honestly I might just keep that as a string value attribute on the player, though it certainly wouldn't hurt to have a list value as the master list of official races so you can check for consistency to keep in mind what specific name you're using in the code so you don't start getting errors when the game looks for racial identifier names that don't quite match up. Another alternative would be to use a StringDictionary, as they work somewhat similar to lists, except instead of an integer value for the index it uses a string, so you can basically have a system name for your races and when you look them up they display as the string listed under that name.

ie: for whatever reason I want to insist on referring to the naga race in my code as 'snake_person' but obviously I don't want that as the official display in the game, it would look something like this.
//racial list dictionary attribute is fulldata.racial_list

dictionary add (fulldata.racial_list, snake_person, Naga)
//repeat with other races to build the list if not inputting directly into the actual attribute


then whenever I reference the DictionaryItem(fulldata.racial_list, snake_person) the game displays the result as "Naga" so I can reference it in whatever way I prefer in the code in actual text without affecting the displayed value and not having to remember the index it ended up under. a bit more complicated this way but tends to be easier to decipher and locate the correct info when a lot of variables get involved.

an example of how this would look when you do something with the actual value in code
//something happens to change player race
player.race = "snake_person"

//set the display name from the master list
display.player_race = DictionaryItem (fulldata.racial_list, player.race)
//your display value for player_race is now whatever you want the actual players to see

*note display isn't an actual built in thing, it's just an extra object I would personally use for organizational purposes with this sort of thing

The Pixie
TinFoilMkIV wrote:basically there are two parts to the solution that fits your problem.

#1: the height index value, the integer that refers to the current height

#2: the actual height value to be displayed such as 5'6"

value #1 makes the most sense to save as a player attribute as this tells the game the value to look at whenever you want the players current height. Value #2 is what you pull from the master list of heights when you want to actually display it. You can either save this to another player attribute or just reference it directly whenever you want it displayed, that's up to you.

Definitely do it that way. It is much easier.


For the races, consider using objects. Have a room called "races", and in it object called "dwarf", "elf", etc. Then you can add attributes to those objects such as name (Dwarf), average height (50 inches), plural (Dwarves), adjective (Dwarven) and so on. When the player picks a race, you go:
player.race = dwarf

Then in descriptions, you can do:
msg("Like all " + player.race.plural + " you have blue hair.")

Unfortunately, the text processor cannot cope with player.race.plural. If you want to use the text processor, you could copy the chosen races attributes into a new object called player_race
player_race = player.race.name
player_race = player.race.plural
//etc

Then:
Like all {player_race.plural} you have blue hair.

Anonynn

//this is the players height rating
player.height_rating = 4

//this will set the displayed height value to the equivalent from your master list
player.height = ListItem(fulldata.height_list, player.height_rating)

//to modify this alter the players built in height rating then resync with the master list value
player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating)



Okay. So just to be clear (I'm a beginner still so bare with me)...

So on the player.object, I go to Attributes and add height_rating for example, as an integer value. Now the problem is, the player gets to choose their height in the beginning of the game (separate object called creation.object, which doesn't have to be messed with), among other traits. What number would I put for.... player.height_rating = # in that case?

player.height = ListItem(fulldata.height_list, player.height_rating)



I think I understand this aspect --- and


player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating)



But just to be clear...I put this in the game itself let's say I have

Tallroom

player enters it. In the scripting I do ... player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating) ----- which is "Add Variable" etc?

The Pixie
Looks like the creation bit gets you a string called result with the number of feet, a dot and then the inches (eg "5.6"). To convert that to an integer, (after handling random) do this:
height_as_array = Split(result, ".")
player.height_rating = ToInt(StringListItem(height_as_array, 0)) * 12 + ToInt(StringListItem(height_as_array, 1))

Consider player.height_rating to be the primary attribute, everything else is derived from that. If the player grows two inches, change that attribute like this.
player.height_rating = player.height_rating + 2

Then create a function call GetHeight. Set its return type to be a string, and paste in this code:
return ("" + player.height_rating / 12 + "'" + player.height_rating % 12)

Do you use the text processor to display the height?

If you do you do use the text processor:

Set up a secondary attribute, player.height, and a change script on player.height_rating to keep them in step. To do that, add a new attribute to the player called changedheight_rating, set it to be a script, and paste in this code:
player.height = GetHeight()


If you do you do NOT use the text processor:

You do not need another attribute, just use the function when you want to display the height.
msg("You are now " + GetHeight() + " tall!")


By the way, I have put all this code in a test game and checked it all works.

TinFoilMkIV
Neonayon wrote:

//this is the players height rating
player.height_rating = 4

//this will set the displayed height value to the equivalent from your master list
player.height = ListItem(fulldata.height_list, player.height_rating)

//to modify this alter the players built in height rating then resync with the master list value
player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating)



Okay. So just to be clear (I'm a beginner still so bare with me)...

So on the player.object, I go to Attributes and add height_rating for example, as an integer value. Now the problem is, the player gets to choose their height in the beginning of the game (separate object called creation.object, which doesn't have to be messed with), among other traits. What number would I put for.... player.height_rating = # in that case?


Well as far as when you first create the attribute in the editor I'd just leave it at 0 or whatever you want the default value to be. As far as changing it in the character creator, the easiest method would be to just give the player some preset options. So you would list some choices and when the player selects a starting height from those choices you would code it to just set player.height_rating to the integer value of that height in the master list.

There are ways to convert a player entered measurement but those can get pretty tricky. If you really want to pursue that route I would stick with only allowing the entered measurement to be entirely in inches or cm or whatever your preferred measurement unit is. It's a lot easier to handle a single number than a height listed in multiple parts.


[quote]player.height = ListItem(fulldata.height_list, player.height_rating)



I think I understand this aspect --- and


player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating)



But just to be clear...I put this in the game itself let's say I have

Tallroom

player enters it. In the scripting I do ... player.height_rating = player.height_rating + 2
player.height = ListItem(fulldata.height_list, player.height_rating) ----- which is "Add Variable" etc?[/quote]
basically whenever you change the player.height_rating you then have to recalculate the player.height, otherwise the game wont actually show the height change since the player.height is what the player will see. And at the same time you should only ever need to calculate the player.height when you change the player.height_rating, as it should be correct as long as the rating wasn't changed.

Since they will almost always be altered and recalculated together it wouldn't be a bad idea to create a custom function, something like

//function name : Change_Height
//parameters: change

// to call this function in code will look like this
//Change_Height(#)

player.height_rating = player.height_rating + [u]change[/u]
player.height = ListItem(fulldata.height_list, player.height_rating)

This way when you want to do something like say add 2 to your height rating, you can just call Change_Height (2), and for a height decrease you simply use a negative number.

Anonynn

Well, as far as when you first create the attribute in the editor I'd just leave it at 0 or whatever you want the default value to be. As far as changing it in the character creator, the easiest method would be to just give the player some preset options.



Yes, the player in the "creator" have choices ranging from 5.0 - 6.0 ...every two inches. For example, 5.2, 5.4, 5.6 etc (if that's what you meant). The fulldata.object (containing the extended lists) goes beyond that. For example, 3.0 to 7.0, every two inches.

So you would list some choices and when the player selects a starting height from those choices you would code it to just set player.height_rating to the integer value of that height in the master list.



Not sure what you mean. Kind of have to dumb it down for me, cause I'm really slow apparently lol.

So first, I go to the player.object where the height attribute is (which is currently a stringlist), then I create an integer attribute called height_rating and set it to 0?

basically whenever you change the player.height_rating you then have to recalculate the player.height, otherwise the game wont actually show the height change since the player.height is what the player will see.



So in the game I will be changing the "height_rating" instead of the height directly (which is what the player sees). Got that.

And at the same time you should only ever need to calculate the player.height when you change the player.height_rating, as it should be correct as long as the rating wasn't changed.



How would I go about doing that? Calculating the player.height when I change the rating.

This way when you want to do something like say add 2 to your height rating, you can just call Change_Height (2), and for a height decrease you simply use a negative number.



I understand this part. I'm just confused about how I should go about setting up all these things. I don't know where to start.

Currently, I have stringlists....I know for each of them, I need to create integer-based attribute ratings for each of the current attributes on the player, for example...

player.race
player.race_rating
player.height
player.height_rating
player.eyecolor
player.eyecolor_rating

etc

Once I have those ratings and they are set to "0" what do I do from there?

((Also, thank you Pixie and Tin so far on helping me, I really appreciate your patience))

HegemonKhan
you roughly (or should) have something like this:

<object name="creator">
<attr name="creation_height_list" type="simplestringlist">5.0; 5.2; ... ; 5.10; 6.0</attr>
</object>

<object name="fulldata">
<attr name="full_height_list" type="simplestringlist">3.0; 3.2; ... ; 6.10; 7.0</attr>
</object>

<object name="player">
<attr name="alias" type="string">unknown</attr>
<attr name="sex" type="string">unknown</attr>
// etc Attributes

<attr name="height" type="string">unknown</attr>
<attr name="height_rating" type="int">0</attr>

<attr name="statusattributes" type="simplestringdictionary">height = Height: !; alias = Name: !; sex = Sex: !; etc_etc_etc</attr>
</object>


for your character creation, you use:

<object name="creator">
<attr name="creation_height_list" type="simplestringlist">5.0; 5.2; ... ; 5.10; 6.0</attr>
</object>


letting them select a height (via 'showmenu()' for the in-line if I remember right), let's say they select '5.6' :

player.height = "5.6"

but during the game, their height can change, which, using Pixie's~Tin's method of the 'player.height_rating' Integer Attribute, is what we alter, which in-turn will determine what the 'player.height' String Attribute's height value is:

conceptually about your 'fulldata.full_height_list', this is what it is~(will be) doing:

(we change the 'player.height_rating' in a script during game play, which will determine~adjust your 'player.height' as seen below)

player.height_rating...|...player.height.....
..............0.................|.........3.0...........
..............1.................|.........3.2...........
..............2.................|.........3.4...........
..............3.................|.........3.6...........
..............4.................|.........3.8...........
etc etc etc
..............?.................|.........7.0...........

this happens when we do this:

player.height = StringListItem (fulldata.full_height_list, player.height_rating)

using it in either:

the special 'changed' Script:

object name="player">
<changedheight_rating type="script">
player.height = StringListItem (fulldata.full_height_list, player.height_rating)
</changedheight_rating>
</object>


or, a (global) Turnscript:

<turnscript name="xxx">
<enabled>
<script>
player.height = StringListItem (fulldata.full_height_list, player.height_rating)
</script>
</turnscript>


-----

so, let's say we start out as:

player.height = "5.6"

player.height_rating = 0 // (actually we got a problem with this Attribute... we need to set it to it's proper value for '5.6', whatever the index value is for the '5.6' using your 'fulldata.full_height_list', for this example, as the 'changed' Script or Turnscript, will immediately change your, player.height="5.6", to, player.height="3.0"... you can ask Pixie and~or Tin, as they'll understand this issue, and can help you with it step by step if you need help with it. Ask them to read over this post of mine (if they haven't), and they'll understand this issue and be able to help you with it.

then during the game, we drink a height (+2) potion:

player.height_rating = player.height_rating + 2
// player.height_rating = 0 + 2 = 2
// player.height_rating = 2

now our 'player' Object's special 'changed' Script or our (global) Turnscript, kicks in, giving us our new height:

player.height = StringListItem (fulldata.full_height_list, player.height_rating)
// player.height = "3.4"

let's say we drank the height (+2) potion again, resulting in:

// player.height_rating = 2 + 2 = 4

and again, now our 'player' Object's special 'changed' Script or our (global) Turnscript, kicks in, giving us our new height:

// player.height = "3.8"

and let's say we drink a different height (-1) potion:

// player.height_rating = 4 - 1 = 3

and again, now our 'player' Object's special 'changed' Script or our (global) Turnscript, kicks in, giving us our new height:

// player.height = "3.6"

and let's say we drink a different height (-3) potion:

// player.height_rating = 3 - 3 = 0

and again, now our 'player' Object's special 'changed' Script or our (global) Turnscript, kicks in, giving us our new height:

// player.height = "3.0"

TinFoilMkIV
Neonayon wrote:

So you would list some choices and when the player selects a starting height from those choices you would code it to just set player.height_rating to the integer value of that height in the master list.



Not sure what you mean. Kind of have to dumb it down for me, cause I'm really slow apparently lol.

So first, I go to the player.object where the height attribute is (which is currently a stringlist), then I create an integer attribute called height_rating and set it to 0?


What I was trying to say, is when you give the player a list of choices say 5'2", 5'6", 5'10" for example, when the player selects one the script will first set their height_rating to the master list integer that matches with those values. so something like this
//display options for player to choose

//player chose 5'6"

player.height = 5'6"
player.height_rating = 7

or if you want to be extra careful and possibly plan to alter your full_data values, you can just set the height_rating, and then run the script that sets the player.height based on it

[quote]And at the same time you should only ever need to calculate the player.height when you change the player.height_rating, as it should be correct as long as the rating wasn't changed.



How would I go about doing that? Calculating the player.height when I change the rating. [/quote]
That is basically what I was describing with the Change_Height(#) function, where it includes the player.height = (....) line which calculates the display height after you change the rating. That's all I really meant by that, is just including the script to get your displayed height off the master list whenever you change the rating, so including them together as one function is probably a good solution.

[quote]This way when you want to do something like say add 2 to your height rating, you can just call Change_Height (2), and for a height decrease you simply use a negative number.



I understand this part. I'm just confused about how I should go about setting up all these things. I don't know where to start.

Currently, I have stringlists....I know for each of them, I need to create integer-based attribute ratings for each of the current attributes on the player, for example...

player.race
player.race_rating
player.height
player.height_rating
player.eyecolor
player.eyecolor_rating

etc

Once I have those ratings and they are set to "0" what do I do from there? [/quote]
Well you really don't need the ratings for every attribute, the string attribute should do everything you need. The advantage of using the ratings is most obvious for things like height, where the attribute has some type of numerical value that may increase/decrease throughout the game. The non-numerical strings are less necessary, as you're not likely to be in a situation where player.race_rating + 2 wont end up with some weird results. The part where those ratings do benefit you is that you have a master list in one location where you can change the race names and such without breaking all existing code that references that race, as well as less opportunities for errors related to spelling. The downside is that of course down the line when you look at a code that checks for "player.race_rating = 5" it's a lot more likely you won't actually remember what race that is immediately and may have to go back and check the master list.

As for your question of where to go from there, well, you build your master lists if you haven't already, and then you decide which values the player will be allowed to start as and make those options in the character creation. From that point really you just use the display attributes for anything when the player actually sees the attribute and you use the rating when you want to change one of the attributes.

((Also, thank you Pixie and Tin so far on helping me, I really appreciate your patience))

No problem, I like looking at this kind of stuff. Considerably less convoluted then half the code I end up putting myself through, heh. Helps me to step back and make sure I'm not building one giant mess with my own code.

Anonynn
Okay...I'm not sure why, but neither of you are putting this in simple terms for me. I need it completely broken down! I must be really awful at this.

Why do I need a second list that displays the same exact information? I have...for example...

Creation
player.height: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0

Full Data
player.height: "string list": 3.0 --- 7.0


Now from what I understand you guys want me to create a second list for these...for example
player.height: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0
player.height_list: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0

and

player.height: "string list": 3.0 --- 7.0
player.height_list: "string list": 3.0 --- 7.0

So why am I making that a new (second) list, which is exactly the same? Why can't I use the first lists? Keep in mind I have no idea where to place the "code" for these either...so it'll have to be done in the GUI, I guess.

From what I've gathered...

I need these lists...

Creation
player.height: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0

Full Data
player.height: "string list": 3.0 --- 7.0

...to correspond with one another (match up).

I have already written out both lists and made sure the numbers match for them. Now I just need to put this into action.

From what I gathered here, HK said....

<attr name="height" type="string">unknown</attr>
<attr name="height_rating" type="int">0</attr>



^--- is this why I need the secondary lists (player.height_list)? Why can't I just use the lists. If not, then I'll have to have secondary lists for just about everything, which display the same lists...

I know the "unknown" needs to be unknown because it's filled in by the player.

player.height = StringListItem (fulldata.full_height_list, player.height_rating)

^--- I know this is the end result. But why can't it be ....

player.height = StringListItem (fulldata.height, player.height) ?





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


Essentially all I want to do.....is after the player creates their character, manipulate that selection from the fulldata list. I have a creation list....and a fulldata list. The fulldata list is an expansion directly from the creation list.

I just want to be able to make a player (no matter what they chose) to become taller or shorter, tanner or paler, skinnier and more fat, etc

I don't want/need it to be anymore complicated than it needs to be. Ugh. Sorry I'm just incredibly frustrated. Not with you guys.

I still have to do a damn Combat System and a Transformation System too, and this stuff is the first steps.

HegemonKhan
my apologies, for confusing you neonayon!

my wrong usage of 'creation.height_list' and my 'fulldata.full_height_list', is just your 'creation.height' and 'fulldata.height', as I couldn't remember what~how you named them. Don't make any duplicates of them, lol. Again, my bad!

Anonynn
You didn't confuse me. It's perfectly okay!

I tend to get really confused about all this because I'm new at it, and dealing with a lot of these complicated features. Once I have all this out of the way, I hopefully won't have to deal with it again.

I know you guys are doing your best to help, and I really, really appreciate it. I really do. So even if you have to explain it a hundred ways, I still won't ever be mad at you guys for taking time out of your day to deal with all this mundane stuff you've already mastered and having the patience to explain it to a newbie.

Would you mind reexplaining all of that?

HegemonKhan
just one little correction (and explanation as I've confused you about it) on when you're writing this stuff:

neonayon wrote:Creation
player.height: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0

Full Data
player.height: "string list": 3.0 --- 7.0


You should be saying it like this (aka: understanding it as):

Object (Name):

Creation

a Stringlist Attribute added to the 'Creation' Object:

Creation.height: 5.0, 5.2, 5.4, 5.6, --- 6.0

as seen by doing it through the GUI~Editor:

'Creation' Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)

(Object Name: Creation)
Attribute Name: height
Attribute Type: stringlist
Attribute Value (add): 5.0, 5.2, ... , 6.0

'Full Data' Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)

(Object Name: Creation)
Attribute Name: height
Attribute Type: stringlist
Attribute Value (add): 3.0, 3.2, ... , 7.0

see how the word~text on the left side of the dot has to be the Object that you added the Attribute to~into, and the word~text on the right side of the dot is the name of the Attribute that you added to~into the specific Object.

just wanted to correct your usage of 'player.height', as this isn't correct in understanding quest and its coding structure.

HegemonKhan
these of mine:

<attr name="height" type="string">unknown</attr>
<attr name="height_rating" type="int">0</attr>

(again, you do NOT need any secondary~duplicate height lists, so these Attributes above have nothing to do with my confusion about secondary~duplicate height lists)

are the Attributes added to~into~for your 'player' Object

here's how to do it via the GUI~Editor (as the above, 'creation' tag code, is confusing you, as you've not learned~understand it yet):

'player' Object -> 'Attributes' Tab -> Attributes -> add -> (see below, repeat as needed)

(Object Name: player)
Attribute Name: height
Attribute Type: string
Attribute Value: unknown // (or whatever you want for the initial display, such as '0.0' or whatever, before it is set~selected by your character creation section at the start of the game play)

(Object Name: player)
Attribute Name: height_rating
Attribute Type: int (integer)
Attribute Value: (this is an issue... Stringdictionary usage would fix it... but I doubt you want to get into learning dictionaries when you're still learning lists)

-------

then, when your game begins, I believe you already got the character creation setup working right?, so it takes care of setting your 'player.height' already. But, we've got the issue with your 'player.height_rating', as this needs to be matching-corresponding to your character creation selected~set 'player.height'..., sighs... I'm not sure if there's a simple way to deal with this issue for you... sighs.

HegemonKhan
actually... when I get the time (hopefully sometime in the next week or two ... well if I don't have tests to study for...hmm), I'll guide you step by step through a new slightly different setup that'll work and you'll be able to (hopefully) understand very easily too.

As what you got right now... has a few issues with it, to get it working... so, it'll be better to create a slightly change in setup, than trying to correct your current setup to work fully.

Anonynn

Object Name: player)
Attribute Name: height
Attribute Type: string
Attribute Value: unknown // (or whatever you want for the initial display, such as '0.0' or whatever, before it is set~selected by your character creation section at the start of the game play)



^--- I actually already have this set up on the player.object as well, you did it for me a while ago when you reorganized my game. Remember?

(Object Name: player)
Attribute Name: height_rating
Attribute Type: int (integer)
Attribute Value: (this is an issue... Stringdictionary usage would fix it... but I doubt you want to get into learning dictionaries when you're still learning lists)



^--- so I still need to make this one, then. Okay!

Also, I don't mind using String Dictionaries if you have the patience to teach it lol. So far, so good though with this explanation (I already had all of that up to the height_rating thing right there.


actually... when I get the time (hopefully sometime in the next week or two ... well if I don't have tests to study for...hmm), I'll guide you step by step through a design that'll work and you'll be able to (hopefully) understand easily.

As what you got right now... has a few issues with it to get it working... so, it'll be better to create a slightly change in setup, than trying to correct your current setup to work fully.



Oh, hm. well, I suppose! Good luck on your tests and whatnot, just don't forget about this! I have a couple of tests as well. Maybe someone can move me along until you can explain your new idea! Or I have a million other things on the game to work on too.

HegemonKhan
if you want to learn Dictionaries, that would make all of this much easier!, though we'd have to re-create a new setup, but it shouldn't be too bad to do.

Dictionaries actually aren't too much different from Lists, but they can be a bit harder to grasp~understand, especially if Lists are still confusing to you.

Anonynn

if you want to learn Dictionaries, that would make all of this much easier!, though we'd have to re-create a new setup, but it shouldn't be too bad to do.

Dictionaries actually aren't too much different from Lists, but they can be a bit harder to grasp~understand, especially if Lists are still confusing to you.



As long as you have the patience of walking me through it, I can recreate things.

TinFoilMkIV
Neonayon wrote:Okay...I'm not sure why, but neither of you are putting this in simple terms for me. I need it completely broken down! I must be really awful at this.

Why do I need a second list that displays the same exact information? I have...for example...

Creation
player.height: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0

Full Data
player.height: "string list": 3.0 --- 7.0


Now from what I understand you guys want me to create a second list for these...for example
player.height: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0
player.height_list: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0

and

player.height: "string list": 3.0 --- 7.0
player.height_list: "string list": 3.0 --- 7.0

So why am I making that a new (second) list, which is exactly the same? Why can't I use the first lists? Keep in mind I have no idea where to place the "code" for these either...so it'll have to be done in the GUI, I guess.

Ah I think I see the problem, bit of miscommunication on both sides.

The player.height is not supposed to be a string list, just a regular string, since 5'6" has to be stored as a string due to non numerical characters. The player.height only needs to hold the current value of the players height, not the full list.

player.height = ListItem(fulldata.height_list, player.height_rating)

I think this is the part that was confusing you? Sorry if I sometimes put to much together at once when I'm writing out equations.

first we have [player.height =] this is setting the value of the player.height string, which is just a single string attribute

the [ListItem()] will pull a single value from a list, in this case the master list
*see ListItem*

[fulldata.height_list] is the first parameter of the ListItem function, which is the ID of the list being looked at

[player.height_rating] is being used as the second parameter for ListItem, which is used as the index of the list

so all together this line of code will use the player.height_rating as an index to find string from the fulldata.height_list then set player.height equal to the string value on that list. So it will use the current height_rating to setup the players height string correctly

Ultimately you do not strictly need a player.height attribute, you can just use ListItem() to pull the value directly from your master list whenever you need it, it depends on how you plan to use it or whatever is easier to keep track of.


From what I've gathered...

I need these lists...

Creation
player.height: "string list": 5.0, 5.2, 5.4, 5.6, --- 6.0

Full Data
player.height: "string list": 3.0 --- 7.0


You shouldn't need the player.height to be a string list, just an individual string, as I hopefully explained adequately above.


player.height = StringListItem (fulldata.full_height_list, player.height_rating)

^--- I know this is the end result. But why can't it be ....

player.height = StringListItem (fulldata.height, player.height) ?


well for one that method could only be used once since you're setting player.height to a different value based on itself, so that script won't be useable more than once without getting odd results.

player.height = StringListItem (fulldata.height, player.height)
^the problem is the underlined section, since you're using the current value as a list index, the only time this works cleanly is if the list index is the same as the list item, in which case the list itself is completely redundant


Essentially all I want to do.....is after the player creates their character, manipulate that selection from the fulldata list. I have a creation list....and a fulldata list. The fulldata list is an expansion directly from the creation list.

I just want to be able to make a player (no matter what they chose) to become taller or shorter, tanner or paler, skinnier and more fat, etc



You're actually very close to getting this down, and string lists are really the way to go to have a +/- to a stat type that isn't a strict integer. There's just a bit of confusion over the equation to pull the info from your master list it seems.


EDIT: As for dictionaries they really are similar to lists, except the indexes used don't need to be numbers and they don't have to be in order. If you want to do things like +1 height, or +1 lightness, and that sort of thing, then a list is probably easier to use, as they are always based on numbers and ordered. They're both made up of indexes and a corresponding item, it's more how they're organized and accessed.

A dictionary works more like the index in a text book, where you can look up an idea or specific item by name and then it will direct you to the relevant information. The indexes used in a dictionary can be any type of string, and they don't need an order, unlike lists which will always be ordered from 0 to however many items you have.

I can go into more detail on how it would work when I have a clearer idea what its going to be used for, hopefully this will at least give you an idea of how they're different from lists.

HegemonKhan
@Neonayon (and Tin possibly too):

the reason a Dictionary works great is that it deals with your 'player.height_rating' issue not being set to match up with with your selection of your initial 'player.height' from the character creation at the start of the game (as the global Turnscript will immediately change your 'player.height' to correspondingly what you put for your 'player.height' via in your code for its initial value), as the Dictionary allows you to switch back and forth between your (now as this is a Dictionary) 'string_index_key1' and your 'key1s_value'.

---------

@Neonayon *and Tin* (this will get everything working for neonayon, if you can help her with the below, I'd be immesnely appreciative, as I may be too busy with school to help her immeidately with this):

I also, overnight (while I slept, lol), I thought of an easy way to deal with this issue, without changing over to using Dictionaries:

it's a bit bad~messy~ugly coding design, but who cares, it's a simple quick fix (a band-aid isn't that bad~ugly, wink), hehe :D

we'll just need to help you to add some scripts at the end of your character creation, which will set your 'player.height_rating' to the correct value, based upon what your selected 'player.height' is from the character creation menu-list scripts in it, for quick simple example:

// neonayon's initial limited height selection list *only* for the start of the game (character creation):
// Creation.height = split ("5.0;5.2;5.4;5.6;5.8;5.10;6.0", ";")

// neonayon's full height range list during game play (after the initial limited selection of height of the character creation):
// Full Data.height = split ("3.0;3.2;3.4;3.6;3.8;3.10;4.0;4.2;4.4;4.6;4.8;4.10;5.0;5.2;5.4;5.6;5.8;5.10;6.0;6.2;6.4;6.6;6.8;6.10;7.0", ";")

...index_integer....|..string_value
...(height_rating)..|....(height)
--------------------|-----------------
........0...........|......3.0......
........1...........|......3.2......
........2...........|......3.4......
........3...........|......3.6......
........4...........|......3.8......
........5...........|......3.10.....
........6...........|......4.0......
........7...........|......4.2......
........8...........|......4.4......
........9...........|......4.6......
........10..........|......4.8......
........11..........|......4.10.....
........12..........|......5.0......
........13..........|......5.2......
........14..........|......5.4......
........15..........|......5.6......
........16..........|......5.8......
........17..........|......5.10.....
........18..........|......6.0......
........19..........|......6.2......
........20..........|......6.4......
........21..........|......6.6......
........22..........|......6.8......
........23..........|......6.10.....
........24..........|......7.0......
---------------------|---------------

a qwasi-part of your 'character creation' script block within~for your 'game' Object -> 'script' Tab -> 'start' Script:

showmenu ("Height?", Creation.height, false) {
player.height = ToString (result)

// The fix to deal with the issue of non-set 'player.height_rating=(null or unknown)', see below:

if (player.height = "5.0") {
player.height_rating = 12
} else if (player.height = "5.2") {
player.height_rating = 13
} else if (player.height = "5.4") {
player.height_rating = 14
} else if (player.height = "5.6") {
player.height_rating = 15
} else if (player.height = "5.8") {
player.height_rating = 16
} else if (player.height = "5.10") {
player.height_rating = 17
} else if (player.height = "6.0") {
player.height_rating = 18
}
}

// and because of the fix above, now your 'player.height_rating' is correctly set (after~from the character creation) and thus won't cause any issues with your global Turnscript:

<turnscript name="xxx">
<enabled />
<script>
player.height = StringListItem(Full Data.height, player.height_rating)
</script>
</turnscript>

// during game play, the full height range is the 'Full Data.height' Stringlist Attribute, from 3.0 to 7.0, by 2 inch intervals

// for example, neonayon has a 'height_growth_potion' that can be drunk during game play:

player.height_rating = player.height_rating + 2

// which then her global Turnscript kicks-in, changing her 'player.height'

HaganeSteel
Like my other post, this may or may not help. Maybe I can simplify what everyone is trying to say here.

In Carrion Fire, the player has two attributes: HP and Condition. Condition is a string. HP is an integer.

I then have a third attribute that's called changedHP. The attribute "changedHP" runs every time the HP integer is added to or subtracted from. This is what "changedHP" does:

HP.png


The "Condition" string, by default, says "Normal," since the player begins at max health.

HP2.png

HegemonKhan
thank you Hagane!

neonayon wasn't able to understand the special 'changed' Script Attributes from the wiki documentation, but your post will be a great help to her in understanding it! Especially as it has nice pics of doing it in the GUI~Editor, much easier for neonayon than her trying to figure it out in code from me, laughs.

She's currently using Turnscripts, which has the same effect as your method of using the special 'changed' Script Attributes.

her problem is~was slightly different as it dealt with conceptually (using your 'HP' and 'condition' example) needing a way to go from (a selected state of) 'condition' to 'HP', the opposite~backwards direction of your example, of going from (a change) in 'HP' to 'condition'.

--------

also, if you're interested (if you don't know of this already), you can do this (using my own labels~names, lol):

if (player.current_life_integer > player.maximum_life_integer) {
player.current_life_integer = player.maximum_life_integer
}


what this does is, say your life is: 'Life: 900/999", and you drink a health potion that restores +500 HP... this code will ensure that your life is this: 'Life: 999/999'.

and it will work for any max life, for anotehr example:

what this does is, say your life is: 'Life: 250/500", and you drink a health potion that restores +500 HP... this code will ensure that your life is this: 'Life: 500/500'.

it puts (assigns) your max life variable's value into your current life variable as its value.

HaganeSteel
If I'm understanding you right, you can just invert it.

It'd be a "changedCondition" script. If Condition = " Normal " then set variable: player.HP = 6.

The Pixie
Why not use JavaScript for the character creation?

http://textadventures.co.uk/games/view/ ... r-neonayon

Anonynn
The Pixie wrote:Why not use JavaScript for the character creation?

http://textadventures.co.uk/games/view/ ... r-neonayon


Pix, you cray cray if you think I can program in Java script!! I can barely use Quest! That looks fantastic though. But I think I'm too much of a newbie to do any substantial work like that. I still have to figure out a basic combat system, and items that affect the characters appearance. Maybe once I figure out those backbones I'll be able to Java.

Anonynn
Alright, so Pixie was helping me in email a bit, but I haven't been able to get a hold of him in the last few days to continue fixing things. I'm still not sure how to manipulate the coding or do what was hoping to do...

Here's what he did.

He created a secondary "GetHeight" function.

return ("" + player.height_rating / 12 + "'" + player.height_rating % 12)


and a "ListIndex" function as well.

// Returns the index of the given item in the given list, or -1 if it is not found
count = 0
msg ("looking for " + item)
foreach (o, lst) {
if (o = item) {
return (count)
}
msg ("not " + o)
count = count + 1
}
return (-1)


and he added a player.object, attribute called 'changedheight_rating...

player.height = GetHeight()



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

So my problem is, I don't know how to use this at all. He has a reply here saying...

[quote="The Pixie"]Looks like the creation bit gets you a string called result with the number of feet, a dot and then the inches (eg "5.6"). To convert that to an integer, (after handling random) do this:
height_as_array = Split(result, ".")
player.height_rating = ToInt(StringListItem(height_as_array, 0)) * 12 + ToInt(StringListItem(height_as_array, 1))

Consider player.height_rating to be the primary attribute, everything else is derived from that. If the player grows two inches, change that attribute like this.
player.height_rating = player.height_rating + 2

Then create a function call GetHeight. Set its return type to be a string, and paste in this code:
return ("" + player.height_rating / 12 + "'" + player.height_rating % 12)

Do you use the text processor to display the height?

If you do you do use the text processor:

Set up a secondary attribute, player.height, and a change script on player.height_rating to keep them in step. To do that, add a new attribute to the player called changedheight_rating, set it to be a script, and paste in this code:
player.height = GetHeight()


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

But as I said I still don't know how to just increase and decrease the height values during the game, and I don't know how to manipulate the other lists I have that don't have numerical values. As I said before, my two stringlist lists match up completely starting with "0". One list is for a character creation where the player has limited choices at first and one is a larger/expanded list that the player can get during the course of the game. Using height as an example is in the beginning they can choose between 5'0 to 6'0 (every 2 inches) ...and the expanded list allows them to become 3'0 to 7'0.

So I have other things in the list like haircolor, body sizes, orientations etc, which don't have numerical values. They are stringlists and match up starting at "0" as HK said.

But during the course of the game, I want "traps" to be able to decrease or increase those values with a quick code. For example...

((WARNING: THE FOLLOWING IS RATED R for RESTRICTED))

Let's say the player chooses to have a flat butt (lol) plank butt, and decide to drink a "butt increasing" potion, which expands their butt and makes it a little bigger.

So on the creation and fulldata stringlists both are flat "0" and the potion increases the butt +1 ....bringing them to the next level, small "1". Let's say they do it again, which makes their butt bigger, average "3" and so on.

((R-RATED SECTION COMPLETE))

So how would I do that? I hope this is clear x-x

The Pixie
Neonayon wrote:

"The Pixie"

Why not use JavaScript for the character creation?

http://textadventures.co.uk/games/view/ ... r-neonayon



Pix, you cray cray if you think I can program in Java script!! I can barely use Quest! That looks fantastic though. But I think I'm too much of a newbie to do any substantial work like that. I still have to figure out a basic combat system, and items that affect the characters appearance. Maybe once I figure out those backbones I'll be able to Java.


Given me a couple of days and I will see what I can do for you.

By the way, JavaScript is a very different language to Java.

The Pixie
Actually, if you e-mail me the latest version, I will hook in the library I created here:
viewtopic.php?f=18&t=5474

Anonynn
Ah, so that's what you've been up to? Did my questions/dilemma inspire all that new-coding? I'll shoot you the email asap. Just don't forget how to explain to me how to use it, haha.

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

Support

Forums