Community

SCI Programming => SCI Syntax Help => Topic started by: MusicallyInspired on June 06, 2007, 02:04:39 PM

Title: Bit of help with 3 Things
Post by: MusicallyInspired on June 06, 2007, 02:04:39 PM
I've searched the tutorials and the SCI Studio help file and I'm still not getting answers for these three things I want to accomplish. Help is appreciated.

First: I'm looking to hide the cursour until a certain case.

Second: I want to change what pressing the enter button does (skipping the intro screen) to skipping ahead to the next case and learn how to change what the enter button does generally. Also how to prevent any other key from doing anything at all.

Third: I want to make a selector for buttons a la KQ1SCI's title menu and cause either a mouse click or using the arrow keys and pressing enter to select and activate each button.

Many thanks.
Title: Re: Bit of help with 3 Things
Post by: troflip on June 06, 2007, 02:32:26 PM
I have a feeling there is a way to hide the cursor, since I think I've done it before.... I'll have to check.  But one thing you could do is just set the cursor to be a blank cursor.  For completeness you'd want to ignore all mouse events too, so a user randomly clicking the mouse doesn't click on something.

For intercepting keyboard events, look here (http://scicommunity.com/sciforums/index.php?topic=69.0).

Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 06, 2007, 04:40:25 PM
Thanks. I've made a lot of headway here. Just a simple question. Is it possible that I can have a keystroke in my handleEvent method skip ahead to the next case in my changeState method rather than it taking so many cycles to get there normally? Or can it be done that way? Basically I just want the intro to be able to go to the next changestate case either after a certain amount of cycles or when the player press a button. And after that enable the menu selector on the buttons.
Title: Re: Bit of help with 3 Things
Post by: lskovlun on June 06, 2007, 04:43:46 PM
I have a feeling there is a way to hide the cursor, since I think I've done it before....
SetCursor(0 0) is your friend (the second parameter is the on/off toggle).
(edited):
Damn, two edits in one evening. You want the setCursor method on your game object. That way, the setting will be remembered across save/restore (this is the same difference we had with DrawPic versus drawPic the other day).
Title: Re: Bit of help with 3 Things
Post by: lskovlun on June 06, 2007, 04:45:48 PM
Is it possible that I can have a keystroke in my handleEvent method skip ahead to the next case in my changeState method rather than it taking so many cycles to get there normally?
Code: [Select]
(yourScript:cue())
But be aware that if you have started a character moving, he won't automatically move to his desination. To be absolutely sure, you have to position the character manually in the next case. Other asynchronous actions have the same problem.
Title: Re: Bit of help with 3 Things
Post by: Doan Sephim on June 06, 2007, 05:03:02 PM
Third: I want to make a selector for buttons a la KQ1SCI's title menu and cause either a mouse click or using the arrow keys and pressing enter to select and activate each button.

Here is the Script from my title screen: it has the ability to select "new game", "restore", "play demo" and "quit" based on mouse clicks or selecting with the arrow keys and enter. I hope this is what you're looking for.
Code: [Select]

(include "sci.sh")
(include "game.sh")

(script TITLESCREEN_SCRIPT)

(use "main")
(use "game")
(use "menubar")
(use "obj")
(use "cycle")
(use "user")
(use "controls")
(use "feature")

//Variables to determine what the "selector" View is highlighting
(local
   sNewGame = 1 // default selector on New Game
   sRestore = 0
   sPlayDemo = 0
   sQuitGame = 0
)

(instance public TitleScreen of Rm
(properties picture scriptNumber)
(method (init)
        // Set up the title screen
ProgramControl()
= gProgramControl FALSE
(send gGame:setSpeed(3))
(SL:disable())
(TheMenuBar:hide())

(super:init())
(self:setScript(RoomScript))

(send gEgo:init()hide())

        Display(
"Copyright < 2007"
dsCOORD 150 177
dsCOLOUR 1 // dark blue
dsBACKGROUND clTRANSPARENT
)
        (profile:init()loop(1))
        (games:init()setCycle(Fwd)cycleSpeed(2))
        (newGame:init())
        (restore:init()loop(1))
        (quitGame:init()loop(2))
        (playDemo:init()loop(3))
        (selector:init()loop(4))

        )
)

(instance RoomScript of Script
(properties)
    (method (changeState newState)
        = state newState
        (switch(state)
            (case 0 = cycles 40
            )(case 1 = cycles 40
                Display(
                    "Presents:"
                    dsCOORD 110 70
                    dsCOLOUR clBLUE
                    dsBACKGROUND clTRANSPARENT
                )
            )(case 2 = cycles 7
                (line:init()setCycle(End))
            )(case 3 = cycles 10
                (line:loop(1)posn(208 140)cel(0)setCycle(End)cycleSpeed(1))

            )(case 4 = cycles 15
                (BA:init()loop(1))
            )
        )

    )
(method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if(==(send pEvent:type) evJOYSTICK)
            (if(==(send pEvent:message) 1)  // UP
                (selectorCheckUp)
            )
        )
        (if(==(send pEvent:type) evJOYSTICK)
            (if(==(send pEvent:message) 5)  // Down
                (selectorCheckDown)
            )
        )
        (if (==(send pEvent:type)evKEYBOARD)
            (if(==(send pEvent:message)KEY_RETURN)
                (if(sNewGame)
                    (send gRoom:newRoom(INITROOMS_SCRIPT))
                )(else
                    (if(sRestore)
                        (send gGame:restore())
                    )(else
                        (if(sPlayDemo)
                            = gDemo 1
                            (send gRoom:newRoom(INITROOMS_SCRIPT))
                        )(else
                            (if(sQuitGame)
                                = gQuitGame 1
                            )
                        )
                    )
                )
            )
        )
        (if(==(send pEvent:type())evMOUSEBUTTON)
            (if((> (send pEvent:x) (newGame:nsLeft))and
                (< (send pEvent:x) (newGame:nsRight))and
                (> (send pEvent:y) (newGame:nsTop))and
                (< (send pEvent:y) (newGame:nsBottom)))
                (if(sNewGame)
                    (send gRoom:newRoom(INITROOMS_SCRIPT))
                )(else
                    (selectorZero)
                    = sNewGame 1
                    (selector:posn(44 61))
                    (send pEvent:claimed(TRUE))
                )
            )(else
                (if((> (send pEvent:x) (restore:nsLeft))and
                    (< (send pEvent:x) (restore:nsRight))and
                    (> (send pEvent:y) (restore:nsTop))and
                    (< (send pEvent:y) (restore:nsBottom)))
                    (if(sRestore)
                        (send gGame:restore())
                    )(else
                        (selectorZero)
                        = sRestore 1
                        (selector:posn(44 94))
                        (send pEvent:claimed(TRUE))
                    )
                )(else
                    (if((> (send pEvent:x) (playDemo:nsLeft))and
                        (< (send pEvent:x) (playDemo:nsRight))and
                        (> (send pEvent:y) (playDemo:nsTop))and
                        (< (send pEvent:y) (playDemo:nsBottom)))
                        (if(sPlayDemo)
                            = gDemo 1
                            (send gRoom:newRoom(INITROOMS_SCRIPT))
                        )(else
                            (selectorZero)
                            = sPlayDemo 1
                            (selector:posn(44 127))
                            (send pEvent:claimed(TRUE))
                        )
                    )(else
                        (if((> (send pEvent:x) (quitGame:nsLeft))and
                            (< (send pEvent:x) (quitGame:nsRight))and
                            (> (send pEvent:y) (quitGame:nsTop))and
                            (< (send pEvent:y) (quitGame:nsBottom)))
                            (if(sQuitGame)
                                = gQuitGame 1
                            )(else
                                (selectorZero)
                                = sQuitGame 1
                                (selector:posn(44 160))
                                (send pEvent:claimed(TRUE))
                            )
                        )
                    )
                )
    )
)
)//end method
)
//Procedures for the Title Menu
(procedure (selectorCheckUp)
    (if(sNewGame)
        (selectorZero)
        = sQuitGame 1
        (selector:posn(44 160))
    )(else
        (if(sRestore)
            (selectorZero)
            = sNewGame 1
            (selector:posn(44 61))
        )(else
            (if(sPlayDemo)
                (selectorZero)
                = sRestore 1
                (selector:posn(44 94))
            )(else
                (if(sQuitGame)
                    (selectorZero)
                    =sPlayDemo 1
                    (selector:posn(44 127))
                )
            )
        )
    )
)

