Adding verbs
Moderators: Ice Cream Jonsey, joltcountry
Adding verbs
Can 'new' verbs i want to include in my game be #included in a file (#include myverbs.g) or do they have to be declared in the main game file (before the grammar?)
-
- Posts: 119
- Joined: Fri Jun 27, 2003 12:10 pm
Either
They can be #included in a separate file, either before or after the game grammar. Guilty Bastards, for instance, has this in guilty.hug:
Now, what this means is that verbs in verblib.g take precedence over gb.g. If you wanted to override verblib.g's grammar, you'd need to define some grammar before it.
Basically think of #included files as being all part of the same big source file--that's the way the compiler looks at it, anyway.
Code: Select all
! Grammar must be included before anything else:
!
#include "verblib.g" ! normal verb library grammar
#include "gb.g" ! game grammar
#include "moreverb.g"
Basically think of #included files as being all part of the same big source file--that's the way the compiler looks at it, anyway.
- Ice Cream Jonsey
- Posts: 30193
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
Hey, can you have conditions for "living" and "object" for the same verb? I.E. -- and I don't mean that crappy Browser!!!!
... Anyway, if I try to run all that I see that it handles me trying to spit on a living object OK, but it won't invoke DoSpit if I try to spit on an object.
EDIT! Also, if I try to handle talking to an object and talking to a living entity in DoTalk (for instance, I have a skull in the game and I want the PC to be able to try to talk to it, but I don't want that skull to get any of the other privledges that the living tag offers) it'll mess up in the same way.
Is there a way to make it so that I can have different default commands for spitting on animate and inanimate things?
Code: Select all
verb "spit"
* DoVague
* living DoSpitLiving
* "on" living DoSpitLiving
* "at" living DoSpitLiving
* object DoSpit
* "on" object DoSpit
* "at" object DoSpit
routine DoSpitLiving
{
if object.conscious = 0
{
"I hock a sizeable loogie and let go."
}
else
{
"Being brought up by Old Man Duffy gets in the way of spitting in a face!"
}
}
routine DoSpit
{
"I try to keep the city clean, eh?"
}
... Anyway, if I try to run all that I see that it handles me trying to spit on a living object OK, but it won't invoke DoSpit if I try to spit on an object.
EDIT! Also, if I try to handle talking to an object and talking to a living entity in DoTalk (for instance, I have a skull in the game and I want the PC to be able to try to talk to it, but I don't want that skull to get any of the other privledges that the living tag offers) it'll mess up in the same way.
Is there a way to make it so that I can have different default commands for spitting on animate and inanimate things?
the dark and gritty...Ice Cream Jonsey!
-
- Posts: 119
- Joined: Fri Jun 27, 2003 12:10 pm
Workaround
Yeah, as it is now, the use of an attribute as an object placeholder will interrupt parsing if it gets a grammar match whether or not the object has that attribute--i.e., you'll be passed either to the verbroutine or to a parser error. This is not ideal and should probably be changed at some point (probably by improving the parser's notion of 'best error' and having it work more intelligently through a number of possible grammar matches).
What I would recommend doing is something like:
where DoSpitGeneral would do the dispatch for you, along the lines of:
Or something like that. There are a number of different ways to go about this (including just putting the test in the DoSpit[Living] routine, etc.) But this way probably abstracts it best.
What I would recommend doing is something like:
Code: Select all
* object DoSpitGeneral
Code: Select all
routine DoSpitGeneral
{
if object is living
return DoSpitLviing
else
return DoSpit
}
- Ice Cream Jonsey
- Posts: 30193
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact: