Community

SCI Programming => SCI Community How To's & Tutorials => Topic started by: claudehuggins on September 22, 2016, 11:58:21 PM

Title: Need help finding a tutorial -- Am I going crazy?
Post by: claudehuggins on September 22, 2016, 11:58:21 PM
Times like this make me wish there was a "?!" message icon.

I swear this is a tutorial/guide I saw somewhere. I don't know if it was on the forums, or the wiki, or what, but I can't find it for the life of me.

It was a guide on making an "exit message" (optionally, a randomly selected one) that appears in DOS upon exiting the game. The example given was the messages that pop up when you exit SQ6 to DOS, and the process involved putting all the messages you wanted in a text resource.

I know this tutorial/guide exists because I remember using it and showing off the results to my friends. Or did I hallucinate the whole thing? Or maybe I'm just tired and it was right here all along (I stayed up later than usual tonight to work on RoPreSto.)

Also, I'm sorry if this isn't in the right board. I couldn't think where else to put it, and as I mentioned before, I'm quite tired, so apologies if this post in general has a thousand horrible mistakes. I'll probably edit this heavily when I wake up tomorrow.
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: MusicallyInspired on September 23, 2016, 12:29:00 AM
That...would be cool. Is that something that's part of the scripts at all I wonder or part of the interpreter?
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: lskovlun on September 23, 2016, 12:32:48 AM
http://sciprogramming.com/community/index.php?topic=1484.0
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: Collector on September 23, 2016, 01:16:27 AM
You weren't thinking of the death handler, were you? http://sciwiki.sierrahelp.com//index.php?title=SCI_Studio_Tutorial_Chapter_23_-_Using_The_Death_Handler
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: claudehuggins on September 23, 2016, 08:46:49 AM
lskovlun had it. Odd, could have sworn SQ6 was mentioned in the post... I know that game did something similar, so maybe that's what confused me.

Thank you!!

I was, however, mistaken in my remembering that it was for SCI0. Though, I can't think of any early SCI games that used this sort of feature, so I'm not sure what in the world gave me that assumption. Well, the important thing is I found the post I was looking for :)
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: Cloudee1 on September 23, 2016, 11:36:25 AM
I accomplished this in the MenuBar script.

Scroll down to the MENU_QUIT case statement and add in anything that you want. In my case I always add in the "Visit SciProgramming.com" line. In this case here it is hardcoded in the script, but it would be just as easy to send it to a text resource instead.

Code: [Select]

(case MENU_QUIT  
(if(Print("Do you really want to quit?" #title "Quit" #font gDefaultFont #button " Quit " 1 #button " Oops " 0))
Print("Visit SciProgramming.com")
= gQuitGame TRUE
)
)

I can't remember if you can use the Random procedure in the print statement directly, but if so then assuming in this case text resource 100 lines 1,2,3,4 then change the sciprogramming line above to something like...

Code: [Select]
Print(100 Random(1 4))
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: OmerMor on September 23, 2016, 01:12:48 PM
The kernel call was added in SCI version 1.001.071 (1993-01-15).
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: Kawa on September 23, 2016, 01:13:07 PM
Poor claude :D
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: claudehuggins on September 23, 2016, 01:35:35 PM
I accomplished this in the MenuBar script.

Scroll down to the MENU_QUIT case statement and add in anything that you want. In my case I always add in the "Visit SciProgramming.com" line. In this case here it is hardcoded in the script, but it would be just as easy to send it to a text resource instead.

Code: [Select]

(case MENU_QUIT  
(if(Print("Do you really want to quit?" #title "Quit" #font gDefaultFont #button " Quit " 1 #button " Oops " 0))
Print("Visit SciProgramming.com")
= gQuitGame TRUE
)
)

I can't remember if you can use the Random procedure in the print statement directly, but if so then assuming in this case text resource 100 lines 1,2,3,4 then change the sciprogramming line above to something like...

Code: [Select]
Print(100 Random(1 4))

Your method got me as close to what I wanted as I think I'm going to get with this version of SCI :P
And it doesn't seem like you can call the random procedure in this situation, but I'm sure I could find an albeit less-graceful way of doing it, or maybe a way for the print statement to take a variable...
But, all in all, it's solely aesthetic in the end. One will be plenty. :)
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: troflip on September 23, 2016, 01:44:23 PM
Why wouldn't you be able to use Random in a Print statement?
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: Cloudee1 on September 23, 2016, 02:44:51 PM
I had that inkling, but I really wasn't sure... you could always use a switch statement... but it's not very pretty

Code: [Select]
(case MENU_QUIT
  (if(Print("Do you really want to quit?" #title "Quit" #font gDefaultFont #button " Quit " 1 #button " Oops " 0))
    (switch(Random(0 3))
      (case 0 Print(100 1))
      (case 1 Print(100 2))
      (case 2 Print(100 3))
      (default Print(100 4))
    )// end switch
    = gQuitGame TRUE
  )//end if
)// end case
 
Or the best solution would be to create a variable to use

In the handle event method, add the new varable... your current variable list may look different than this, I am pulling up Manic's source code to copy from, but just add randomStatement to the end of whatever is listed in the var defines.

Code: [Select]
(method (handleEvent pEvent)
(var menuItem, hGauge, newSpeed, randomStatement)

Then in the case menu quit statement set the variable and use it.

Code: [Select]
(case MENU_QUIT
     = randomStatement Random(1 4)
     (if(Print("Do you really want to quit?" #title "Quit" #font gDefaultFont #button " Quit " 1 #button " Oops " 0))
          Print(100 randomStatement)
          = gQuitGame TRUE
     )
)

I can't think of any reason why this wouldn't work

* tested, works... you may need to adjust accordingly for Sierra syntax. As mentioned elsewhere, I have not yet made the change
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: troflip on September 23, 2016, 03:14:20 PM
Random returns a value, and... you can obviously pass values to functions, so...

Code: [Select]
(MENU_QUIT
     (if (Print "Do you really want to quit?" #title "Quit" #font gDefaultFont #button " Quit " 1 #button " Oops " 0)
          (Print 100 (Random 1 4))
          (= gQuitGame TRUE)
     )
)
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: claudehuggins on September 23, 2016, 03:17:18 PM
Random returns a value, and... you can obviously pass values to functions, so...

Code: [Select]
(MENU_QUIT
     (if (Print "Do you really want to quit?" #title "Quit" #font gDefaultFont #button " Quit " 1 #button " Oops " 0)
          (Print 100 (Random 1 4))
          (= gQuitGame TRUE)
     )
)
Okay, that's just bizarre...The first time I tried this, it didn't work, and that's why I said it didn't...but I tried it again just now, the exact same way, and it worked.
Weird.
Okay, glad that's handled, though! I thought it was a little odd that this would cause errors.
Title: Re: Need help finding a tutorial -- Am I going crazy?
Post by: Cloudee1 on September 23, 2016, 03:19:24 PM
Yeah Phil, you're right. This does work
Code: [Select]
Print(100 Random(1 4)) // Studio syntax

the differences in the syntax would be my guess why Claude thought it failed initially
Code: [Select]
(Print 100 (Random 1 4)) // Sierra syntax

That's my bad Claude for not pointing out at the time that I was using Studio syntax when I first posted the solution. Well if nothing else, you now have three ways to accomplish the same goal