✅ [Added] Core Gameplay Logic Turn-based number picking based on each player's remaining lives. Dice roll system for the "peril" player via dialog prompt. Automated peril player advancement and elimination for 0-life players. Round transition system fully implemented. ⏱️ [Added] AFK Timeout System 10-minute inactivity timer with: Warnings at 2, 5, and 9 minutes. Auto-elimination after 10 minutes. 🔐 [Improved] Game Rules & Integrity Blocked new players from joining once the game begins. Implemented "Ready Check" for all players before start. Enforced unique global number picks per round. 🛠️ [Added] Admin Tools Owner-only debug dialog for: Adding/removing test players. Starting/resetting the game. Testing dialogs and player picks. "Leave Game" options for owner and all participants. 🔧 [Fixed] Syntax & Structural Issues Resolved: Mismatched braces and block closures. Type mismatches (e.g., timeoutTimer). Improper llParseString2List usage. Stray placeholders like $1. Removed redundant code and validated logic flow. 🧱 [Refactored] Function Structure Renamed updatePlayerPick() to handlePlayerPick() for clarity. Ensured all functions declare return types and include return 0; as required. Declared variables at top for readability and compliance. 🔁 [Modularized] Code Architecture Split pick dialog logic into Pick Dialog Handler script. Created Roll Dialog Handler and merged into Roll and Confetti Module. Replaced direct llDialog() calls with link messages for modularity. 🔗 [Integrated] Messaging & Effects Main controller now uses MSG_SHOW_ROLL_DIALOG via link message. Confetti effects tied to peril player elimination. All dialog interactions now routed through modular link messaging. 🧪 [Tested & Validated] Game Flow Verified: Player joins/leaves. Pick dialog with correct life-based limits (3L=1, 2L=2, 1L=3). Dice roll outcomes and peril transitions. Game reset and round restart functionality. Implemented game state serialization and syncing. ⚙️ [Fixed] Loop & Variable Issues Replaced reused loop variables (i, j) with unique names (loopI, loopJ, etc.). Fixed broken loop logic and conditional scoping issues. 🧹 [Cleanup] Code Hygiene Removed duplicate function definitions. Ensured consistent naming and formatting across all modules. Resolved scoping errors (e.g., ownerKey issue). ✅ [Current Status] Scripts compile without errors. All modules function as intended. System ready for in-world testing.
50 lines
1.6 KiB
Text
50 lines
1.6 KiB
Text
// === Dialog Handler (Updated for Peril Dice) ===
|
|
|
|
integer MSG_SHOW_DIALOG = 101;
|
|
integer numberPickChannel = -77888;
|
|
|
|
list getDialogButtons(integer diceType) {
|
|
list buttons = [];
|
|
integer i;
|
|
for (i = 1; i <= diceType; i++) {
|
|
buttons += [(string)i];
|
|
}
|
|
return buttons;
|
|
}
|
|
|
|
showPickDialog(string name, key id, integer diceType) {
|
|
if (diceType <= 0) {
|
|
llOwnerSay("⚠️ Cannot show dialog: diceType is 0 or invalid.");
|
|
return;
|
|
}
|
|
|
|
list options = getDialogButtons(diceType);
|
|
llOwnerSay("🗨️ Showing dialog to: " + name);
|
|
llOwnerSay("📋 Page: 0, DiceType: " + (string)diceType);
|
|
llOwnerSay("🔢 Options: " + llList2CSV(options));
|
|
llDialog(id, "Choose a number (1 - " + (string)diceType + "):", options, numberPickChannel);
|
|
}
|
|
|
|
default {
|
|
state_entry() {
|
|
llListen(numberPickChannel, "", NULL_KEY, "");
|
|
}
|
|
|
|
link_message(integer sender, integer num, string str, key id) {
|
|
if (num == MSG_SHOW_DIALOG) {
|
|
list parts = llParseString2List(str, ["|"], []);
|
|
if (llGetListLength(parts) < 2) {
|
|
llOwnerSay("⚠️ Malformed MSG_SHOW_DIALOG input: " + str);
|
|
return;
|
|
}
|
|
|
|
string name = llList2String(parts, 0);
|
|
integer diceType = (integer)llList2String(parts, 1);
|
|
showPickDialog(name, id, diceType);
|
|
}
|
|
}
|
|
|
|
listen(integer channel, string name, key id, string message) {
|
|
llOwnerSay("🔊 Listen triggered on channel: " + (string)channel + ", msg: " + message + ", from: " + name + " (" + (string)id + ")");
|
|
}
|
|
}
|