Thanks for putting this extension online Jim (and thanks to Ben Cressey and Eric Eve for helping with the original code). I have been using this extension and have come up with some improvements. I posted a half-baked tests2.t to the ifarchive prematurely now I’m asking for feedback for the next update (the latest version of tests2.t is attached to this post “.t extensions are not allowed to be uploaded”?! Oh well I put it in a zip).
How to use the test2 extension in your TADs game:
[code]define Test objects like so:
foo: Test
testName = ‘foo’
location = livingRoom //the player character will be moved to livingRoom before the test
testList = [ ‘x me’, ‘i’ ]
;
bar: Test
testName = ‘bar’
testList = [ ‘look’, ‘listen’ ]
;
//you can use the normal + notation to set the location automatically
randomRoom : Room
;
+fob: Test //location = randomRoom
testName = ‘fob’
testHolding = [ matches, bread ] //these items will be moved into the player character’s inventory before the test.
testList = [ ‘light fire’, ‘toast bread’ ]
;
all: Test
testName = ‘all’
testList =
[
‘test foo’,
‘test bar’,
‘test fob’
]
;[/code]
Alternatively, you can include the following lines at the head of your file of test scripts: (a header file tests2.h with these lines is included in the zip - you can #include it in all your .t source files)
[code]/*
Test template ‘testName’ [testList] @location? [testHolding]?;
Test template ‘testName’ [testList] [testHolding]? @location?;
…and then use the template structure to create your test objects more conveniently:
someTest: Test ‘foo’ [‘x me’, ‘i’];
someTestInBedroom: Test ‘bedroom’ [‘x bed’, ‘enter bed’] @Bedroom;
someTestWithMobile: Test ‘mobile’ [‘x mobile’, ‘call bob’] [mobile_phone];
Unless you’re planning to refer to the Test object in some other part of your code,
you can save a bit of typing by making it an anonymous object:
Test ‘foo’ [‘x me’, ‘i’];
*/[/code]
Modifications to the original test extension:
[]location property - a test can be specified to occur in a specific room. The usual + composition works too.[/]
[]testHolding property - a test can be specified to occur with the player holding a list of game objects (beware that some types of object don’t appear in inventory but you can examine them).[/]
[]Use TemporaryFile for scripts.[/]
[]Eat your own dogfood - now tests2 has it’s own tests - define the symbol TEST_TESTS to enable them.[/]
Thanks again to Jim Aikin for great suggestions and help getting tests2 to work.
tests2.zip (3.08 KB)