tables supported?
Kit_sune
21 Oct 2012, 02:13Why would I want to use one you ask?
Well instead of creating a bunch of templates like I had originally considered, I thought it would be better to create a few tables that could be referenced.
I would just write the code that would make the starting attributes of the player the same as the table.
like,
Attribute / human / elf
health / 50 / 70
Thanks for your time and sorry if that's not clear enough.
The Pixie
21 Oct 2012, 10:10
jaynabonne
21 Oct 2012, 10:12As far as coding with tables -that seems like a fairly specialized thing. What it really seems that you want is "data import using tables", but there is nothing directly in Quest for that. In my opinion, that's a bit esoteric and not something the majority of people would want to do ever. (Yes - you're special!

What would be handy (especially given Pixie's response) would be some form of serialized object format...
Kit_sune
21 Oct 2012, 15:38So after searching a bit, I realize that tables are mostly a "Lua" language thing. (That's the language I started with) And the resource I was reading references their likeness to arrays, since most programmers are familiar with those.
From: http://www.lua.org/pil/11.html
Lua
11 – Data Structures
Tables in Lua are not a data structure; they are the data structure. All structures that other languages offer---arrays, records, lists, queues, sets---are represented with tables in Lua. More to the point, tables implement all these structures efficiently.
In traditional languages, such as C and Pascal, we implement most data structures with arrays and lists (where lists = records + pointers). Although we can implement arrays and lists using Lua tables (and sometimes we do that), tables are more powerful than arrays and lists; many algorithms are simplified to the point of triviality with the use of tables. For instance, you seldom write a search in Lua, because tables offer direct access to any type.
I guess what I'm really looking for is something that looks like this:
LISTrace = {
human = { race = human, hp = 50, maxhp = 50, str = 4, atk = 5},
foxdemon = { race = fox, hp = 75, maxhp = 75, str = 3, atk = 4},
catdemon = { race = cat, hp = 60, maxhp = 60, str = 2, atk = 4},
}
Of course, this is just what I'm looking for. Let me reiterate - This is what I work with for my job, tables. I realize I wouldn't really know how to call the values from these arrays once I figured out how to make it work this way, lol.
Thanks for the input,

jaynabonne
21 Oct 2012, 18:46name=value, name=value, name=value, ...
There is a function called "ApplyAttributes", which takes an object (e.g. the player) and a string like the above, and for each name/value pair, assigns an attribute to the object with the given value.
For example, you can list the "Human" attributes as "race=human, maxhp=50, speed=10, stamina=45", and if you ApplyAttributes to the player with this string, then player.race will equal "human" (as a string), maxhp will equal 50 (as a number), etc.
This is a more compact format, and is in line (I think) with what you want.
The test app has a string attribute for each race stored in the game. The list to be shown is built up directly, and the menu shown. Then the selected race's attributes are applied to the player.
See how that is!
Kit_sune
21 Oct 2012, 19:39You had,
<HumanRace>race=human, maxhp=50, speed=10, stamina=45</HumanRace>
<DogRace>race=dog, maxhp=15, speed=20, stamina=20</DogRace>
<CatRace>race=cat, maxhp=8, speed=15, stamina=18</CatRace>
Would there be any way to make it so that these lists (HumanRace, DogRace, CatRace) were inside of another list? (like a races list) For instance, so that maybe the dictionary choices could read as follows:
dictionary add (choices, game.races.HumanRace, "Human")
dictionary add (choices, game.races.CatRace, "Cat")
dictionary add (choices, game.races.DogRace, "Dog")
It might just be complicating things a little too much. I am aware that there really wouldn't be much of a difference to do it either way, if it was possible, but just something that I am very very curious about.

jaynabonne
21 Oct 2012, 19:51Create an object to hold the race strings.
<object name="Races">
<HumanRace>race=human, maxhp=50, speed=10, stamina=45</HumanRace>
<DogRace>race=dog, maxhp=15, speed=20, stamina=20</DogRace>
<CatRace>race=cat, maxhp=8, speed=15, stamina=18</CatRace>
...
</object>
And then in your game object have:
<game ...>
....
<races type="object">Races</races>
...
</game>
Then you can either use "game.races.HumanRace" or just "Races.HumanRace". If you prefer the second format, then don't even bother with the game "races" attribute.

Believe me, I understand the motivation for this, that desire to organize things!
Kit_sune
21 Oct 2012, 21:30So the function ApplyAttributes does all these nifty things for me behind the scenes, I like it! Now if only I knew exactly how it works.
I get the jist of it, but it would take me a long time to come up with something like that.

jaynabonne
21 Oct 2012, 22:47It does that over and over, marching along, until it runs out of string. Of course, the devil is in the details... I've written code like that far too many times.

Glad it's working for you.

jaynabonne
23 Oct 2012, 23:12Kit_sune
24 Oct 2012, 00:56Even if it does nearly the same thing as the ApplyAttributes function, I'd be more than willing to see how the StringDictionary version of it works so I could learn some more. It could come in useful.
Just a quick question for whoever reads it, did you all go to a programing course/class/school?
I've had to self teach myself a lot of things, and programing has been by far the toughest thing to learn. I've been returning to it for over 13 years (when I was 13 years old) with various different programs that allow you to manipulate code. I've always been fascinated by it, but I've never had the fortune to take any classes, and most tutorials I've poked around in were really confusing with how they bounce around.
I don't want anyone here to get the idea that I'm trying to get you all to write all my code for me - I really aim to learn this stuff. But it's kind of embarrasing asking for so much help because I know you all have your own projects, and have been to school, so why should I get any special treatment? I'm just so grateful with all the help I've received so far that for once I feel like I might actually be begining to understand how this stuff works.
I'm the kind of person who needs to understand every . little . detail about how something works before it all clicks into place. It's like putting all the cogs together. If I'm missing even one cog, they won't function properly!!!
Ok I'm done with my story XD
If TLDR I'm sorry !!
Kitsune
The Pixie
24 Oct 2012, 08:06Here is an alternatve version. ApplyAttributes is much smaller, but other parts of the code got bigger. I found the easiest way was to have each race template as an object, with stringdictionary attached.
<!--Saved by Quest 5.2.4515.34846-->
<asl version="520">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="ApplyAttributes">
<gameid>e4c54dda-b7a0-470f-abbc-2d603f94a18e</gameid>
<version>1.0</version>
<start type="script">
choices = NewStringList()
races = NewObjectList()
list add (races, HumanRace)
list add (races, CatRace)
list add (races, DogRace)
foreach (race, races) {
list add (choices, race.name)
}
msg(" ")
show menu ("What is your race?", choices, false) {
// Copy all the attributes, using the "attributes" string list as key.
ApplyAttributes(player, GetObject (result))
msg("player.race = " + player.race)
msg("player.maxhp = " + player.maxhp)
msg("player.speed = " + player.speed)
msg("player.stamina = " + player.stamina)
}
</start>
</game>
<object name="HumanRace">
<stats type="stringdictionary">race=Human; maxhp=50; speed=10; stamina=45</stats>
</object>
<object name="DogRace">
<stats type="stringdictionary">race=Dog; maxhp=15; speed=20; stamina=20</stats>
</object>
<object name="CatRace">
<stats type="stringdictionary">race=Cat; maxhp=8; speed=15; stamina=18</stats>
</object>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
</object>
</object>
<function name="ApplyAttributes" parameters="object, race"><![CDATA[
foreach (attribute, race.stats) {
value = StringDictionaryItem (race.stats, attribute)
if (IsNumeric(value)) {
set (object, attribute, ToInt(value))
} else {
set (object, attribute, value)
}
}
]]></function>
</asl>

jaynabonne
24 Oct 2012, 09:12