🎯 Refactored the Game Architecture
We modularized the original Peril Dice controller into separate cohesive components:
Main Peril Dice Controller
Handles core logic: player join/leave, peril selection, game sync, and communication routing.
Broadcasts updates via MSG_SYNC_GAME_STATE after major state changes.
Applies llSleep(0.2) to improve message delivery reliability.
Dialog Handler Module
Manages the number-picking dialog.
Tracks player picks and updates picksData accordingly.
Sends state sync after every valid pick.
Fixed pick serialization bugs and ensured updates trigger correctly.
Float Rezzer Module
Registers player data and rezzes a StatFloat object beside each participant.
Applies llSetObjectDesc(name); before rezzing for easier identification.
On update, broadcasts llRegionSay messages including current lives, peril, and picks.
StatFloat (HUD Script)
Listens on assigned channel to receive floating text updates.
Parses synced game state from link_message to extract lives, picks, and peril data.
Dynamically follows the avatar.
Enhanced parsing reliability and fixed index mapping for correct player display.
Roll and Confetti Module
Performs dice rolls and checks for matches.
Transfers peril role on match or removes a life otherwise.
Triggers confetti on a miss and updates floats for all players.
🛠 Debugging and Enhancements
Added llOwnerSay debug statements across all modules.
Resolved multiple name not defined within scope (nndws) issues.
Verified and cleaned up serialized game data formats across modules.
Ensured consistent use of player indexing and life count mapping.
Sequential Player Picking Logic
Players now pick in order starting with the peril player.
Number of picks is determined by the peril player’s current lives.
Picks are tracked globally to prevent duplicates.
Dynamic Dice Type Adjustment
Dice size (diceType) now adjusts based on player count:
1–2 players = 6
3–4 players = 12
5–6 players = 18, etc.
Prompt for Dice Roll
After all players have made their picks, the peril player is prompted to roll via a dialog.
Dice Roll Resolution Logic
If another player matches the roll, they become the new peril player.
If no one matches or the peril player matches, the peril player loses a life.
🔄 Fixes & Improvements
Fixed syntax and scoping errors (resultStr, newPeril, and timer logic).
Prevented duplicate rezzing of StatFloat objects.
Restored and ensured 🔢 Picks: are shown on the floating stat displays.
Updated floaters dynamically after each pick using llSetTimerEvent.