Author Topic: Help Requested: Adding titles to death messages?  (Read 5077 times)

0 Members and 1 Guest are viewing this topic.

Offline claudehuggins

Help Requested: Adding titles to death messages?
« on: January 20, 2016, 12:47:14 PM »
I know how to register a death icon and message, like such
Code: [Select]
(send dyingScript:
caller(1)
register("This is the string registered in rm001.sc. The caller has been set to view 1.")
)
And this code works fine, I have no problems with this on its own.
But, I was wondering, how would I add a title to the message window? The first example I can think of would be the death messages in Space Quest III ("One way to lower your blood pressure", etc).
Is there any way to implement a "#title" I could register from the room script, or would it be more complicated than that?

My first assumption was something like
Code: [Select]
(send dyingScript:
caller(1)
register("This is the string registered in rm001.sc. The caller has been set to view 1." #title "Wow, a title!")
)
but this neither did what I intended nor produced an error, so I'm not entirely sure what the interpreter is seeing when it comes across that line.

Apologies if this seems simple or trivial; I'm relatively new to this and only really just recently figured out how to USE the handler in the first place.


A while ago, at a block party I found myself socially trapped at, I thought to myself: I need a t-shirt that says, "I'd rather be programming".

Online troflip

Re: Help Requested: Adding titles to death messages?
« Reply #1 on: January 20, 2016, 01:59:21 PM »
Quote
I'm not entirely sure what the interpreter is seeing when it comes across that line.

"register" is a property on the Script class, so the parameter you pass is setting the value to that. In this case, you're passing three parameters, which doesn't make sense (the second two are just ignored, I guess).

DyingScript is an instance, and you can't define new properties on instances. So maybe the easiest thing to do is to add a setTitle method on the DyingScript instance (which you would call from your room), and store that title in a local variable in Dying.sc. Then use that local variable for the #title in the Print call in DyingScript's changeState method.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline claudehuggins

Re: Help Requested: Adding titles to death messages?
« Reply #2 on: January 20, 2016, 02:39:30 PM »
I'm sorry, would you be able to provide an example? I'm always having troubles with methods and changeStates, and I don't want my ignorant fumbling experiments to mess anything up...
By the way, sorry if I sound like I'm stumbling around in the dark here; I do have experience with coding but somehow SCI in particular keeps confusing me.
« Last Edit: January 20, 2016, 08:58:26 PM by Cloudee1 »
A while ago, at a block party I found myself socially trapped at, I thought to myself: I need a t-shirt that says, "I'd rather be programming".

Offline MusicallyInspired

Re: Help Requested: Adding titles to death messages?
« Reply #3 on: January 20, 2016, 08:27:04 PM »
Perhaps due to its object oriented nature? It's quite different from regular C, for instance.
Brass Lantern Prop Competition

Offline Cloudee1

Re: Help Requested: Adding titles to death messages?
« Reply #4 on: January 20, 2016, 08:57:39 PM »
I have tried a couple of little things to make this work and so far they have failed. Here is a very short and low impact code that should work.

First lets go ahead and create a global variable in the main script.

Code: [Select]
deathTitle[25]

Next, we'll head into the Dying script and adjust the Print statement to include a title which will hopefully pull our global variable.

Code: [Select]
  (if(Print(
  message
  #title deathTitle
  #font gDeadFont
  #icon deadIcon
  #button "Continue On" 0
  #button "Order Hintbook" 1
      ))
  Print(
  "Order a hint book? Who do you think I "+
  "am? Sierra On-Line?"
  )
)

And then finally in the actual room script, just before calling the death handler, simply set the global variable to hold a value.

Code: [Select]
                  = dyingScript ScriptID(DYING_SCRIPT)
                  = deathTitle "Shit Title"
                  (send dyingScript:
                    caller(2)
                    register("Thank you for playing. Too bad you've failed miserably.  Better luck next time.")
                  )
                  (send gGame:setScript(dyingScript))

And there you go, simple and easy. My first few attempts were to actually change the script object to include a new title property but in the end, I couldn't seem to get it to work quite right... But this way does.
« Last Edit: January 20, 2016, 09:00:16 PM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline claudehuggins

Re: Help Requested: Adding titles to death messages?
« Reply #5 on: January 20, 2016, 09:16:00 PM »
It works like a charm! Thank you so much!  ;D
A while ago, at a block party I found myself socially trapped at, I thought to myself: I need a t-shirt that says, "I'd rather be programming".

Offline claudehuggins

Re: Help Requested: Adding titles to death messages?
« Reply #6 on: January 20, 2016, 09:59:12 PM »
Sorry for the double post, this one I can live without but I'm curious if it's possible. Is there any way to point the title to a text resource? Like, say I have text resource 500 set aside for death messages.
Code: [Select]
(send dyingScript:
caller(1)
register(500 1)
This works fine, soEDIT: It does not; I'm not sure what made me think it was working. I was wondering... Could I put the titles in there too, and use that instead of a string? Or does it just not work that way?
« Last Edit: January 20, 2016, 10:04:09 PM by claudehuggins »
A while ago, at a block party I found myself socially trapped at, I thought to myself: I need a t-shirt that says, "I'd rather be programming".

Offline Cloudee1

Re: Help Requested: Adding titles to death messages?
« Reply #7 on: January 20, 2016, 11:20:56 PM »
Theoretically it is possible...

Here is a thread where Gumby attempted to use text resources for titles, http://sciprogramming.com/community/index.php?topic=898.msg4362#msg4362

It doesn't look like he was ever quite happy with his results though judging from the edits he made to the post.

As for my own opinions... It looks like it is more trouble than it is worth. Sometimes it is better just to come up with something that works and move on rather than getting bogged down and frustrated. I find that I spend more time trying to get something to work the way I think it should versus a way that I know it will.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline Kawa

Re: Help Requested: Adding titles to death messages?
« Reply #8 on: January 21, 2016, 05:38:14 AM »
My suggestion: use single "death reason" values, one per joke, set the register to one of those, and have dyingScript set the text, title, and icon from there.

Even easier to do if you put joke #N as text line #N, with icon #N, and the title as text line #N+50 or so.

Online troflip

Re: Help Requested: Adding titles to death messages?
« Reply #9 on: January 21, 2016, 10:44:12 AM »
Yup, that sounds like a reasonable way to do it. That way you can easily customize things even further based on the death reason (e.g. different font colors, whatever).
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: Help Requested: Adding titles to death messages?
« Reply #10 on: January 21, 2016, 03:05:44 PM »
The hard part is pulling the text resource in as the title. If I remember correctly, it is not looking for two parameters for that property.

For example, this fails
Code: [Select]

      Print("hello" #title 5 8)

Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline lskovlun

Re: Help Requested: Adding titles to death messages?
« Reply #11 on: January 21, 2016, 04:23:21 PM »
The hard part is pulling the text resource in as the title.
Why would that be hard? If you're already adding a new method (as Phil suggested), you can check first whether it's a pointer (compare it to 1000, that's what Sierra does and it's special-cased in ScummVM), and if it isn't, call GetFarText or Format to put the string into DeathTitle (if it is a pointer, use StrCpy to put the string there).


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

Page created in 0.114 seconds with 24 queries.