(procedure (selectorCheckDown)
    (if(sNewGame)
        (selectorZero)
        = sRestore 1
        (selector:posn(44 94))
    )(else
        (if(sRestore)
            (selectorZero)
            = sPlayDemo 1
            (selector:posn(44 127))
        )(else
            (if(sPlayDemo)
                (selectorZero)
                = sQuitGame 1
                (selector:posn(44 160))
            )(else
                (if(sQuitGame)
                    (selectorZero)
                    = sNewGame 1
                    (selector:posn(44 61))
                )
            )
        )
    )
)

(procedure (selectorZero)
= sNewGame 0
= sRestore 0
= sPlayDemo 0
= sQuitGame 0
)

(instance BA of Prop
    (properties
        y 128
        x 206
        view 995
    )
)
(instance games of Prop
    (properties
        y 50
        x 210
        view 999
    )
)
(instance profile of Prop
    (properties
        y 35
        x 180
        view 999
    )
)
(instance newGame of Prop
    (properties
        y 57
        x 44
        view 998
    )
)
(instance restore of Prop
    (properties
        y 90
        x 44
        view 998
    )
)
(instance playDemo of Prop
    (properties
        y 123
        x 44
        view 998
    )
)
(instance quitGame of Prop
    (properties
        y 156
        x 44
        view 998
    )
)
(instance selector of Prop
    (properties
        y 61
        x 44
        view 998
    )
)
(instance line of Prop
    (properties
        y 112
        x 208
        view 997
    )
)
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 06, 2007, 10:27:06 PM
SetCursor(0 0) is your friend (the second parameter is the on/off toggle).
That doesn't work.

