Author Topic: Negation of Said()  (Read 6111 times)

0 Members and 1 Guest are viewing this topic.

Offline gumby

Negation of Said()
« on: November 11, 2010, 10:50:52 PM »
I'm trying to test to see if something is NOT said.  Here is what I came up with:
Code: [Select]
(if(not Said('look'))
   Print("You did NOT type look")
)
...which works, sort of.  The problem is that the print statement is displayed for every keystroke & mouse click.  Once I finally get the text input box to show up (after many gyrations of keystrokes & mouse clicks), and I type 'look', the print message is not displayed, which is precisely what is desired.

Anyone got any ideas how to accomplish this correctly?


In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Cloudee1

Re: Negation of Said()
« Reply #1 on: November 12, 2010, 11:30:17 AM »
Adding a pevent claimed true should take care of it. I think.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline MusicallyInspired

Re: Negation of Said()
« Reply #2 on: November 12, 2010, 03:19:54 PM »
Fascinating. And yeah, I agree with Cloudee, seeing as it's not just looking for if you have "Said" something but any event covered under the handleEvent method...which is any input besides Saids as well.
Brass Lantern Prop Competition

Offline Cloudee1

Re: Negation of Said()
« Reply #3 on: November 12, 2010, 04:20:17 PM »
Oh I see, I apparantly skimmed a little bit. I would start by hijacking troflips easy alt debugging to narrow the handleevent to just keystroke events, not mouseclicks. To get it further I would need to try it out myself.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline gumby

Re: Negation of Said()
« Reply #4 on: November 12, 2010, 10:06:52 PM »
I got it figured out.  At first glance I was skeptical of the no-claim direction, however:
Code: [Select]
(if(Said('*>'))
    (if(not Said('look'))
         Print("You did NOT type 'look'")
         (send pEvent:claimed(TRUE))
    )( else
(send pEvent:claimed(FALSE))    
    )
)
...sure seems to work!  So you start by doing a no-claim on *everything*, which gets you into a 'legitimate' user input (no mouse clicks/directional keys, etc).  Then just perform the event handling.  Works great.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline gumby

Re: Negation of Said()
« Reply #5 on: November 15, 2010, 04:03:03 PM »
Great.  So my above code does not work when you have more than one Said() negation in an if statement.  So I need an 'inline'/one-liner solution, similar to this (from my first post)
Code: [Select]
(if(not Said('look'))
   Print("You did NOT type look")
)
I was thinking about writing a procedure to do this, & use the said string as the parameter - but I never solved the problem in this thread here http://sciprogramming.com/community/index.php/topic,286.0.html regarding dynamic said strings.
« Last Edit: November 15, 2010, 04:06:07 PM by gumby »
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline gumby

Re: Negation of Said()
« Reply #6 on: November 15, 2010, 09:15:22 PM »
I'm an idiot... the post I referenced actually HELPED me solve the problem rather than stand in my way.  It must be one of those days.

Here is the complete solution:
Code: [Select]
(instance RoomScript of Script
(properties)
(method (handleEvent pEvent)
           (super:handleEvent(pEvent)

           (if(== NotSaid('look' pEvent) TRUE)
                 Print("You did not say LOOK!")      
           )        
  )
)

(procedure public (NotSaid saidStr pEvent)
   (if(Said('*>'))
       (if(Said(saidStr))
     (send pEvent:claimed(FALSE))
     return FALSE
       )( else
     (send pEvent:claimed(TRUE))
     return TRUE
       )
   )
)
Really straight-forward, no? 

EDIT:  Now that I look more closely at this, this isn't going to work for any word in the string that is inputted.  It will work for the first word only.  The procedure really ought to be named 'NotVerbSaid', or it should be retooled to go through every token in the Said(), not just the first.
« Last Edit: November 15, 2010, 09:23:26 PM by gumby »
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition


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

Page created in 0.037 seconds with 22 queries.