Treetrunkpalm
Module: treetrunkpalm.lua
Overview
The Treetrunkpalm module plays a material animation on a palm tree trunk when it enters a fire state ("FireDebrisState" or "FireDestroyedState"), giving it the charred/debris look. Two functions, one deferred animation.
It is functionally the same script as treetrunk β the palm version just uses a different animation name (global_env_treepalm_anim vs. global_env_treeplaza03_anim) and adds a leftover Debug.Printf. If youβre editing both, keep them in sync.
Inheritance
- Inherits from:
none β base/utility module - Imports:
none
Instance pattern
This is a stateless utility module with no per-instance pattern. It does not track any persistent state.
Functions
OnStateChange(uiGuid, uiNodeHashName, uiStateHashName)
Engine lifecycle callback. Compares uiStateHashName against String.GetHash("FireDebrisState") and String.GetHash("FireDestroyedState") (it hashes the state name strings and compares hashes). On a match it schedules _PlayMaterialAnims via Event.ObjectIsReady. uiNodeHashName is unused.
_PlayMaterialAnims(uiGuid)
Calls Object.PlayMaterialAnimation(uiGuid, "global_env_treepalm_anim", false) (non-looping), then prints a debug line ("im playing the palm material anim") β engine-log noise, no gameplay effect. This debug print is the only code difference from treetrunk.
Events
Event.ObjectIsReady(inOnStateChange, viaEvent.Create) β the onlyEvent.*call in this file. Schedules_PlayMaterialAnimsto run once the object reports ready, after a matching state change is detected.OnStateChangeitself is not registered throughEvent.Createin this file β noEvent.ObjectStateChange(or similarly named constant) appears anywhere in the source. Itβs invoked directly by the engine as a naming-convention callback on the world-object script, the same wayOnActivate/OnDeathare called on other modules.
Module constants & tunables
- Trigger states:
"FireDebrisState"and"FireDestroyedState"(compared as hashes viaString.GetHash). - Material animation:
"global_env_treepalm_anim", played once (non-looping).
Notes for modders
- Change the animation by editing the
"global_env_treepalm_anim"string; change when it plays by editing the two state names inOnStateChange. - The animation is deferred with
Event.ObjectIsReadyβ donβt move it inline intoOnStateChange, the object may not be ready to animate the instant its state flips. - The
Debug.Printfhere is harmless leftover; it only writes to the log. See the siblingtreetrunkfor the non-palm variant.