Quote
(yourScript:cue())

But be aware that if you have started a character moving, he won't automatically move to his desination. To be absolutely sure, you have to position the character manually in the next case. Other asynchronous actions have the same problem.

Can you elaborate on that please? How exactly do I implement that? I'm not a programmer I need examples or I don't get it. And my character isn't going to be on the screen. This is for the title.
Title: Re: Bit of help with 3 Things
Post by: troflip on June 06, 2007, 11:00:29 PM
SetCursor(0 0) is your friend (the second parameter is the on/off toggle).
That doesn't work.

It works, but the template game keeps turning the cursor back on at the beginning of every new room.  So that may be what you're seeing.  e.g. I tried putting SetCursor(997 0) in my room's init method, and it didn't work, because it turns it right back on here in the newRoom method in Game:
Code: [Select]
(self:
startRoom(gRoomNumberExit)
checkAni()
setCursor(oldCursor HaveMouse())
)


To make it work, I made a changeState method like this, so after one game cycle in my room, it turns the cursor back off:
Code: [Select]
(method (changeState newState)
  (= state newState)
  (switch (newState)
  (case 0
  (= cycles 1)
)
(case 1
(send gGame:setCursor(997 0))
)
)
)

A bit of a hack.  A more elegant solution would involve mucking around with the game template and having a global variable that represents the on/off state maybe...
But anyway, let me know if you find something that works.
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 07, 2007, 02:03:52 PM
Nice! That fixed my cursour issue! Thank you.

Also many thanks for that menu script that really helps! If I have any more questions I'll let you know.

