1. (define nearWood (& (ego onControl) cBrown)) doesn't work in SCI Companion because it, as opposed to Sierra's in-house compiler, can only handle single values. So wherever you see nearWood in the code later on, you must substitute in (& (ego onControl) cBrown) yourself.
2. Enums are fine, yeah, but this part is really just confusing the matter because of the whole "dissolving credits" and "plot explanation popup" thing. I suggest you ignore it. They are, in the end, just names for numbers of increasing value.
3. InRoom is a function from the Main script to save effort in determining if a specific inventory item has the current room set as its owner. Note that inventory items do not visually appear in their owner rooms. It's aWood that visually represents the granadilla when you haven't picked it up yet. So if InRoom says the granadilla is still in this jungle path, it knows to A) preload the animation of Larry picking it up so that GET WOOD doesn't cause a sudden load delay, and B) initialize aWood, making it appear.
4. When you type GET WOOD, it first checks if you're close enough (nearWood comes in here) and if so, sets the room script's state to getIt (4).
4.1. The room script, when it reaches that state (which can only happen when you try to take the wood because state 3 halts at the end) will take away your controls and tell Larry to move into position in an intricate way to allow him to take the wood from either the left or right. Larry, that is ego, will call back to the room script (self) when he's there, causing state 5, atIt to run.
4.2. Larry is told to play the stooping animation, facing the right way, and call back again. This causes the room script to reach state 6, DrBenDover.
4.3. aWood is hidden from view and the stooping animation is played in reverse. Finishing this animation causes the script to reach its final state, getDone.
4.4. "You take the beautiful chunk of granadilla wood from beneath the tree." and get two points. Reset Larry to normal operation with the NormalEgo function from the main script, which also restores user control.
Here's an example from my own game, in SCI 1.1+.
(instance aPuddle of cdFeature
;...
(verbs
(V_LOOK
; some irrelevant stuff to either say one thing or the other depending on you having checked the puddle up close.
(V_DO
(if (Btst fDayOnePuddleChecked)
; say you've already done that.
else
(Bset fDayOnePuddleChecked) ; remember having checked the puddle.
(curRoom setScript: InspectPuddleScript)
)
)
)
)This part is analogous to said checks in your room script's handleEvent. If we clicked the hand cursor on the puddle and haven't done so before, set the room's script to InspectPuddleScript/tt]. This is unlike what the jungle path in LSL3 did, having a single script for both the credits and plot, and picking up the granadilla wood.
(instance InspectPuddleScript of Script
(method (changeState newState)
(switchto (= state newState)
(
(HandsOff)
(ego setMotion: PolyPath 100 160 self)
)
(
(ego view: vSpecific loop: lTastePuddle cel: 0 setCycle: EndLoop self)
)
(
(Score 20)
; "Yup, that's water alright. Which can mean only one thing!"
)
(
(ego cel: cCrouched setCycle: BegLoop self)
)
(
(ego view: 0 loop: 8 cel: 1 resetCycler:)
; Warning: I'm not too sure if this is correct.
(curRoom setScript: RoomScript)
)
)
)
)Basically, we make a little cutscene. Take away the player's control so we can't horribly break everything, then have our main character smartly move over next to the puddle. We don't do anything like Larry taking the wood from either direction, we always lick it from the right.