Peril_Dice/Debugger.lsl
RebeccaNod1 89a364d2ec Summary of Today’s Work:
Issue Identified:

The main issue was that the floater was showing 0 as the player's pick even after they made a selection, and the correct pick was not being reflected in the float.

Steps Taken:

Improved Data Synchronization: We ensured that the picksData list, which holds player choices, was properly updated and synchronized across all parts of the system.

State Serialization: The game state, including updated picksData, was serialized correctly using the serializeGameState() function. This ensured that the floater was aware of the new state whenever a player's pick changed.

Immediate Float Updates: After updating a player's pick, we immediately sent the new game state (gameSync) to all linked objects to update their floats, ensuring the pick was reflected in the UI.

Key Modifications:

Main Peril Dice Controller: We improved the way we updated picksData and immediately synchronized this update with the floater using MSG_SYNC_GAME_STATE.

StatFloat: Adjustments were made to handle receiving and displaying updated pick data, ensuring that picks were displayed correctly on the float after each update.

Dialog Handling: Proper dialogs were shown to players for pick choices, and feedback on their picks was sent back to update the floats in real-time.

Outcome:

The game now correctly updates and displays the player’s picks on their respective floats immediately after making a choice.

The picks are reflected in the logs as well, with the correct updated pick being shown rather than 0.

Final Result:

The issue of picks not being displayed correctly has been resolved, and the flow of data between the scripts (game state synchronization, float updates, etc.) is working as intended.
2025-07-26 03:52:29 -05:00

78 lines
2.6 KiB
Text

integer MSG_SYNC_GAME_STATE = 107;
list validatePicksData(list picksData, list names) {
list allPicksFlat = [];
integer i;
for (i = 0; i < llGetListLength(picksData); i++) {
string entry = llList2String(picksData, i);
list parts = llParseString2List(entry, ["|"], []);
if (llGetListLength(parts) == 2) {
string name = llList2String(parts, 0);
string picks = llList2String(parts, 1);
list pickNums = llParseString2List(picks, [","], []);
// Check if name is in names list
if (names != [] && llListFindList(names, [name]) == -1) {
llOwnerSay("⚠️ picksData name not in names list: " + name);
}
// Check for duplicate picks in this player's list
integer j;
list uniqueCheck = [];
for (j = 0; j < llGetListLength(pickNums); j++) {
string pick = llList2String(pickNums, j);
if ((string)((float)pick) != pick) {
llOwnerSay("⚠️ Invalid number in picks for " + name + ": '" + pick + "'");
}
if (~llListFindList(uniqueCheck, [pick])) {
llOwnerSay("🚨 Duplicate pick in " + name + "'s picks: " + pick);
} else {
uniqueCheck += [pick];
}
allPicksFlat += [pick];
}
llOwnerSay("✅ " + name + "'s picks: " + llList2CSV(pickNums));
} else {
llOwnerSay("⚠️ Malformed entry in picksData: " + entry);
}
}
// Check for duplicate picks across all players
list seen = [];
integer k;
for (k = 0; k < llGetListLength(allPicksFlat); k++) {
string val = llList2String(allPicksFlat, k);
if (~llListFindList(seen, [val])) {
llOwnerSay("❌ Duplicate pick across players: " + val);
} else {
seen += [val];
}
}
return picksData;
}
default {
link_message(integer sender, integer num, string str, key id) {
if (num == MSG_SYNC_GAME_STATE) {
list parts = llParseString2List(str, ["~"], []);
if (llGetListLength(parts) < 4) {
llOwnerSay("⚠️ Incomplete game state received.");
return;
}
list lives = llCSV2List(llList2String(parts, 0));
list picksData = llCSV2List(llList2String(parts, 1));
string perilPlayer = llList2String(parts, 2);
list names = llCSV2List(llList2String(parts, 3));
llOwnerSay("🔍 Checking picksData...");
validatePicksData(picksData, names);
}
}
}