Could I also get some further help with skipping ahead to the next case? Specifically if this is the code to use:
Code: [Select]
(yourScript:cue())How then do I actually use it and where do I put it, etc? What I'm trying to do is make the enter button or a mouse click event either skip ahead to the next (or a certain) case or if it's already at that case (I've already created a "sMenu" variable for this) then act normally in my menu (if it's on Intro button then skip to intro, if it's on Begin game then go to first room, etc).

For example. This is part of my current handleEvent code. I'm not sure what to put in the "else" part:

Code: [Select]
(if (==(send pEvent:type)evKEYBOARD)
            (if(==(send pEvent:message)KEY_RETURN)
                (if(sMenu)
                (if(sBegin)
                    (send gRoom:newRoom(INITROOMS_SCRIPT))
                )(else
                    (if(sCont)
                        (send gGame:restore())
                    )(else
                        (if(sIntro)
                            = gIntro 1
                            (send gRoom:newRoom(INITROOMS_SCRIPT))
                        )(else
                            (if(sCred)
                                = gCred 1   
                                (send gRoom:newRoom(INITROOMS_SCRIPT))
                            )
                        )
                    )
    )
)
            )
            (else
           
            )
           
)
Title: Re: Bit of help with 3 Things
Post by: Doan Sephim on June 07, 2007, 02:30:46 PM
Put this in the else part:

(RoomScript:cue()) // this will send the state to the next one
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 07, 2007, 04:10:57 PM
I have a handful of problems (including that RoomScript:cue code not working), but I'll start with one.

When I try to compile the script it says that selectorZero needs to have a "(" immediately after it but I notice you don't have it that way in your script there. Any ideas?
Title: Re: Bit of help with 3 Things
Post by: Doan Sephim on June 07, 2007, 04:12:26 PM
can you email me (or post, or PM) your script? That would help me alot to be able to pinpoint any potential problems.
doansephim@yahoo.com
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 07, 2007, 04:25:43 PM
I'm just playing with it a little here. I'll make some finishing changes and then post it here momentarily.
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 07, 2007, 05:10:38 PM
Ok here you go:

I also can't understand how keyboard arrow movements will move around the menu selector as well as the mouse if there's no keyboard intercepts for it.

Code: [Select]
/******************************************************************************
 SCI Template Game
 By Brian Provinciano
 ******************************************************************************
 titlescreen.sc
 Contains the title screen room.
 ******************************************************************************/
(include "sci.sh")
(include "game.sh")
(include "keys.sh")
/******************************************************************************/
(script TITLESCREEN_SCRIPT)
/******************************************************************************/
(use "main")
(use "game")
(use "menubar")
(use "obj")
(use "cycle")
(use "user")
(use "controls")
(use "feature")

(local
title1 = 0
title2 = 0
sIntro = 1
sBegin = 0
sCred = 0
sCont = 0
sMenuStart = 0
)
/******************************************************************************/
(instance public TitleScreen of Rm
(properties
picture scriptNumber
)
(method (init)
        // Set up the title screen
ProgramControl()
= gProgramControl FALSE
(send gGame:setSpeed(1))
(SL:disable())
(TheMenuBar:hide())

(super:init())
(self:setScript(RoomScript))

(send gEgo:
init()
hide()
)
 
        /****************************************
         * Set up the room's music to play here *
         ****************************************/
(send gTheMusic:
prevSignal(0)
stop()
number(1)
loop(-1)
play()
)

        /**************************************************
         * Add the rest of your initialization stuff here *
         **************************************************/

)
)
/******************************************************************************/
(instance RoomScript of Script
(properties)     

(method (changeState newState)
  = state newState
  (switch(state)
    (case 0
    (= cycles 1)
)
    (case 1
        (send gGame:setCursor(997 0))
        (theRomance:
        init()
  )
  (theThrone:
  init()
  )
  = title1 Display( "SCI Pre-Alpha Version 1.0" // 800 is the text resource number and 0 is the line
                    dsCOORD 98 170
                    dsCOLOUR clMAROON
                    dsBACKGROUND clTRANSPARENT
                    dsFONT 4
                    dsSAVEPIXELS
          )
          = title2 Display( "By: Brandon Blume"
dsFONT 4
            dsCOORD 115 180
dsCOLOUR clMAROON
dsBACKGROUND clTRANSPARENT
dsSAVEPIXELS
      )  
          (theSpark1:
          init()
          setCycle(Fwd)
  )
          (theSpark2:
          init()
          setCycle(Fwd)
  )
  (theSpark3:
          init()
          setCycle(Fwd)
  )
  (theSpark4:
          init()
          setCycle(Fwd)
  )
  (theSpark5:
          init()
          setCycle(Fwd)
  )
  (theSpark6:
          init()
          setCycle(Fwd)
  )
  (theSpark7:
          init()
          setCycle(Fwd)
  )
  (theSpark8:
          init()
          setCycle(Fwd)
  )
          = seconds 10
    )
    (case 2
        (theRomance:
        dispose()
  )
        (theThrone:
        dispose()
  )
  = title1 Display( "" dsRESTOREPIXELS title1)
  = title2 Display( "" dsRESTOREPIXELS title2)  
  = seconds 2
    )
    (case 3
        (send gGame:setCursor(999 1))
        = sMenuStart 1
        (buttonIntro:
        init()
        loop(1)
  )
  (buttonBegin:
  init()
  loop(2)
  )
  (buttonCred:
  init()
  loop(3)
  )
  (buttonCont:
  init()
  loop(4)
  )
  (buttonSelect:
  init()
  loop(5)
  )
    )
    )
)



   
(method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if (sMenuStart)
        (if (==(send pEvent:type)evKEYBOARD)
            (if(==(send pEvent:message)KEY_RETURN)
            (if(sBegin)
                    (send gTheMusic:fade())
                    (send gRoom:newRoom(INITROOMS_SCRIPT))
                )(else
                    (if(sCont)
                        (send gGame:restore())
                    )(else
                        (if(sIntro)
                            = gIntro 1
                            (send gTheMusic:fade())
                            (send gRoom:newRoom(INITROOMS_SCRIPT))
                        )(else
                            (if(sCred)
                                = gCred 1   
                                (send gTheMusic:fade())
                                (send gRoom:newRoom(INITROOMS_SCRIPT))
                            )
                        )
                    )
)
)
)
)(else
(RoomScript:cue())
)
(if(==(send pEvent:type())evMOUSEBUTTON)
            (if((> (send pEvent:x) (buttonBegin:nsLeft))and
                (< (send pEvent:x) (buttonBegin:nsRight))and
                (> (send pEvent:y) (buttonBegin:nsTop))and
                (< (send pEvent:y) (buttonBegin:nsBottom)))
                (if(sBegin)
                    (send gTheMusic:fade())
                    (send gRoom:newRoom(INITROOMS_SCRIPT))
                )(else
                    (selectorZero())
                    = sBegin 1
                    (send pEvent:claimed(TRUE))
                )
            )(else
                (if((> (send pEvent:x) (buttonCont:nsLeft))and
                    (< (send pEvent:x) (buttonCont:nsRight))and
                    (> (send pEvent:y) (buttonCont:nsTop))and
                    (< (send pEvent:y) (buttonCont:nsBottom)))
                    (if(sCont)
                        (send gTheMusic:fade())
                        (send gGame:restore())
                    )(else
                        (selectorZero())
                        = sCont 1
                        (send pEvent:claimed(TRUE))
                    )
                )(else
                    (if((> (send pEvent:x) (buttonCred:nsLeft))and
                        (< (send pEvent:x) (buttonCred:nsRight))and
                        (> (send pEvent:y) (buttonCred:nsTop))and
                        (< (send pEvent:y) (buttonCred:nsBottom)))
                        (if(sCred)
                            = gCred 1
                            (send gTheMusic:fade())
                            (send gRoom:newRoom(INITROOMS_SCRIPT))
                        )(else
                            (selectorZero())
                            = sCred 1
                            (send pEvent:claimed(TRUE))
                        )
                    )(else
                        (if((> (send pEvent:x) (buttonIntro:nsLeft))and
                            (< (send pEvent:x) (buttonIntro:nsRight))and
                            (> (send pEvent:y) (buttonIntro:nsTop))and
                            (< (send pEvent:y) (buttonIntro:nsBottom)))
                            (if(sIntro)
                                = gIntro 1
                                (send gTheMusic:fade())
                                (send gRoom:newRoom(INITROOMS_SCRIPT))
                            )(else
                                (selectorZero())
                                = sIntro 1
                                (send pEvent:claimed(TRUE))
)
)
)
)
)

)(else
(RoomScript:cue())
)
)
)
/******************************************************************************/
(procedure (selectorCheckUp)
    (if(sBegin)
        (selectorZero)
        = sCred 1
        (buttonSelect:posn(58 165))
    )(else
        (if(sCont)
            (selectorZero)
            = sBegin 1
            (buttonSelect:posn(161 146))
        )(else
            (if(sCred)
                (selectorZero)
                = sIntro 1
                (buttonSelect:posn(58 146))
            )(else
                (if(sIntro)
                    (selectorZero)
                    =sCont 1
                    (buttonSelect:posn(161 165))
                )
            )
        )
    )
)
(procedure (selectorCheckDown)
    (if(sBegin)
        (selectorZero)
        = sCont 1
        (buttonSelect:posn(161 165))
    )(else
        (if(sCont)
            (selectorZero)
            = sIntro 1
            (buttonSelect:posn(58 146))
        )(else
            (if(sCred)
                (selectorZero)
                = sBegin 1
                (buttonSelect:posn(161 146))
            )(else
                (if(sIntro)
                    (selectorZero)
                    = sCred 1
                    (buttonSelect:posn(58 165))
                )
            )
        )
    )
)
(procedure (selectorCheckLeft)
    (if(sBegin)
        (selectorZero)
        = sIntro 1
        (buttonSelect:posn(58 146))
    )(else
        (if(sCont)
            (selectorZero)
            = sCred 1
            (buttonSelect:posn(58 165))
        )(else
            (if(sCred)
                (selectorZero)
                = sBegin 1
                (buttonSelect:posn(161 146))
            )(else
                (if(sIntro)
                    (selectorZero)
                    = sCont 1
                    (buttonSelect:posn(161 165))
                )
            )
        )
    )
)
(procedure (selectorCheckRight)
    (if(sBegin)
        (selectorZero)
        = sCred 1
        (buttonSelect:posn(58 165))
    )(else
        (if(sCont)
            (selectorZero)
            = sIntro 1
            (buttonSelect:posn(58 146))
        )(else
            (if(sCred)
                (selectorZero)
                = sCont 1
                (buttonSelect:posn(161 165))
            )(else
                (if(sIntro)
                    (selectorZero)
                    = sBegin 1
                    (buttonSelect:posn(161 146))
                )
            )
        )
    )
)
(procedure (selectorZero)
= sBegin 0
= sCont 0
= sCred 0
= sIntro 0
)

