Author Topic: changeState script  (Read 1376 times)

0 Members and 1 Guest are viewing this topic.

Offline robbo007

changeState script
« on: July 06, 2023, 05:17:55 PM »
Hi,
I'm messing around with Room 460 and 470 from LSL3. I've managed to get the changeState working for Larry to press button and move into the elevator. Only trouble is instead of walking into the elevator he glides like a ghost. Not sure why this is happening. Any ideas where I'm going wrong?

Code: [Select]
(method (changeState newState)
(= state newState)
(switch state
(0
)
(1 ; handle the elevator, ego goes to button.
(ProgramControl)
;(= IN_ELEVATOR)
(gEgo
illegalBits: 0
ignoreActors:
setMotion: MoveTo 94 139 self
)
)
(2 ; Ego presses button
(gEgo
cycleSpeed: 1
view: 707
setLoop: 2
setCycle: End self
)
)
(3 ; Done pressing button
(aButton setCel: 1 stopUpd:)
(gEgo setCycle: Beg self)
)
(4 ;Elevator lights move
(gEgo view: 000 loop: 3)
(ProgramControl)
((aLightLeft script?) changeState: 3)
)
(5 ;Wait here until the elevator gets to the ground floor,
;indicated by the LightScript reaching cel 0.
(= seconds 0)
)
(6
(aLightLeft setScript: 0)
;(gTheSoundFX number: 460 loop: 1 play:)
(aDoor setCycle: End self)
)
(7
(aDoor stopUpd:)
(= cycles 10)
)
(8 ; Move ego to elevator door
(gEgo illegalBits: 0 setMotion: MoveTo 70 135 self)
)
(9 ; Ego enters elevator
(gEgo setMotion: MoveTo 72 128 self)
)
(10
(gEgo setLoop: 2)
(= cycles 14)
)
(11
;(gTheSoundFX number: 461 loop: 1 play:)
(aDoor setCycle: Beg)
(= seconds 3)
)
(12
;(gTheMusic fade:)
(gRoom newRoom: 505)
)
(13
(gEgo setMotion: MoveTo 70 154 self)
)
(14
;(gTheSoundFX number: 461 loop: 1 play:)
(aDoor setCycle: Beg self)
)
(15
(aDoor stopUpd:)
(gEgo view: 000)
; (= currentStatus egoNORMAL)
)
)
)
)



Offline Kawa

Re: changeState script
« Reply #1 on: July 06, 2023, 05:30:04 PM »
Something else may have messed with Larry before this Script runs, to play a animation or something. Therefore, his cycler isn't set to Walk.

Offline lskovlun

Re: changeState script
« Reply #2 on: July 06, 2023, 09:05:08 PM »
There's this nifty function in LSL3 that will revert changes like those Kawa mentioned. It's called NormalEgo if you're following the now public source, proc0_1 otherwise. Be aware that it messes with the handsOff state, so you'll need to call it before your (ProgramControl).

Offline Kawa

Re: changeState script
« Reply #3 on: July 07, 2023, 03:43:37 AM »
You also can't safely use it in the middle of a cutscene script, going from walking to bespoke animation, back to walking somewhere else. If you use NormalEgo there, you must go handsoff again. But if you know which character and view to use for walking, just reset the view and cycler yourself.

"And cycler" is the important part there.

Offline robbo007

Re: changeState script
« Reply #4 on: July 07, 2023, 05:56:28 PM »
There's this nifty function in LSL3 that will revert changes like those Kawa mentioned. It's called NormalEgo if you're following the now public source, proc0_1 otherwise. Be aware that it messes with the handsOff state, so you'll need to call it before your (ProgramControl).

I could never get handsOff and NormalEgo working with the normal SC template. I've seen it used in the LSL3 source. I was using ProgramControl to replace handsOff. I see that also Eric's de-compiled source uses it. What scripts do I need to load to use those syntax?


But if you know which character and view to use for walking, just reset the view and cycler yourself.

Could you give an example of resetting the view and cycler? I'll try and work it in then.

Offline Kawa

Re: changeState script
« Reply #5 on: July 07, 2023, 06:19:45 PM »
I could never get handsOff and NormalEgo working with the normal SC template. I've seen it used in the LSL3 source. I was using ProgramControl to replace handsOff. I see that also Eric's de-compiled source uses it. What scripts do I need to load to use those syntax?
For LSL3, the official code uses HandsOff and HandsOn from 000.sc. In the template game that'd be ProgramControl and PlayerControl in main.sc. Either case, script 0 exports 3 and 4.
Quote
Could you give an example of resetting the view and cycler? I'll try and work it in then.
(gEgo view: 700, setCycle: Walk), where 700 is fat Larry.


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

Page created in 0.033 seconds with 22 queries.