Filtering / Selecting Entries From Tables

Hi all, I have a table that will keep track of levels of four different related skills.

I want to know how I can list out all the skills in the table that have a skill level above 0.

"Help Me Please"

ElementalSkill is a kind of value. The ElementalSkills are fire, water, earth and air.

Table of Elemental Skill Levels
Element	Level
Fire	0
Air	0
Water	0
Earth	0
	
LearningElementalSkill is an action applying to one ElementalSkill. Understand "learn [ElementalSkill]" as LearningElementalSkill.
Carry out LearningElementalSkill:
	Increment the level corresponding to an Element of the ElementalSkill understood in the Table of Elemental Skill Levels.

testing studio is a room. "You have learned the following skills: [The Element corresponding to a Level greater than 0 in the Table of Elemental Skill Levels]".
[ !!! THE LINE ABOVE DOESN'T WORK, WHAT'S THE CORRECT WAY? !!! ]

The player is in the testing studio.

I’m thinking I might have over-complicated this for myself and that a table isn’t needed, but I haven’t got anything else to work.
If I change the table to four number properties, then it makes defining rules that apply to all them much harder.
I have in mind for the player to be able to do something like an air blast or fire blast so that’s why I set them up as kinds of values under ElementalSkill. Some powers will be level-blocked hence the need for keeping track of them.

The phrase that you are using expects to get a specific value as input and to return a specific value as output. You’re trying to input a condition on a value, i.e. that level must be at least zero. It’s possible for more than one row to qualify, and it looks like you really want all matching rows instead of only a single row.

For what you are trying to do it will probably be easier to just iterate through the table. You can use a temporary list to accumumlate the relevant skills and then take advantage of the list to simplify output. Because you’re trying to place this in a room description, you will need to build a special to say... phrase.

"Help Me Please"

ElementalSkill is a kind of value. The ElementalSkills are fire, water, earth and air.

Table of Elemental Skill Levels
Element	Level
Fire	0
Air	0
Water	0
Earth	0
    
LearningElementalSkill is an action applying to one ElementalSkill. Understand "learn [ElementalSkill]" as LearningElementalSkill.
Carry out LearningElementalSkill:
    Increment the level corresponding to an Element of the ElementalSkill understood in the Table of Elemental Skill Levels.

testing studio is a room. "You have learned the following skills: [current skills].". [see following phrase]

To say current skills:
    let known skills be a list of elementalskills;
    repeat through the Table of Elemental Skill Levels: [see WWI 16.16 Repeating through tables]
	    if the level entry is greater than zero, add the element entry to known skills;
    if the number of entries in known skills is zero:
	    say "none";
    otherwise:
	    say known skills.

The player is in the testing studio.

Test me with "learn fire / look / learn water / look / learn air / look".

Ahh thank you! The missing ingredient was crafting a custom to say phrase!

Do you think the table is the right way to solve this problem?

If you would rather not use tables another way to do this would be to just attach the numbers to the player (you could also then give npcs their own skills levels as well to test for but you could also do this by giving everyone their own table of elemental levels). I’m not sure if one is better then the other but it seems like my example may be more lines if you’re only going to be using it for one person, but may decrease the amount of lines you have to write if you’ll have multiple people use this system.

"Skill Check"

Lab is a room.

An element is a kind of value. The elements are Fire, Air, Earth and Water.

The player has a number called Fire Elemental Level.
The player has a number called Air Elemental Level.
The player has a number called Earth Elemental Level.
The player has a number called Water Elemental Level.

To level up (the element - an element):
	if the element is Fire:
		increase the Fire Elemental Level of the Player by 1;
	otherwise if the element is Air:
		increase the Air Elemental Level of the Player by 1;
	otherwise if the element is Earth:
		increase the Earth Elemental Level of the Player by 1;
	otherwise if the element is Water:
		increase the Water Elemental Level of the Player by 1;

Leveling up is an action applying to one value.

Understand "Level up [an element]" as leveling up.

Carry out leveling up:
	level up the element understood.

Checking level is an action applying to nothing.

Understand "Check level" as Checking level.

Carry out checking level:
	say "Current Fire Element level is [the fire elemental level of the player].[line break]Current Air Elemental level is [the Air elemental level of the player].[line break]Current Earth Elemental level is [the Earth elemental level of the player].[line break]Current Water Elemental level is [the Water elemental level of the player]."
1 Like