[TADS] A particular set of beginner questions

So I’m definitely a beginner with this program, and you know how it is, you try rushing into it and you find yourself attempting things that are obviously out of your league… But still.

So, I’m trying to do a generic game and learn along the way, but I have one defining aspect of my game I’m not sure how to best implement. So one of the concepts of the game is that the world around the character will distort (text based description distortion) as the values within him are altered. For instance, if his internal me.happy variable is less than 4, the dresser changes from “It’s a generic Dresser” to “It’s a gloomy dresser”. (These are just example descriptions. I’m worried about code at the moment, not my writing. XD)

Now that’s not it though. Not only would the description change when examined, but all listings would need to change about the dresser, so the listing in the room would have to adapt.

The character starts off lying in bed, so I was able to make the description more apt by doing such:

myBedRoom: Room 'My Bedroom' 'my bedroom' desc { "This is my bedroom. You see a large <<dresser.color>> dresser and a black desk. A mirror adornes the wall next to the door." ; if (me.posture == lying && me.location == myBed) "\b You are lying in bed."; else "There is a bed in the corner."; } east = houseHallway

And as you can see there, I already implemented a color for the dresser. The problem is I am uncertain how to continually modify the object descriptions and I really don’t want to stick in a switch function into the desc of the room itself and then into each object. I’d prefer it if the room just took the switch function passed to it from the objects, but I’m a little unsure how. I tried making functions within the objects of the room, but I’m mis-using the code and so nothing is quite working.

I repeat: I realize this is probably simple and I’m getting ahead of myself, but looking through the manuals wasn’t very specific about my issue so I thought maybe approaching others for help could let me continue learning without being stuck on this particular issue of my game.

As an aside: My experience is with a tiny bit of C and a whole lot of MatLab, which is a modified C derivative.

One way to do it would be to create a mood object of type Thing somewhere in your code, in which you define colors of various things you want to be able to change. Then, whenever you want to use the current color of that thing, the room color, for example, simply refer to it as mood.roomColor.

Similarly, when you want to change it, do the same thing: mood.roomColor = ‘green’.

In the following example, the initial mood object sets room color to red. Then when the player character moves into the green room, the mood.roomColor variable gets set to green…

me: Actor 'me' @redRoom
    ""
    actorBeforeTravel(traveler, connector)
    {
        if(connector.destination == greenRoom)
            mood.roomColor = 'green';
    }
;

redRoom: Room 'Red Room' 'red room'
    "The room in which things are <<mood.roomColor>>. <.p>"
    
    south = greenRoom
;
;

greenRoom: Room 'Green Room' 'green room'
    "The room in which things are <<mood.roomColor>> <.p>"
     
    north = redRoom
;

mood: Thing 'mood'
    "mood"
    
    roomColor = 'red'
;

Here’s how it looks in the game window…

First off, thanks for the response! Creating a separate object to reference could work, but I’m not sure that it’s exactly what I need.

My main goal is to make each item independently switching. So not all items will have the same adjectives but have appropriate adjectives and descriptions for themselves which switch depending upon the main character’s numerical stats.

The issue is, I’d like actions to alter the main character’s numerical stats, and then I want the items in the room to ‘update’ to reflect his altered stats. Of course, they would only ‘update’ once they were looked at again or a room was entered or something.

Let me put it another way, here is sort of a flow through of what I’d like to happen:

Character enters Room A.
Room A’s description says: This room has plain green walls and a brown floor.
Character A reads book. Internal Happy-status +1
Character A draws picture. Internal Happy-status +1
Character A opens fridge. Character A eats cheesecake. Internal Happy-status +3
Character A looks at room.
Room A’s description says: This room has sparkling green walls and a mahogany floor.
Character A enters room B.
Room B’s description says: This room has a beautiful painting on the wall and dynamic lighting.
Character A looks at painting.
Painting description says: It’s a beautiful painting of a man riding a horse jumping over a deep blue river.
Character A eats spinage. Internal Happy-status -1
Character A calls dad and finds out his dog got hit by a car. Internal Happy-status -35
Character A looks at room.
Room B’s description says: This room has a morbid painting on the wall and grey lighting that makes a buzzing noise.
Character A looks at painting.
Painting description says: It’s a morbid painting of a sickly man riding a horse jumping over murky waters.

