1
SCI Syntax Help / Re: [Solved] SCI0 - multiple actors using same changeState
« on: July 03, 2025, 11:58:08 PM »
Sounds good. It certainly doesn't hurt to keep it in, either way, just to be on the safe side.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
OK, so the script is not supposed to finish. In that case, you shouldn't dispose the script until a room change. Add it to (yourRoom newRoom:) instead. Something like:Okay, I tested both of these (and none at all) and ran a memory check in the next adjacent room. In every instance the heap memory was the same. Do you suppose the global disposal cleanup is sufficient and these extra methods are superfluous, or am I simply not using them properly and mininterpreting the data?Code: [Select](method (newRoom)
or maybe even:
(myScript1 dispose:)
(myScript2 dispose:)
(super newRoom: &rest)
)Code: [Select](method (newRoom)
((myActor1 script:) dispose:)
((myActor2 script:) dispose:)
(super newRoom: &rest)
)
(instance DeadwoodScript of Script
(method (changeState newState)
(= state newState)
(switch state
(0
(if (> (client x?) 139)
(client setMotion: MoveTo (- (client x?) 60) (client y?) self)
else
(self cue:)
)
)
(1 (= cycles 10)
(client setMotion: 0)
)
(2
(if (< (client x?) 120)
(client setMotion: MoveTo (+ (client x?) 60) (client y?) self)
else
(self cue:)
)
)
(3 (= cycles 10)
(client setMotion: 0)
)
(4
(self changeState: 0)
(self dispose:)
)
)
)
)
This was released a few days ago, but wanted to make sure it was known here if it wasn't already.Thanks so much for announcing this! I've been meaning to do this, but man! There's been a lot going on! Thanks again, Brandon. Also, thanks doomlazer for the very kind words about the game! It is now a far better experience - visually, musically, and gameplay as well!
Maybe try setting a flag for "retry", call restore and them modify the restore method like this:Seems to have worked simply and easily. Will have to play around a little bit to make sure there are no issues, but seems like a very easy solution. Plus, there should always be a "0" save slot since the autosave triggers at the beginning of each room, so there should be no calling on a non-existent save.Code: [Select](method (restore &tmp gameNum oldCursor hSound)
(= gameNum -1)
(Load rsFONT gSaveRestoreFont)
(Load rsCURSOR gNormalCursor)
(Load rsCURSOR gLoadingCursor)
(= oldCursor (self setCursor: gNormalCursor))
(= hSound (Sound pause: 1))
(if (GetSaveDisk TRUE)
(if gPrintDlg (gPrintDlg dispose:))
; handle retry
(if (btst fRetryFlag)
(= gameNum 0)
(bclr fRetryFlag)
else
(= gameNum (Restore doit: &rest))
)
; end handle retry
(if (!= gameNum -1)
(self setCursor: gLoadingCursor)
(if (CheckSaveGame objectName gameNum gVersion)
(gCast eachElementDo: #dispose)
(gCast eachElementDo: #delete)
(RestoreGame objectName gameNum gVersion)
else
{That game was saved under a different interpreter. It cannot be restored.}
#font
0
#button
{OK}
1
)
(self setCursor: oldCursor (HaveMouse))
(= gameNum -1)
)
)
(GetSaveDisk FALSE)
)
(Sound pause: hSound)
(return gameNum)
)
The problem is how do you know game 0 is the most recent save?
That's fair, but I used shorthand. I have an autosave feature that always uses the "0" slot for its save. It autosaves at the beginning of each room. The player could of course choose to save over it, but they would still be in the same room they died, so that is the game I would call.The problem is how do you know game 0 is the most recent save?
Ohohohohohohohoh yeeesss X3
It is worth noting that RestoreGame can fail. Try inserting some Print statements (both before and after RestoreGame) to see if the code gets called at all and to catch any errors from RestoreGame.I would do that, but I'm not sure where it is defined. I searched for it, but didn't find. I will keep looking.
(repeat
(= mbResult
(Print
{Remember:\nsave early, save often!}
#title
{Words to the wise:}
#font
gDeadFont
#button
{Restore}
1
#button
{Retry}
2
#button
{Restart}
3
#button
{__Quit__}
4
)
)
(switch mbResult
(1
(if (!= (gGame restore:) -1) (return))
)
(2
(gCast eachElementDo: #dispose)
(gCast eachElementDo: #delete)
(RestoreGame objectName 0 gVersion)
(return)
)
(3 (gGame restart:) (return))
(4 (= gQuitGame TRUE) (return))
)
)
I simply added a new button called retry, and when it is clicked I copy/pasted some code from the restore method in the game script, but I am clearly missing something. Here is the code from the game script. I'm a bit out of my element when it comes to deciphering the base code, so any help would be appreciated.(method (restore &tmp gameNum oldCursor hSound)
(= gameNum -1)
(Load rsFONT gSaveRestoreFont)
(Load rsCURSOR gNormalCursor)
(Load rsCURSOR gLoadingCursor)
(= oldCursor (self setCursor: gNormalCursor))
(= hSound (Sound pause: 1))
(if (GetSaveDisk TRUE)
(if gPrintDlg (gPrintDlg dispose:))
(= gameNum (Restore doit: &rest))
(if (!= gameNum -1)
(self setCursor: gLoadingCursor)
(if (CheckSaveGame objectName gameNum gVersion)
(gCast eachElementDo: #dispose)
(gCast eachElementDo: #delete)
(RestoreGame objectName gameNum gVersion)
else
(Print
{That game was saved under a different interpreter. It cannot be restored.}
#font
0
#button
{OK}
1
)
(self setCursor: oldCursor (HaveMouse))
(= gameNum -1)
)
)
(GetSaveDisk FALSE)
)
(Sound pause: hSound)
(return gameNum)
)
(procedure (checkEvent pEvent x1 x2 y1 y2)
(if
(and
(> (pEvent x?) x1)
(< (pEvent x?) x2)
(> (pEvent y?) y1)
(< (pEvent y?) y2)
)
(return TRUE)
else
(return FALSE)
)
)
I will reference this procedure in the handleEvent method in this way:(if (== (pEvent type?) evMOUSEBUTTON)
(if (& (pEvent modifiers?) emRIGHT_BUTTON)
(if (checkEvent pEvent 92 123 65 117) ; clicked within the box of these coordinates
(PrintOther 18 6)
)
You can also reference the coordinates of a view this way:(checkEvent pEvent (mapItem nsLeft?) (mapItem nsRight?) (mapItem nsTop?) (mapItem nsBottom?))
(PrintOther 18 24)
)
You can also check to see if the click happened on a control color:(if
(== ctlGREY (OnControl ocSPECIAL (pEvent x?) (pEvent y?)))
(PrintOther 18 77)
)
Or on a priority color:(if
(== ctlYELLOW (OnControl ocPRIORITY (pEvent x?) (pEvent y?)))
(PrintOther 18 78)
)
This is what works for me. Perhaps when I start a new project, I'll look into having something more global, but this does the trick for now,It appears the answer may just be '/somenoun', considering how Rumplestiltskin is implemented in KQ1.Wow! Sometimes I feel SOOOOO dumb! That works easily. Thank you for the prompt answer.
Did you use the conversion built into Companion? Probably a lot of work to fix what gets broken by it, but it might do a lot of the work for you.Yes, I had tried that in the past but it was quite a lot of headache...too much for me at the time... probably too much work still. But now I'm feeling like I'm missing out on something important not being able to use cond to make this simple and elegant code for looking at inv items
SMF 2.0.19 |
SMF © 2021, Simple Machines
Simple Audio Video Embedder
Page created in 0.064 seconds with 20 queries.