Hey everyone,
I’m fairly new to TADS 3, but not to IF authoring in general. I’ve worked with Inform 7 in the past, and, having an affinity for programming, I thought I would give TADS a go. I love it, and I’m currently trying to develop a skill system with dynamic/randomly determined outcomes for certain actions. I’ve got a lot of it working, but in an attempt to consolidate my code, I kind of entered some unfamiliar territory that I was hoping I could find some help with.
Here’s where I started to get tripped up. I created a new class of object, called Skill, which has a number of properties, which are all supposed to refer to names of other properties found in other objects (things, actors, and wearables, specifically). Here’s what the class declaration looks like, as well as a specific skill object I created.
[code]class Skill : object
sName = nil
cBName = nil
wBName = nil
cBonusName = nil
wBonusName = nil
;
balance : Skill
sName = sBalance
cBName = cBBalance
wBName = wBBalance
cBonusName = cBonusBalance
wBonusName = wBonusBalance
;[/code]
Now, here’s the meat of my questions. Having written and tested some other code, I’ve hit a series of roadblocks.
#1. I can’t find a way to get new functions to refer to specific skill objects, such as balance. For example, the following code does basically nothing, I think because the program isn’t actually looking for an object called “balance” even if the method is called with the argument as “balance.”
totalSkill(skill)
{
local s = skill.sName;
"<<skill.sName>> \n";
"<<s>>\n";
local c = skill.cBName;
"<<skill.cBName>> \n";
"<<c>>\n";
local w = skill.wBName;
"<<skill.wBName>> \n";
"<<w>>\n";
//return(&s + &c + &w);
}
(Aside: Most of the double-quoted strings in this code were put there for debugging purposes, and went completely ‘undsaid’ when the method was executed)
#2. I’m a bit confused as to when to use ‘&’ and when not to use it…by my best guess and understanding, I’m using these symbols correctly here, but I’m also willing to acknowledge that I’m wrong.
#3. Finally, is there any way to get the program to dynamically create a list of objects of a certain class, like my skill class, so that I could execute code using a foreach loop?
Thanks for any help you can offer. I realize that creating something like this might be a bit much for a newcomer, but it’s an idea I’ve had for years, since I first started working with IF.