i want to be able to holster my gun, draw my gun and shoot my gun,
Here’s a very rough skeleton for all three actions. You will need to add more synonyms for the verbs and many more checks around shooting.
DefineTAction(Holster);
VerbRule(Holster)
'holster' singleDobj
: HolsterAction
verbPhrase = 'holster/holstering (what)'
;
DefineTAction(Draw);
VerbRule(Draw)
'draw' singleDobj
: DrawAction
verbPhrase = 'draw/drawing (what)'
;
DefineTIAction(ShootWith);
VerbRule(ShootWith)
'shoot' singleDobj 'with' singleIobj
: ShootWithAction
verbPhrase = 'shoot/shooting (what) (with what)'
;
modify Thing
dobjFor(Holster)
{
preCond = [objHeld]
verify() { illogical('You can\'t holster {that dobj/him}. '); }
}
dobjFor(Draw)
{
preCond = [objHeld]
verify() { illogical('You can\'t draw {that dobj/him}. '); }
}
dobjFor(ShootWith)
{
preCond = [objVisible]
verify() { illogical('You see no need to shoot {the dobj/him}. '); }
}
iobjFor(ShootWith)
{
preCond = [objHeld]
verify() { illogical('You never learned to shoot {a iobj/him}. '); }
}
;
class Gun: Thing
dobjFor(Holster)
{
verify() {}
check()
{
if (isHolstered())
failCheck('{The dobj/him} is already holstered. ');
}
action()
{
"You holster {the dobj/him}. ";
holster();
}
}
dobjFor(Draw)
{
verify() {}
check()
{
if (isDrawn())
failCheck('{The dobj/him} is already drawn. ');
}
action()
{
"You draw {the dobj/him}. ";
unholster();
}
}
iobjFor(ShootWith)
{
verify() {}
check()
{
if (isHolstered())
failCheck('You cannot shoot {the iobj/him} from the holster! ');
}
action()
{
"You take aim at {the dobj/him} with {the iobj/him} and open fire! ";
}
}
notifyMoveInto(newCont)
{
unholster();
inherited(newCont);
}
isDrawn() { return !holstered_; }
isHolstered() { return holstered_; }
holster() { holstered_ = true; }
unholster() { holstered_ = nil; }
holstered_ = nil;
;
class Target: Thing
dobjFor(ShootWith)
{
verify() {}
}
;
revolver: Gun 'revolver' 'REVOLVER' @me
"An old-fashioned six shooter. "
;
apple: Target 'apple' 'APPLE' @me
"A large red apple. "
;
If you haven’t seen it already, you should read Getting Started in TADS 3. TADS 3 is a pretty easy language to pick up, but the adv3 library is quite complex and will take a fair bit of effort to bend to your will.