Does that make sense? I could be asking a lot. Sorry. XD

I didn’t test, but this doesn’t sound hard. What you need is to define dresser.color as a method instead of a property, and the method returns a single-quoted string, that way you can still use “<<dresser.color>>” (or rather, “<<dresser.color()>>”) in your description, and the method dresser.color() will be something like:

dresser: Thing ... ... color() { if ( me.happy > 4 ) { return 'green'; } else { return 'grey'; } } ... ;
This way the description of the dresser should change color depending on the PC’s happiness, and it applies every description where you use “<<dresser.color()>>”.

YES! That did it! Thank you! :slight_smile:
Yeah, this works perfectly. I knew it was something that could probably be done rather simply, as long as approached the right way, but I was too new to know how.
ThankyouThankyouThankyouThankyouThankyouThankyou!!!

Ok… so I have another question XD
Everything is running smoothly, and I’m making headway on learning other factors of the code, but I have a concept that I wanted to implement now rather than later, but I can’t seem to make headway.

So, my character has hidden stats, and I want an item to appear permanently on my character when a certain level of stat is reached.
Now the permanence part wouldn’t be too hard, as I’d just have to modify the remove function I think.

The problem is I’m a little uncertain how to modify my character’s inventory status.
You see, the ‘check’ about the status only needs to happen when my character either looks in a mirror or checks his inventory. So, my question is then probably a basic one. How do I modify the inventory command such that before it actually checks the protagonist’s inventory it adds or gets rid of this permanent item? I’d also need to do it for the mirror, but modifying a mirror to make it work is something I’d have to mess around with quite a bit anyways, so I’m not as worried about that.

I tried to work with the actorInventory command and if statements, but nothing seems to work, so I think I’m calling it completely wrong. How does one call that command and modify it but keep it’s usual (inherited?) reaction?

And thanks again!

My first question is, is the “item” you’re referring to a separate object, or one that can be conceived of as separate? Such as, perhaps, some bulging muscles? If so, just leave the item offstage until it’s needed, and then move it into the player object. If you don’t want it to be removable thereafter, consider making it a Component.

My T3 is extremely rusty, so I’m not going to get into the specifics, but that seems like a decent strategy.

To decide when it’s time to move the Component into the player, use the routine that adds to the stats. Each time the relevant stat is incremented, check to see whether it has passed the required threshold. If so, move the Component into the player.

Yeah sort of. Well for instance, one concept is that they gain glasses after the character’s eyesight gets worse. I still want it listed in inventory because the player will wear them, but I’ll just change the remove command to “If I remove the glasses I won’t be able to see very well.” rather than actually removing the glasses.

I’ve already made a holding room for items that won’t be available to the player at different points, so I agree with you there.

It’s possible I could use that, it’s just that many of the changes through the actions will be subtle and the events which cause the changes will be large…

So really, what I need is some sort of function which can be accessed shortly during the events. So for instance:
Player A fights with Player B.
Player A’s eyesight is decreased 1 point.
Call Function that checks player’s stats, and makes changes and notifies player of effects depending upon whether the thresholds have been crossed or not, and adds/gets rid of those items as needed.

So, I guess I’m trying to make a class of function which will activate depending upon which aspects are incremented?

I guess I’m jumping in over my head here. XD
I should really practice my dialogue and action coding more before I get too far into this. Thats ok :slight_smile:
I realize I was approaching this wrong though so that helps!

The player object has a beforeAction method, which I’m pretty sure will be called every turn before the player’s command is executed. This is a handy place to make adjustments of this sort. You’ll still have to write a bunch of code to test everything you want tested, but there’s no way around that.