Author Topic: changing states, always a joy  (Read 12483 times)

0 Members and 1 Guest are viewing this topic.

Offline robingravel

Re:changing states, always a joy
« Reply #15 on: November 07, 2003, 04:58:22 PM »
I mighty not understand to your question.

Do you wish to see to run the instance script when the game begins?

Robin Gravel

Offline robingravel

Re:changing states, always a joy
« Reply #16 on: November 07, 2003, 08:11:36 PM »
Hi cloudee1

I checked your game again.

I changed (RoomScript:changeState(20)) to (RoomScript:changeState(1)) in (if(== GARY_P 1) section.

(RoomScript:changeState(1)) works but not (RoomScript:changeState(20))

I suspect the template has a bug or sci studio itself.

Also I removed JelLy:changeState and keep RoomScript:changeState
alone. It should work this way.

(case 16
...
)
(case 20
...
)
...


Robin Gravel



Note: I lost the messageboard a few minutes ago.
« Last Edit: November 07, 2003, 08:59:27 PM by Robin_Gravel »

Offline Brian Provinciano

Re:changing states, always a joy
« Reply #17 on: November 08, 2003, 02:06:23 AM »
No, there are no bugs in it. I will explain fully why both your codes are not working.


cloudee:

You have:

    (if(TALK_TO(FALSE))
     =cycles 1
     = state 100
    )(else
     return()
    )

that compiles to this:

    (if(
        TALK_TO
        FALSE
      )

the TALK_TO is ignored because it is followed by another expression. Which in turn, executes simply as:

     (if( FALSE )

Therefore, it will always execute the "return" and never execute the "= cycles". Second, the "= state 100" will not give you the desired results either. You should not actually be touching the state property there. To change states, you call the changeState(newState) method.


The changeState method is executed. So, for example, if you call changeState(0), it will execute state #0 because of this:

(switch(= state newState)
   (case 0
      = cycles 10
   )
   (case 1
     = seconds 20
   )
   (case 2
      // do nothing
   )
   (case 3
     = cycles 10
   )

Cycle #0 will be executed, then 10 cycles later, cycle #1 will be executed, then 20 seconds later, cycle #2 will be executed. Since cycle #2 doesn't set the seconds or cycle property, the changeState loop will stop. cycle #3 will not be executed.

Now take for instance this:
(switch(= state newState)
   (case 0
      = cycles 10
   )
   (case 1
     = seconds 20
   )
   (case 3
     = cycles 10
   )

It is EXACTLY the same thing. It executes cycle#0, then cycle#1, there's no cycle#2, so when it executes cycle#2, there's nothing to set the seconds or cycles properties, and thus, the changeState loop will halt execution.

Separating case#16 and #20 has no advantage to using case #16 and case #17, provided that case #16 doesn't set the cycles or seconds property, it will not continue to #17. Also, it's possible to execute the changeState from the middle of a normal case array.

Offline robingravel

Re:changing states, always a joy
« Reply #18 on: November 08, 2003, 08:19:57 AM »
Hi Brian

I understand to your examples but.

What does(RoomScript:changeState(20)) not work but (RoomScript:changeState(1)) does?

Here cloudee1's code:

(if(== GARY_P 1)
  (RoomScript:changeState(20))
   = cycles 1
)

This code does not work but


(if(== GARY_P 1)
  (RoomScript:changeState(1))
   = cycles 1
)

This code works.


Here the case 20

   (case 20
    ProgramControl()
    (send gEgo:hide())(garyMan:hide())
(talkingFrame1:init()setCycle(Fwd)setPri(16))(talkingFrame2:init()setCycle(Fwd) setPri(16))
    (talkingBob1:init()setPri(13))(talkingGary2:init()setPri(13))
    (bobMouth:init()loop(2)setPri(14))(garyMouth:init()loop(1)setPri(14))
    (bobEyes:init()loop(1)setPri(14)setCycle(End))(garyEyes:init()loop(2)setPri(14))
    = cycles 10
   )


Robin Gravel

Offline Brian Provinciano

Re:changing states, always a joy
« Reply #19 on: November 09, 2003, 05:51:14 AM »
  (RoomScript:changeState(1))
worked, but
  (RoomScript:changeState(20))
did not because in both scripts cloudee posted, the "RoomScript" instance did not have a "case 20". There was a "case 20" in a Jelly instance, but calling "RoomScript:changeState" does nothing for "Jelly". For that you would need to call "Jelly:changeState".

Offline robingravel

Re:changing states, always a joy
« Reply #20 on: November 09, 2003, 08:50:27 AM »
Brian.

When I changed (Jelly:changeState(20)) to (RoomScript:changeState(20)) I removed Jelly instance as well.

Here the script:


Robin Gravel

Offline humanity

Re:changing states, always a joy
« Reply #21 on: November 27, 2003, 12:08:23 AM »
I've been fighting this same thing myself. You probably figured this out before I did, but method doit seems to interrupt the changestate process, so that the first case will run, but not others. When I removed the method doit code, the changestate process incremented as expected. Hope this helps.

Offline Brian Provinciano

Re:changing states, always a joy
« Reply #22 on: November 27, 2003, 07:21:52 AM »
The whole changeState engine is built within the scripts. If you want to understand how they work, when doit()s are executed, when they are executed, etc. look through the scripts.

I can assure you all there are no bugs with the changeStates, you are just not using them correctly. They were used in ALL sierra SCI games all the way through Leisure Suit Larry 1VGA,2,3,5,6,7, King's Quest, 1SCI,4,5,6,7, Space Quest, 1VGA,3,4,5,6, and all the others! Even Police Quest SWAT! The class system in the template game runs IDENTICAL to Leisure Suit Larry 3's as that is what it was based upon. In fact, it runs Leisure Suit Larry 3's rooms perfectly.

I have multiple explanations on how they work, including my EXTENSIVE help file, tutorial, and other random docs all over the place. Anyone who says SCI Studio lacks documentation (I'm looking at you Robin ::)) Hasn't given it much of a look. The help file documents the whole class system, all 29 scripts, 63 classes, all the methods in the classes, all the procedures, the 114 kernel functions, every syntax in SCI code, and along with the tutorial, every aspect needed to make a game with SCI Studio. If you want to know more about SCI, there is also the extensive FreeSCI documentation, and of course, the complete source codes to SCI Studio, FreeSCI, and all of their other tools.

Offline robingravel

Re:changing states, always a joy
« Reply #23 on: November 27, 2003, 10:29:50 AM »
Hi Brian

Quote
Anyone who says SCI Studio lacks documentation (I'm looking at you Robin ) Hasn't given it much of a look

I READ THAT!!!

Seriously, I'm still having problem to follow your help file.
And the Print command is not in the help file.

I can explain furter why I have problem with help file but this will be off-topic.

Also in chapter 24 in the tutorial with Printing With Buttons.

The newbie will have some problems with this code found in the tutorial:
Quote
(var button)
= button Print(
  "Do you want to click Yes or No?"
  #title "Click What?"
  #font LARGE_FONT
  #icon 0 0 0
  #button " Yes " 1
  #button " No " 0
)
(if(== button 1)
  Print("You clicked YES")
)(else
  Print("You clicked NO")
)

This is the correct code:
Quote
(instance RoomScript of Script
 (properties)
 (method (handleEvent pEvent)
  (var button)
  (super:handleEvent(pEvent))

  /*****************************************
    * Handle the possible said phrases here *
    *****************************************/
  (if(Said('look'))
   = button Print(
    "Do you want to click Yes or No?"
    #title "Click What?"
    #font LARGE_FONT
    #icon 0 0 0
    #button " Yes " 1
    #button " No " 0
   )
   (if(== button 1)
    Print("You clicked YES")
   )(else
    Print("You clicked NO")
   )
  )
 )
)


Robin Gravel


« Last Edit: November 27, 2003, 10:37:10 AM by Robin_Gravel »

Offline Brian Provinciano

Re:changing states, always a joy
« Reply #24 on: November 27, 2003, 11:38:25 PM »
Hi Brian

Quote
Anyone who says SCI Studio lacks documentation (I'm looking at you Robin ) Hasn't given it much of a look

I READ THAT!!!

Seriously, I'm still having problem to follow your help file.
And the Print command is not in the help file.

I can explain furter why I have problem with help file but this will be off-topic.

Also in chapter 24 in the tutorial with Printing With Buttons.

The newbie will have some problems with this code found in the tutorial:
Quote
(var button)
= button Print(
  "Do you want to click Yes or No?"
  #title "Click What?"
  #font LARGE_FONT
  #icon 0 0 0
  #button " Yes " 1
  #button " No " 0
)
(if(== button 1)
  Print("You clicked YES")
)(else
  Print("You clicked NO")
)

This is the correct code:
Quote
(instance RoomScript of Script
 (properties)
 (method (handleEvent pEvent)
  (var button)
  (super:handleEvent(pEvent))

  /*****************************************
    * Handle the possible said phrases here *
    *****************************************/
  (if(Said('look'))
   = button Print(
    "Do you want to click Yes or No?"
    #title "Click What?"
    #font LARGE_FONT
    #icon 0 0 0
    #button " Yes " 1
    #button " No " 0
   )
   (if(== button 1)
    Print("You clicked YES")
   )(else
    Print("You clicked NO")
   )
  )
 )
)


Robin Gravel




Haha! Don't take it so personal. If I didn't want you to see that, I wouldn't have posted it.

First, the help file is not needed in the beginning. The tutorial is what a newbie must do first, then the help file is for _additional_ information. I didn't bother putting most of the stuff in the tutorial in the help file, because that would just be copy/pasting duplicate information. It's ALL covered by the tutorial and help file TOGETHER.

Second, my code IS correct, and yours is not entirely. Anyone who has done the entire tutorial up to chapter 24 would know that (var) declarations must be at the top of the procedure/method. If they've just been copying/pasting code from the tutorial directly, they won't learn anything. I'm not going to put EXTRA, unnecessary code in the examples. It would just make them less flexible and more confusing. The example does not need to be in handleEvent(), nor in an if(Said()) statement. It could be pasted exactly as it is into an init(), for example.

I was simply responding to your comment with the facts. It's nothing personal. Cool down.

Offline robingravel

Re:changing states, always a joy
« Reply #25 on: November 28, 2003, 09:16:57 AM »
O.K Brian.

If I'm still having problem with the help file I'll let you to know with a new thread.


Robin Gravel


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

Page created in 0.037 seconds with 22 queries.