(instance theRomance of Prop
    (properties
        x 86
        y 163
        view 913
        cel 0
    )
)
(instance theThrone of Prop
    (properties
        x 236
        y 159
        view 913
        cel 1
    )
)
(instance theSpark1 of Prop
    (properties
        x 61
        y 27
        view 950
        cycleSpeed 10
    )
)
(instance theSpark2 of Prop
    (properties
        x 97
        y 59
        view 950
        cycleSpeed 11
        cel 2
    )
)
(instance theSpark3 of Prop
    (properties
        x 130
        y 21
        view 950
        cycleSpeed 12
        cel 4
    )
)
(instance theSpark4 of Prop
    (properties
        x 182
        y 21
        view 950
        cycleSpeed 11
    )
)
(instance theSpark5 of Prop
    (properties
        x 208
        y 54
        view 950
        cycleSpeed 9
        cel 1
    )
)
(instance theSpark6 of Prop
    (properties
        x 264
        y 32
        view 950
        cycleSpeed 12
    )
)
(instance theSpark7 of Prop
    (properties
        x 143
        y 89
        view 950
        cycleSpeed 8
        cel 3
    )
)
(instance theSpark8 of Prop
    (properties
        x 174
        y 117
        view 950
        cycleSpeed 10
    )
)
(instance buttonIntro of Prop
    (properties
        x 58
        y 146
        view 950
    )
)
(instance buttonBegin of Prop
    (properties
        x 161
        y 146
        view 950
    )
)
(instance buttonCred of Prop
    (properties
        x 58
        y 165
        view 950
    )
)
(instance buttonCont of Prop
    (properties
        x 161
        y 165
        view 950
    )
)
(instance buttonSelect of Prop
    (properties
        x 58
        y 146
        view 950
    )
)
Title: Re: Bit of help with 3 Things
Post by: Doan Sephim on June 07, 2007, 05:33:15 PM
I'm working through the code, but I think I may have found a problem, and I will post the redone code as soon as I get it reworked. I think there is an (else floating around with no (if and it may be causing problems.
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 07, 2007, 05:48:30 PM
If you need it here's the syntax tree that's created from that script.
Title: Re: Bit of help with 3 Things
Post by: Doan Sephim on June 07, 2007, 05:52:45 PM
I PMed you with a redone script. I added an (if(sMenuStart) and I think I changed a few of the brackets...let me know if it works!

EDIT: OOPS!! I sent you the script prematurely. I was going over it again and found a problem. The way the code is the enter button will not do anything until sMenuStart is TRUE...you can replace the code with this slightly modified version:

Code: [Select]
(if (==(send pEvent:type)evKEYBOARD)
           
            (if(==(send pEvent:message)KEY_RETURN)
(if(sMenuStart)
            (if(sBegin)
                   (send gTheMusic:fade())
                   (send gRoom:newRoom(INITROOMS_SCRIPT))
                )(else
                    (if(sCont)
                        (send gGame:restore())
                    )(else
                       (if(sIntro)
                           = gIntro 1
                           (send gTheMusic:fade())
                           (send gRoom:newRoom(INITROOMS_SCRIPT))
                       )(else
                           (if(sCred)
                                = gCred 1
                               (send gTheMusic:fade())
                               (send gRoom:newRoom(INITROOMS_SCRIPT))
                           )
                       )
                    )
)
)(else
                (RoomScript:cue())
)
            )
)
Title: Re: Bit of help with 3 Things
Post by: troflip on June 07, 2007, 06:01:20 PM
Procedure calls should have () at the end
Code: [Select]
(selectorZero)
Should be

Code: [Select]
selectorZero()
The former will not compile in SCI Companion.  Yes, it does compile in SCIStudio, but SCIStudio has incomprehensible grammar rules (not sure where you saw that style of calling functions Doan - I'm pretty sure Brian's tutorials never used it, nor is it used in the template game) .  The latter compiles fine in both and is consistent with usage in the template game and the tutorials.
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 07, 2007, 06:04:17 PM
Thanks for that edit again, Doan. And thank you, troflip, that was my problem all along.

Also I'll ask again. I'm guessing the arrows won't control the menu selector in this script. How involved would the code have to be to implement that. I have an idea how it would work I'm just wondering what would be the most efficient way.
Title: Re: Bit of help with 3 Things
Post by: Doan Sephim on June 07, 2007, 06:07:51 PM
The script I posted allows for the arrows to select. All the code is there for the up and down arrows. You have put in code for left and right, so I am guessing that is what you are looking for. It's not very involved at all really...you just need a visual representation of which button is selected.

Troflip: thanks for the lesson in coding...I have no idea where I learned that really?! I am not a scripter (SCI was my first and only coding experience) and I did that from day one! oops!
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 07, 2007, 07:03:21 PM
I did see a bit of code that referenced your up and down procedures but they said Joystick not keyboard...will it work anyway?

Also a couple more errors I'm getting here. Firstly when I click on the "Continue Game" button it comes up with an error message that says "font.997 not found." and exits. I don't have any 997 numbers at all in my title script. I don't know what's going on there.

EDIT: I just discovered that it's not a title script error but there's actually an error in my save and restore classes apparently. F5 and F7 both give that font error when I press them in game. I've always had problems with the restore actually. It kept showing a "ctrl" character in the field box for the restore window for instance and I don't know why. Any idea how I can fix these font errors? I can't even find 997 in the SysWindow script. What's strange is I have a slightly earlier backup of my game and the save restore functions work fine. Although this did start happening after I was messing with cursors. But I put everything back to normal...I don't understand.

EDIT 2: I compiled the SysWindow script in SCI Studio and it suddenly works fine now. Strange. (I've been using SCI Companion exclusively all this time)

Secondly the mouse events. They work fine except for one thing. I have to click on them twice to get them to load. The first click puts the selector on the button and the second click loads whatever that button is supposed to be doing. Which is alright if that's the way it has to be, but I'm trying to make both happen simultaneously. I put the selector positioner code in both the "if" and the "else" but it still loads what the button does without moving the selector on top of the button. Here's my code. I've only so far altered the buttonBegin "if".

Code: [Select]
        (if(==(send pEvent:type())evMOUSEBUTTON)
            (if(sMenuStart)
                (if((> (send pEvent:x) (buttonBegin:nsLeft))and
                    (< (send pEvent:x) (buttonBegin:nsRight))and
                    (> (send pEvent:y) (buttonBegin:nsTop))and
                    (< (send pEvent:y) (buttonBegin:nsBottom)))
                    (if(sBegin)
                    (buttonSelect:posn(161 146))
                        (send gTheMusic:fade())
                        (send gRoom:newRoom(INITROOMS_SCRIPT))
                    )(else
                        selectorZero()
                    = sBegin 1
(buttonSelect:posn(161 146))
                    (send gTheMusic:fade())
                        (send gRoom:newRoom(INITROOMS_SCRIPT))
                        (send pEvent:claimed(TRUE))
                )
            )(else
                    (if((> (send pEvent:x) (buttonCont:nsLeft))and
                        (< (send pEvent:x) (buttonCont:nsRight))and
                    (> (send pEvent:y) (buttonCont:nsTop))and
                    (< (send pEvent:y) (buttonCont:nsBottom)))
                    (if(sCont)
                        (send gGame:restore())
                    )(else
                            (selectorZero())
                        = sCont 1
                        (buttonSelect:posn(161 165))
                        (send pEvent:claimed(TRUE))
                    )
                )(else
                        (if((> (send pEvent:x) (buttonCred:nsLeft))and
                            (< (send pEvent:x) (buttonCred:nsRight))and
                            (> (send pEvent:y) (buttonCred:nsTop))and
                            (< (send pEvent:y) (buttonCred:nsBottom)))
                            (if(sCred)
                                = gCred 1
                           (send gTheMusic:fade())
                           (send gRoom:newRoom(INITROOMS_SCRIPT))
                        )(else
                                (selectorZero())
                            = sCred 1
                            (buttonSelect:posn(58 165))
                            (send pEvent:claimed(TRUE))
                        )
                    )(else
                            (if((> (send pEvent:x) (buttonIntro:nsLeft))and
                                (< (send pEvent:x) (buttonIntro:nsRight))and
                                (> (send pEvent:y) (buttonIntro:nsTop))and
                            (< (send pEvent:y) (buttonIntro:nsBottom)))
                            (if(sIntro)
                                    = gIntro 1
                                (send gTheMusic:fade())
                                (send gRoom:newRoom(INITROOMS_SCRIPT))
                            )(else
                                    (selectorZero())
                                = sIntro 1
                                (buttonSelect:posn(58 146))
                                (send pEvent:claimed(TRUE))
                )
                            )
                        )
                    )
)
)(else
                (RoomScript:cue())
                (RoomScript:cue())
            )
Also, what exactly does "(send pEvent:claimed(TRUE))" do in this script?

Also one other thing. To make the Introduction and Credits buttons work the right way I assumed there'd need to be global variables enabled (which I've named gIntro and gCred) before the "(send gRoom:newRoom(INITROOMS_SCRIPT))" line is executed. But there'd have to be something somewhere else that would catch this and tell the game where to go. Would that be in the InitRooms script? Like a "(if (gIntro)...<do something>)(else (if gCred)....<do something>))(else <do normally>))"  kinda thing?
Title: Re: Bit of help with 3 Things
Post by: Doan Sephim on June 07, 2007, 08:07:21 PM
Don't worry about it saying "Joystick" it will work just the same.

You do have to double-click...I did that merely for my game, you don't have to do that for yours. In fact, it would be less coding for single-click...you would just have to take out some code.

You wouldn't need to have a global variable and then go to initrooms, you could simply tell the game, when clicked on credits to go to that particular room:
Code: [Select]
(send gRoom:newRoom(900)) or whatever number room it would be.

I have no idea what
Code: [Select]
(send pEvent:claimed(TRUE)) really does, I just have it there because I borrowed some of this code from Cloudee1 and it was in his...sorry

Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 07, 2007, 08:26:14 PM
You do have to double-click...I did that merely for my game, you don't have to do that for yours. In fact, it would be less coding for single-click...you would just have to take out some code.
Would you be willing to show me which code? I've been messing with it for a while now and I still can't figure it out. Not with the selector landing on the button you click, anyway.

Quote
You wouldn't need to have a global variable and then go to initrooms, you could simply tell the game, when clicked on credits to go to that particular room:
Code: [Select]
(send gRoom:newRoom(900)) or whatever number room it would be.
Ah nice! Thank you for that!

Quote
I have no idea what
Code: [Select]
(send pEvent:claimed(TRUE)) really does, I just have it there because I borrowed some of this code from Cloudee1 and it was in his...sorry
I see. Well I'll just leave it there just in case, then.

My title screen is just about finished now. I just need to get that double-click issue sorted out. One last thing. I have these sparkles animating on the title. Right now they're only animating forwards and looping. How do I get it to loop forwards then backwards and loop that way?
Title: Re: Bit of help with 3 Things
Post by: troflip on June 07, 2007, 08:52:36 PM
EDIT 2: I compiled the SysWindow script in SCI Studio and it suddenly works fine now. Strange. (I've been using SCI Companion exclusively all this time)

Uh oh.  What version of SCI Companion do you have?
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 07, 2007, 08:55:21 PM
Version 2.1.0.4. Is that the latest version? When I tried compiling it in SCI Companion (all I changed was removing a couple of "//" in front of valid code parameters) it gave errors for using the "self" command or something if that means anything to you.
Title: Re: Bit of help with 3 Things
Post by: Doan Sephim on June 07, 2007, 09:30:15 PM
Would you be willing to show me which code? I've been messing with it for a while now and I still can't figure it out. Not with the selector landing on the button you click, anyway.

Are you saying you want to click on the button, have the selector animate on the button for a split second and then move on to whatever the actual button does? If so, I would create something like this:
Code: [Select]
(instance buttonPress of Script
    (properties)
    (method (changeState newState)
        = state newState
        (switch (state)
            (case 2 = cycles 3
                  (code where the selector animates on the given button)
            (case 3
                  (code that does what the button says)
            )
         )
     )
)

To get this instance to work you have to do a couple things:
(1) on any one of your views that you have initialized, you need to add "setScript(buttonPress)" like:
Code: [Select]
(theThrone:init()setScript(buttonPress))This will make it so the instance is recognized.

(2)Then, wherever you have the click code you put in this: (buttonPress:changeState(2)), which will tell the script to run that code, send you to 3 cycles of the selector landing on the particular button, and then going on to run whatever that button does.

If you do this, you will have to do some re-working on your code. You should be able to figure it out though.

Quote
My title screen is just about finished now. I just need to get that double-click issue sorted out. One last thing. I have these sparkles animating on the title. Right now they're only animating forwards and looping. How do I get it to loop forwards then backwards and loop that way?

easiest way I think is to just make the view to shimmer out and back in again. But if you want it to shimmer out and in, and then wait a moment, you would have to do something like what I just showed you in creating another changeState instance that controls them...you should be able to find out how that works from what I described...but if you have questions, I will try to answer them.
Title: Re: Bit of help with 3 Things
Post by: troflip on June 07, 2007, 09:32:27 PM
Version 2.1.0.4. Is that the latest version? When I tried compiling it in SCI Companion (all I changed was removing a couple of "//" in front of valid code parameters) it gave errors for using the "self" command or something if that means anything to you.

That's the latest version.

The error means nothing unless I know the exact error and see the code.  It would be great if people would file bug reports when they think they see bugs (you can do this from the Help menu).
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 07, 2007, 10:09:21 PM
I've recreated the instance and emailed you the error message.

Thanks, Doan I'll look into altering the code for that.

Quote
easiest way I think is to just make the view to shimmer out and back in again. But if you want it to shimmer out and in, and then wait a moment, you would have to do something like what I just showed you in creating another changeState instance that controls them...you should be able to find out how that works from what I described...but if you have questions, I will try to answer them.
There's no way to just animate the cels in a loop forwards and then backwards?
Title: Re: Bit of help with 3 Things
Post by: Doan Sephim on June 07, 2007, 10:19:26 PM
There is a way to make the view go backward...but the problem is you have to tell it to go backward. So to make it so you can tell it to do so, you have to make a changeState instance so that you can tell it do go backward after going forward, and then you have it cycle...it would look something like this:
Code: [Select]
(instance shimmerScript of Script
    (properties)
    (method (changeState newState)
        = state newState
        (switch (state)
            )(case 1 = cycles 20 // (or however many cycles it takes)
                 (shimmer:setCycle(End))
            )(case 2 = cycles 20
                 (shimmer:setCycle(Beg))
            )(case 3
                 (shimmerScript:changeState(1)) // make it all loop around forever!
            )
         )
    )
)

Then of course you have to have setScript(shimmerScript) in one of you instances...and then when you want the shimmering to begin: (shimmerScript:changeState(1))
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 07, 2007, 11:04:36 PM
Doan, my friend, you've been awesome. Thanks so much for your help! My title screen is now complete! I probably won't bother doing that shimmer thing, though, I'll save it and keep it in mind for the future. I've done enough work already and it already looks nice enough.

I'll upload a demo of the title screen a little later on so you guys can check it out. Tell me if you notice anything offhand that differs in any way from KQ1SCI's menu ;).
Title: Re: Bit of help with 3 Things
Post by: Doan Sephim on June 07, 2007, 11:13:50 PM
Glad to be of help  ;D
It helps that my title screen is very similar to what you're doing. I look forward to seeing your title screen!

I know it feels good to get it done...I was quite proud when I got my screen done...sounds silly, but it's true!
Title: Re: Bit of help with 3 Things
Post by: troflip on June 08, 2007, 12:03:48 AM
Doan/MI, you can leave out the "= cycles 20" thing by providing a reference back to the shimmerScript. That way you don't need to know how many cycles it takes.  When the cycler is done, it will call the cue method on shimmerScript, which will call changeState with the next state.

Code: [Select]
(instance shimmerScript of Script
    (properties)
    (method (changeState newState)
        = state newState
        (switch (state)
            )(case 1
                 (shimmer:setCycle(End shimmerScript))
            )(case 2
                 (shimmer:setCycle(Beg shimmerScript))
            )(case 3
                 (shimmerScript:changeState(1)) // make it all loop around forever!
            )
         )
    )
)
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 08, 2007, 12:07:53 AM
Ah nice! Thanks for that.
Title: Re: Bit of help with 3 Things
Post by: Doan Sephim on June 08, 2007, 12:23:55 AM
Good to know! I thought there was a way to do that, but I wasn't sure!
Title: Re: Bit of help with 3 Things
Post by: MusicallyInspired on June 08, 2007, 12:24:46 AM
BTW I've posted the demo in the KQ2SCI thread in the SCI games forum.