Author Topic: Saying Anything But  (Read 5146 times)

0 Members and 1 Guest are viewing this topic.

Offline NilG

Saying Anything But
« on: April 27, 2019, 06:44:35 PM »
Me again,

Another stupid syntax question that I haven't been able to sort through.  I am trying to do something like the following:

(if (and (Said '[/*') (not (Said '/bulb[<green,red]'))) (= takeOrTouch 0) (self handsOff:))

Basically, I would like '/bulb[<green,red]' to get passed up to the locale script, but I still want to specify a response for anything else that is said.  This and various other things I've attempted have given me a bad spec error; I managed to get it almost working with a convoluted use of local variables, but when I do that, I get a "responseless" statement on top of the expected behavior for any other items I have specified in the room prior to the *.  I have a couple of ideas that might sort this latter method out involving pEvent claimed, but again, it already seems convoluted, and I assume there's probably just a straightforward way of doing this.

Besides, this is over time coming to happen in multiple statements across multiple rooms, so I'd rather not dirty up the code all over the place with hacky workarounds when I'm pretty sure I'm just missing some element of the syntax.  I've got enough crappy hacks in my illiterate code.   ::)

Thanks again in advance.



Offline troflip

Re: Saying Anything But
« Reply #1 on: April 28, 2019, 12:59:12 AM »
It's still not clear what you're trying to do. But it is clear that '[/*' is a bad spec, since there needs to be a matching ']'.

What do you mean by "I would like '/bulb[<green,red]' to get passed up to the locale script"? Can you clarify your scenario? btw, if you want to make sure the said event is not claimed (for instance, to match against something but still let future Said calls to continue matching), you add a '>' at the end of the spec.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline NilG

Re: Saying Anything But
« Reply #2 on: April 28, 2019, 02:08:17 AM »
Thanks, troflip, the typo's my bad, and no more bad specs when I add the other bracket, though it's still not working as I hoped.

Basically, ego's in a store, and the shopkeeper tells him to keep his hands off if he tries to take to mess with anything.  I didn't want to come up with a list of every potential item in the store, so I just went with *, and if someone types something that isn't there or misconstrues an object, no worries, since it will behave the same either way.

But they also potentially have a string of lights in their inventory from which they can take a couple of bulbs (all of which is handled in the locale script).  So I'd like them to be able to do that still, if they happen to try it in the store.

