View previous topic :: View next topic |
Author |
Message |
Hugella Guest
|
Posted: Tue Dec 09, 2003 9:21 am Post subject: 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?) |
|
Back to top |
|
 |
Kent
Joined: 27 Jun 2003 Posts: 119
|
Posted: Tue Dec 09, 2003 12:20 pm Post subject: 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:
Code: |
! Grammar must be included before anything else:
!
#include "verblib.g" ! normal verb library grammar
#include "gb.g" ! game grammar
#include "moreverb.g" |
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. |
|
Back to top |
|
 |
Ice Cream Jonsey
Joined: 27 Apr 2002 Posts: 20088 Location: Colorado
|
Posted: Tue Dec 09, 2003 9:00 pm Post subject: |
|
|
Hey, can you have conditions for "living" and "object" for the same verb? I.E. -- and I don't mean that crappy Browser!!!!
Code: |
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! |
|
Back to top |
|
 |
Kent
Joined: 27 Jun 2003 Posts: 119
|
Posted: Tue Dec 09, 2003 10:23 pm Post subject: 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:
Code: |
* object DoSpitGeneral |
where DoSpitGeneral would do the dispatch for you, along the lines of:
Code: |
routine DoSpitGeneral
{
if object is living
return DoSpitLviing
else
return DoSpit
}
|
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. |
|
Back to top |
|
 |
Ice Cream Jonsey
Joined: 27 Apr 2002 Posts: 20088 Location: Colorado
|
Posted: Wed Dec 10, 2003 1:02 am Post subject: |
|
|
You da man, Kent. Thanks.
Now, to code the horrible wasting disease that my protagonist's spit will contain!!! _________________ the dark and gritty...Ice Cream Jonsey! |
|
Back to top |
|
 |
Brazillio Guest
|
Posted: Wed Dec 10, 2003 2:35 pm Post subject: |
|
|
I'm pregnant and I don't know who the father is! It could be any of you! Help me, Hugo! |
|
Back to top |
|
 |
|