You have already done the chapter on
Changing the Player's Score and are well into creating your own adventure game. If you are anything like me you have found that you don't always need to check every single point scoring against a Boolean flag. Whether it's because the inventory item that you used is taken away, hence impossible to do the action again, or some other Btest flag is used to mark the particular progression in the game, sometimes you just want to add to the players score and move on. Or even better, as Troflip pointed out, the scenario where there is no upper limit to the amount of points that can be received, such as some sort of arcade game scenario.
Well, it looks like you should be able to do just that with the changeScore method found in the game.sc script.
(send gGame:changeScore(5))
Unfortunately, this only sort of works.Yes, you can use it, and yes it changes the score, however it does not update the status bar found at the top of the screen. It does update the score found in the control window and if I remember correctly it updates the score found in the extra icon box in the menu if you applied
Kawa's modification but if you are showing the score at the top of the screen all of the time, then it fails. Looking further into the scripts involved, you find (SL:doit())... This should be all that is needed to get the job done, at least it was all that was needed to update the status bar in SCI0 games. But apparently this has been deprecated over the years and has simply not been removed from the sci template that Sierra used as SCI transitioned through it's versions.
At this point, rather than figure out how to fix the current SL of Obj class found in the game.sc script we are just going to cheat and create a new procedure in the main.sc script. It will basicly do the same thing that the AddToScore procedure does, except it won't include any of the Btest, Bset calls. In the main script, scroll all the way to the bottom. We are going to add in this public procedure.
//******************************
(procedure public (ChangeScore param1)
= gScore (+ gScore param1)
(statusLineCode:doit())
(rm0Sound:
priority(15)
number(1000)
loop(1)
flags(1)
play()
)
)
//******************************
Now, because this is a public procedure, it will also need to be added to the main scripts export list. So, scroll all the way back up to the top of the main script and add the procedure name to the bottom of the export list. Because we stuck it at the bottom of the script, the number that corresponds with it is always one larger than the last one currently on the list. If this is the first public anything you have added to the main script, then it will be 15.
15 ChangeScore
Just like I have mentioned in the past, whenever you make a change to the main script it is a necessity that you compile all scripts. Almost always without fail, if you don't, your game will crash when you go to run it.
With those two edits completed, you now have the ability to add to the players score without the need of checking a flag. Simply by adding in the procedure call whenever you want to add or remove points from the player's score. Where the value that you pass is the amount, positive or negative, that you want to add.
ChangeScore(5)
And there you have it, two different ways now to add to the players score firmly under your belt.