Author Topic: Best way to handle a mailbox?  (Read 10501 times)

0 Members and 1 Guest are viewing this topic.

Offline MusicallyInspired

Best way to handle a mailbox?
« on: June 08, 2007, 01:43:38 PM »
Should I treat it as a door and use the door class? Or just do it normally?


Brass Lantern Prop Competition

Offline Doan Sephim

Re: Best way to handle a mailbox?
« Reply #1 on: June 08, 2007, 01:53:24 PM »
Probably the best way I can think to do it, is set up a control color near it and whenever you walk on the control color have the mailbox door open automatically, and then, whenever you are not on the control color, have the mailbox door close.

Code: [Select]
(method (doit)
  (super:doit)
    (if(== (send gEgo: onControl()) ctlSILVER)
      (if(boxDoorClosed)
        (mailbox:setCycle(End)) // opening animation
        = boxDoorClosed 0
      )
    )(else
      (if(not(boxDoorClosed))
        (mailbox:setCycle(Beg)) // reverse opening animation
        = boxDoorClosed 1
      )
    )
  )
)

Having it be automatic might be a nice addition. I used something similar to this in the New Year's Mystery when the bathroom mirror closed automatically when you walked away from it.

EDIT: I just thought of something better. Instead of using a control color, you could just use a distance:

(if(<=(send gEgo:distanceTo(mailbox))20)
« Last Edit: June 08, 2007, 01:56:07 PM by Doan Sephim »
Artificial Intelligence Competition

Offline MusicallyInspired

Re: Best way to handle a mailbox?
« Reply #2 on: June 08, 2007, 02:11:05 PM »
No, I don't want it to be automatic. I'm just wondering how to code it that's all. I can't figure out how to make something animate only once, is my problem. It also won't send to my theMailbox instance from within the said statement 'if' which I don't get.
Brass Lantern Prop Competition

Offline Doan Sephim

Re: Best way to handle a mailbox?
« Reply #3 on: June 08, 2007, 02:21:12 PM »
For something to animate once, you just have to use something like
Code: [Select]
(mailbox:setCycle(End))"End" tells it to cycle only to the last cel in the loop.

To code it you need to put it in the handleEvent method:
Code: [Select]
(if(Said('open/door,mailbox'))
   (if(<=(send gEgo:distanceTo(mailbox))25)
      Print("OK")
      (mailbox:setCycle(End))
   )(else
       PrintNotCloseEnough()
   )
)

That (or something similar) should work.

Offline troflip

Re: Best way to handle a mailbox?
« Reply #4 on: June 08, 2007, 02:25:06 PM »
It also won't send to my theMailbox instance from within the said statement 'if' which I don't get.

Are you using
Code: [Select]
(send theMailBox:setCycle(End))
?

That won't work... for instances you need to drop the send:
Code: [Select]
(theMailbox:setCycle(End))

But assign the instance to a variable:
Code: [Select]
(= myProp theMailbox)

and suddenly you have to use send if you reference it through the variable:
Code: [Select]
(send myProp:setCycle(End))

Crazy.... my c-syntax will eliminate this kind of stuff.  you would just do
Code: [Select]
theMailbox.setCycle(End);
or
Code: [Select]
var myProp = theMailbox;
myProp.setCycle(End);
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Best way to handle a mailbox?
« Reply #5 on: June 16, 2007, 12:12:55 AM »
Ok. Got the mailbox opening and closing nicely. I'm having a bit of problems with the look saids. I was "look mailbox" and "look in (or inside) mailbox" to give two different messages.

I'm using a:

Code: [Select]
(if(Said('look>'))
        (if(Said('/fence'))
            Print("You see a wooden fence surrounding the cottage.")
        )
kind of look statement code. Here are the two mailbox saids I'm using at the moment. I've tried changing the order but it doesn't help. It keeps giving me the message for "look mailbox" either way and ignores "look in/inside mailbox".

Code: [Select]
(if(Said('/mailbox'))
            Print("The mailbox has the words 'Grandma's House' on it.")
        )

and

Code: [Select]
        (if(Said('/inside / mailbox'))
        (if (== (send gEgo: onControl()) ctlSILVER)
        (if (mailboxClosed)
        Print("The mailbox is closed. You cannot look in it.")
)(else
Print("You see a basket of goodies in the mailbox.")
)
)(else
Print("You're not close enough.")
)
)

I've also tried things like "/ (in , inside) mailbox" and "/ inside < mailbox". Nothing works. Any ideas?
Brass Lantern Prop Competition

Offline troflip

Re: Best way to handle a mailbox?
« Reply #6 on: June 16, 2007, 02:07:59 AM »
I think what you want is:
Code: [Select]
Said('look<in/mailbox')
However,
Code: [Select]
Said('look/mailbox')will match both "look mailbox" and "look in mailbox".

Therefore this
Code: [Select]
Said('look<in/mailbox')needs to come before
Code: [Select]
Said('look/mailbox')

I usually flatten all my Said statements for clarity... so it would look like this:
Code: [Select]
(if (Said('look<in/mailbox'))
Print("You see a letter.")
)
(if (Said('look/mailbox')) // This won't match "look in mailbox" anymore, since it was already matched above
Print("What a nice mailbox.  I wonder what's inside")
)

With your way, it would be like this I guess:
Code: [Select]
(if (Said('look>'))
(if (Said('<in/mailbox'))
Print("You see a letter.")
)
(if (Said('/mailbox')) // This won't match "look in mailbox" anymore, since it was already matched above
Print("What a nice mailbox.  I wonder what's inside")
)
)



btw, 'in' is already a synonym of 'inside', so you only need to use one or the other.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Best way to handle a mailbox?
« Reply #7 on: June 16, 2007, 11:36:04 AM »
Perfect, thank you.

Now I'm having trouble with inventory items. I have a basket object. When I pick it up I can't look at it. When I press tab it says Test Object in my inventory. I've already changed the Test Object instance in the Main script to the attributes of this basket and also replaced {Test Object} in the inventory list near the end of Main's "Template of Game" instance. Why is it still saying Test Object and why can't I look at it with the parser?

EDIT: I just finished looking through every single script in the game and I cannot find the words "Test Object" anywhere. Where is the game getting it from??
« Last Edit: June 16, 2007, 12:00:03 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline troflip

Re: Best way to handle a mailbox?
« Reply #8 on: June 16, 2007, 02:27:03 PM »
And you recompiled everything and there were no errors?
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Best way to handle a mailbox?
« Reply #9 on: June 16, 2007, 09:20:49 PM »
Ah right. I keep forgetting about compile all. Thanks.
Brass Lantern Prop Competition


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

Page created in 0.069 seconds with 22 queries.