Community

SCI Programming => Mega Tokyo SCI Archive => Topic started by: Robert Eric on March 15, 2004, 07:14:53 AM

Title: New instance to run event cases
Post by: Robert Eric on March 15, 2004, 07:14:53 AM
I've been trying to use an instance of Script to run my cases instead of RoomScript, to keep things in order.  I have:

In RoomScript

(if(== (send gEgo:onControl()) ctlGREEN)
  (if(Said('talk'))
    (send gEgo:setMotion(MoveTo 50 50 moveScript))
  )
)

In it's own instance

(instance moveScript of Script
    (properties)
    (method (changeState newState)
        = state newState
        (switch (state)
            (case 0
                Print("He moved.")
                = cycles 10
            )
            (case 1
                Print("He's still there.")
                = cycles 10
            )
            (case 2
                Print("The view has moved to it's first position!")
                = cycles 10
            )
        )
    )
)

When I'm on the green control, and I type "talk", he walks to 50,50, but then nothing happens.  Any ideas?
Title: Re:New instance to run event cases
Post by: Eigen on March 15, 2004, 07:45:06 AM
The code works here...

Are you sure it reaches 50 50? Maybe there's something blocking the way.



-Eigen
Title: Re:New instance to run event cases
Post by: Cloudee1 on March 15, 2004, 09:01:56 AM
You are trying to get it to do all cases in one pass aren't you?  It seems to be a bit of a debate about this type of thing in other posts but what I have become convinced of is that the Roomscripts changestate is the only place that works, these other instances only seem to be good for one case actions, or to illustrate how your script worked in my test game:

first time talk, dude treked over and said "he moved"
... then nothing
wander around talk again and this time he goes and reports "he's moving"
...  then nothing
roam some and talk again and away he goes again "reached his position"

I assume that isn't the desiredresponse however?



Title: Re:New instance to run event cases
Post by: Robert Eric on March 15, 2004, 04:02:12 PM
I thought it was supposed to run the next case no matter if you have an actor move, animate, have a sound play, Print(), or Display() something?  I have those Print() functions to test that theory.  It works in the RoomScript instance, but if it can't do the same in a seperate Script instance, then that really bytes.  I mean, bites.

Edit: Actually, I put it in RoomScript, but it didn't work.  He moved to 50, 50, then stopped, and nothing happened.
Title: Re:New instance to run event cases
Post by: Cloudee1 on March 16, 2004, 01:06:08 PM
Hey Rob Bob,
 When I stick this in roomscript, it works. With just this, upon room start it prints the statements.
Code: [Select]
(instance RoomScript of Script(properties)
 (method (changeState newState)
 = state newState
  (switch (state)
   (case 0
   Print("He moved.")
   = cycles 10
   )
   (case 1
   Print("He's Moving.")
   = cycles 10
   )
   (case 2
   Print("The view has moved to it's first position!")
   = cycles 10
   )
  )
 )
 (method (handleEvent pEvent)

now just add a local variable and check against it as to whether to start this or not and you should be fine
Title: Re:New instance to run event cases
Post by: Robert Eric on March 16, 2004, 04:01:08 PM
It DOES work, but I was hoping to be able to use it in it's own instance.  I guess this will do for now, until I can figure it out on my own.  Thanks cloudee.
Title: Re:New instance to run event cases
Post by: Cloudee1 on March 17, 2004, 09:42:57 AM
me too, but I couldn't ever get mine to work  ::)