Author Topic: SCI0: Issues implementing Trite Phrase Menu item  (Read 422 times)

0 Members and 1 Guest are viewing this topic.

Offline robbo007

SCI0: Issues implementing Trite Phrase Menu item
« on: September 26, 2024, 04:35:18 PM »
Hi guys,
I'm trying to implement something like the Trite Phrase used in LSL2 or the Expletive in LSL3. The LSL2 version seems a lot simpler but I'm getting a crash when using the code in my main.sc

I've added the following to my main.sc
Code: [Select]
(= gExpletive (Format @gExpletiveBuffer 976 0)) ; "Have a nice day."
and I've added the following to menubar.sc

Code: [Select]
(AddMenu
{ Action_}
{Pause Game`^p:Inventory`^I:Retype`#3:--! :Colors`^c :Ask about`^a :Boss Key`^b :Lowe-O-Meter\05`^h :Expletive`^x};:Expletive`^x
)

Code: [Select]
(MENU_EXPLETIVE
(GetInput (Format @temp4 gExpletive) 38
{Enter your favorite expletive:}
)
(if (> (StrLen @temp4) 4)
(Format gExpletive @temp4)
)
)

The game.sh has:
Code: [Select]
(define MENU_EXPLETIVE $0309)
And I have a text file created 976 with the 0 entry holding "Have a nice day"

I get the opps error when starting my game. Using the debug commands I see its getting stuck in room 290 init. This room runs a speed checker for real hardware at startup.

Code: [Select]
(method (init)
(ProgramControl)
(= gProgramControl FALSE)
(SL disable:)
(TheMenuBar hide:)
(super init:)
(gEgo
view: 290
posn: 20 100
setStep: 1 1
setMotion: MoveTo 3000 100
setCycle: Walk ;even though view.290 has only one frame, the overhead of a Cycler makes the simulation more realistic.
init:
)
(gGame setSpeed: 0)
)








Offline lskovlun

Re: SCI0: Issues implementing Trite Phrase Menu item
« Reply #1 on: September 29, 2024, 03:54:12 AM »
Did you insert the new variable in the middle of the existing globals, and if so, did you remember to recompile everything? It may be a good idea in any case...

Offline robbo007

Re: SCI0: Issues implementing Trite Phrase Menu item
« Reply #2 on: September 29, 2024, 03:09:55 PM »
Hi,
I did, I've got gExpletive defined in my main.sc. Recompiled all.
Regards,

Offline lskovlun

Re: SCI0: Issues implementing Trite Phrase Menu item
« Reply #3 on: October 04, 2024, 09:22:26 AM »
You can put (SetDebug) at the beginning of rm290::init and it will break into the debugger when you get there. Then either step through or move the SetDebug later and later until you hit the problematic statement.

Offline robbo007

Re: SCI0: Issues implementing Trite Phrase Menu item
« Reply #4 on: October 04, 2024, 11:01:11 AM »
Amazing thanks for the pointer. I did not know that syntax. It works very well. I find it easier to understand the stack than the actual debug code.

So its seems its failing on all startup rooms that have the:

(PlayerControl)
(ProgramControl)

If I comment these out it gets to my first room #29 then crashes with the infamous out of heap space error.

I see in room 29# I have:

Free Heap: 2022 Bytes
FreeHunk: 40KBytes

Maybe putting the Trite menu item in the main.sc is a bad idea? As it uses more memory right? In LSL3 they don't seem to use it in the main.sc

What things can help free up Heap and Hunk? I think I need to optimise my code a little more.


Offline lskovlun

Re: SCI0: Issues implementing Trite Phrase Menu item
« Reply #5 on: October 04, 2024, 12:09:15 PM »
I went and looked at the code for PlayerControl/ProgramControl, and they both do (ego setMotion: 0), i.e. stop ego. Now, room 290 (as taken from LSL3) doesn't have an ego, so this ought to fail in LSL3 as well, but doesn't.
I don't think this is because of your menu item. There must be something else you've changed. LSL3 sets up ego in the main script like this:
Code: [Select]
                (User
                        alterEgo                        (= ego egoObj),
                        blocks                  FALSE,
                ;       echo                            SPACEBAR,
                ;       x                                       -1,
                        y                                       150,
                )
did you change or move this?

Offline robbo007

Re: SCI0: Issues implementing Trite Phrase Menu item
« Reply #6 on: November 05, 2024, 12:35:32 PM »
Sorry for the hiatus.

So I have in my main.sc

Code: [Select]
(User alterEgo: gEgo blocks: FALSE x: -1 y: 150)

I don't have the "echo SPACE" syntax as it does not like it. I'm not sure if its needed?

I've tried to simplify the command a little more in my 290 script:
Code: [Select]
(= gExpletive ;this is causing startup not to work
(Format @gExpletiveBuffer 290 1)
)
If I use %s in my text file 290 1 it works but does not show a default Trite phrase when selecting it from the menu. You can enter in a new one and it seems to work fine. If I change the %s for "Have a nice day" that's when it crashes on the ProgramControl syntaxes.





Offline troflip

Re: SCI0: Issues implementing Trite Phrase Menu item
« Reply #7 on: November 05, 2024, 05:27:19 PM »
I don't have the "echo SPACE" syntax as it does not like it. I'm not sure if its needed?

It was a comment in the snippet of code Lars posted... See the semicolon? So it wasn't included.
So was x: -1...

So the equivalent to

Code: [Select]
(User
                        alterEgo                        (= ego egoObj),
                        blocks                  FALSE,
                ;       echo                            SPACEBAR,
                ;       x                                       -1,
                        y                                       150,
  )

would be

Code: [Select]
(User alterEgo: gEgo blocks: FALSE y: 150)
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline lskovlun

Re: SCI0: Issues implementing Trite Phrase Menu item
« Reply #8 on: November 05, 2024, 10:21:04 PM »
Code: [Select]
(User alterEgo: gEgo blocks: FALSE y: 150)
You missed the most important and subtle part of this, actually. gEgo is 0 before this point, and as a side effect of setting alterEgo, it also assigns a value to gEgp:
Code: [Select]
                        alterEgo                        (= ego egoObj),


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

Page created in 0.046 seconds with 24 queries.