As a result, I want most 'take>'s to go with the default, but in this one particular circumstance, I'd like it to default to the locale script.  pEvent claimed: FALSE seems to work in cases where there isn't a [/*] association, but it appears that if there is that association, it will just bypass its own instructions and fall on the [/*], so I'm just trying to work out how to skip [/*] and pass the event onto the next script in the hierarchy, if possible.

Hope that makes a little more sense.

Offline troflip

Re: Saying Anything But
« Reply #3 on: April 28, 2019, 11:04:48 AM »
Well generally you want to match more specific Said's first. So just check for the lights before checking for *.

Or is there some handleEvent order issue preventing you from doing that? Why have a shopkeeper locale anyway, if this is just one room? Can't you just put everything in the shopkeeper's room?

Anyway, there's nothing stopping you from adding code to make locales/regions get a first crack at stuff. If they want.

You could also, as I mentioned before, just not claim the said event for [/*] by adding a '>'. Although I'm not sure that will help you - I still don't have a clear grasp on how your code is structured. It seems like no matter what you'll need the specific code to be run before the general code.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline NilG

Re: Saying Anything But
« Reply #4 on: April 28, 2019, 03:14:04 PM »
I am defining specific Saids first.  I guess maybe the question is whether there's just a way to pass a said up to the locale directly.  I've previously used pEvent claimed: FALSE when necessary and that's worked, but it only seems to work if there's no * following it (in which case I only need to define it anyway if it's part of a conditional or something).

The locale's not just the store, it's for the entire area; I just want take bulb to work here as it does throughout the rest of the area despite the fact that the store room has a take * defined.

The whole block I previously had was:

Code: [Select]
(if (Said 'take>')
(if (Said '/artifact')
(if (== gArtBoxFirstOpened FALSE) (Print 8 63)
else (if (== drevDist FALSE) (PrintDrev 8 51)
else (if (== boxOpen FALSE) (gEgo get: INV_ARTIFACT) (Print 8 105) (theOpenBox loop: 1)
else (gEgo get: INV_ARTIFACT) (Print 8 107) (theOpenBox loop: 1)))))
(if (Said '/bulb[<green,red]') (pEvent claimed: FALSE))
(if (Said '/hammer') (Print 8 62))
(if (Said '/grease[/jar]')
(= takeGrease TRUE) (pEvent claimed: FALSE))
(if (and (Said '[/*]') (= takeOrTouch 0) (self handsOff:))
)

This all works except for the bulb line, as when I don't claim the event it's just taken by *.  I'm looking for a way to shoot this one particular statement up to the locale while leaving everyone else to play in this script as is.

I could absolutely be going about it all wrong; I guess I just don't know how to specifically say "send this event to locale and ignore the rest of the conditionals here."

Offline troflip

Re: Saying Anything But
« Reply #5 on: April 28, 2019, 03:28:09 PM »
Change it to this:
Code: [Select]
(if (Said '/bulb[<green,red]>') (pEvent claimed: FALSE))
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline NilG

Re: Saying Anything But
« Reply #6 on: April 28, 2019, 04:49:00 PM »
Aah, okay.  Sorry, I didn't entirely understand the scope of the > at the end, I think.


With the whole bit changed to

      
Code: [Select]
(if (Said 'take>')
(if (Said '/artifact')
(if (== gArtBoxFirstOpened FALSE) (Print 8 63)
else (if (== drevDist FALSE) (PrintDrev 8 51)
else (if (== boxOpen FALSE) (gEgo get: INV_ARTIFACT) (Print 8 105) (theOpenBox loop: 1)
else (gEgo get: INV_ARTIFACT) (Print 8 107) (theOpenBox loop: 1)))))
(if (Said '/bulb[<green,red]>') (pEvent claimed: FALSE))
(if (Said '/hammer') (Print 8 62))
(if (Said '/grease[/jar]>') (pEvent claimed: FALSE))
(if (Said '[/*]') (= takeOrTouch 0) (self handsOff:))
)

my poor guy is still getting yelled at for trying to take shit in the store, though.  I'm going to play around with it some more, but if anything else looks plainly wrong with this, I'm all ears.

Offline troflip

Re: Saying Anything But
« Reply #7 on: April 28, 2019, 06:50:15 PM »
Yes, each Said statement is being executed there, and the last one ('[/*]') will match anything and thus claim the said event, which is what I think you are trying to prevent?

It seems like once you match any of these, you don't want to continue trying the others. Normally it wouldn't matter, since they would all fail once a Said has been claimed. But since you added the '>' to the grease jar clause, if that Said returns true, the Said has still not been claimed, so anything that matches afterward will also succeed.

I suspect you could get away with a cond statement here instead:

Code: [Select]
(if (Said 'take>')
(cond
((Said '/artifact')
(if (== gArtBoxFirstOpened FALSE) (Print 8 63)
else (if (== drevDist FALSE) (PrintDrev 8 51)
else (if (== boxOpen FALSE) (gEgo get: INV_ARTIFACT) (Print 8 105) (theOpenBox loop: 1)
else (gEgo get: INV_ARTIFACT) (Print 8 107) (theOpenBox loop: 1)))))

((Said '/bulb[<green,red]>') (pEvent claimed: FALSE)) ; I doubt you even need to do claimed: FALSE here now that you have > ...
((Said '/hammer') (Print 8 62))
((Said '/grease[/jar]>') (pEvent claimed: FALSE))
((Said '[/*]') (= takeOrTouch 0) (self handsOff:))
)
)



« Last Edit: April 28, 2019, 09:48:14 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline NilG

Re: Saying Anything But
« Reply #8 on: April 29, 2019, 04:55:11 PM »
Nice, okay, I see now.  The cond implementation does appear to do the trick, and all is looking good now.   8)  Thank you.


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.047 seconds with 23 queries.