I’m trying to create a class that can be called to create a room and assign it a position relative to the previous room created. I have it partially working, considering how new I am to TADS, but I’m a little stuck. If I test the loop with a say(), it looks like the loop is indeed happening 3 times, but the results are puzzling when run to actually create the rooms… only the last room gets assigned, not each room in sequence. Also, a south direction gets added to the startRoom, but I don’t know why.
I only learn through practical application, so please help troubleshoot this
#charset "us-ascii"
#include <adv3.h>
#include <en_us.h>
versionInfo: GameID
;
class DynamicRoom: Room
construct(name_, dir_)
{
Room.roomName = name_;
dir_.north = Room;
Room.south = dir_;
}
;
myInitObj: InitObject
execute()
{
local prevRoom = startRoom;
for(local i = 0; i < 3; i++) {
local droom = new DynamicRoom('room #' + i, prevRoom);
prevRoom = droom;
}
}
;
gameMain: GameMainDef
initialPlayerChar = me
;
startRoom: Room 'Start Room'
"This is the starting room. "
;
+ me: Actor;