Author Topic: ChangeState, apparantly I am missing something here.  (Read 5811 times)

0 Members and 1 Guest are viewing this topic.

Offline Cloudee1

ChangeState, apparantly I am missing something here.
« on: November 02, 2013, 11:18:37 PM »
Ok, I honestly can't see what it is that I am doing wrong here. For some reason, I can't get to state 2 in the code below. Case 0 and 1 run perfectly, but it just will not progress on to state 2

Code: [Select]
(instance fillingCup of Script
(properties)
  (method (changeState newState)
  = state newState
    (switch (state)
      (case 0 ProgramControl()
            (send gEgo:setCycle(Walk)setMotion(MoveTo 165 132 fillingCup))
            )
      (case 1 (send gEgo:loop(3)cel(0))
            (emptyCup:cel(4))
            (pouringSoda:posn(141 105))
            = seconds 5
          )
  (case 2 Print("A cup that large may take a long time to fill")
            = seconds 7
            )

I can't get seconds or cycles to work for whatever reason, but if I replace the line with a moveTo that triggers the next state, it progresses just fine.

Code: [Select]
(youdontwannaknow:setMotion(MoveTo 700 96 fillingCup)) // used as a timer

I have the bit in the features script commented out that lets me place and move actors off screen. And I am using my usual set of "use" scripts

Code: [Select]
(use "main")(use "controls")(use "cycle")(use "game")(use "feature")(use "obj")
« Last Edit: November 02, 2013, 11:59:23 PM by Cloudee1 »


Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline gumby

Re: ChangeState, apparantly I am missing something here.
« Reply #1 on: November 03, 2013, 09:08:48 AM »
That looks like it should work.  Is there maybe an issue with ProgramControl()?  Did you modify it based on this discussion: http://sciprogramming.com/community/index.php/topic,660.0.html
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: ChangeState, apparantly I am missing something here.
« Reply #2 on: November 03, 2013, 10:35:23 AM »
Perhaps you didn't use setScript(fillingCup) when you initialized your Props and Acts?

Offline Cloudee1

Re: ChangeState, apparantly I am missing something here.
« Reply #3 on: November 03, 2013, 04:39:49 PM »
Doan, I didn't use setScript at init, but instead set it when the user clicks on the soda machine. At which time it does state 0 and state 1, just it stops there with cycles or seconds set.

Code: [Select]
(case 995 (send pEvent:type(evMOUSEBUTTON) claimed(TRUE))//  get
               //(if(... close enough
                (if(not(puSoda))
                (sodaMachine:setScript(fillingCup))
  )
  (else
                Print(25 6)
                )
               //)
               //(else
               // Print("You are not close enough to operate the machine")
               //)
  )

Gumby, I do have the ProgramControl and PlayerControl modified, and it has been in the pnc template for a while now.

Code: [Select]
(procedure public (ProgramControl)
(User:canControl(FALSE)canInput(FALSE))
(send gEgo:setMotion(NULL))
= gProgramControl TRUE
= canTab FALSE
)
(procedure public (PlayerControl)
(User:canControl(TRUE)canInput(FALSE))
(send gEgo:setMotion(NULL))
= gProgramControl FALSE
= canTab TRUE
)

I guess, what really bugs me about this is that, using an actors moveto to trigger the next step works. Why is it that it can find case 2 and beyond that way but not with the seconds or cycles. Even worse, this problem seems to be specific to this room. In another room, I've got a changestate set up using seconds that works just fine.

Code: [Select]
(instance passerBy of Act(properties x -10 y 133 view 504 loop 0))

(instance passingBy of Script
(properties)
  (method (changeState newState)
  = state newState
    (switch (state)
      (case 0  = whichWalker Random(504 505)
             (passerBy:view(whichWalker))
             = seconds Random(4 12)
               )
      (case 1  (passerBy:setCycle(Walk) setMotion(MoveTo 330 133 passingBy)))
      (case 2 = whichWalker Random(504 505)
             (passerBy:view(whichWalker))
             = seconds Random(8 16)
               )
      (case 3 (passerBy:setCycle(Walk) setMotion(MoveTo -10 133 passingBy)))
      (case 4 (self:changeState(0)))
    ) // switch end
  ) // method end
) // instance end
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition


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

Page created in 0.052 seconds with 22 queries.