Began process to make the game more stable

This commit is contained in:
Tara 2022-12-25 12:39:58 -07:00
parent 7229f3381e
commit 97f0e4a475
4 changed files with 262 additions and 17 deletions

View file

@ -25,7 +25,7 @@ default
}else{ }else{
llListenRemove(genericListen); llListenRemove(genericListen);
genericListen = llListen(card_channel, "", "", ""); genericListen = llListen(card_channel, "", "", "");
llSay(0, "Card is trying to find a table"); //llSay(0, "Card is trying to find a table");
llListen(t, "", "", ""); llListen(t, "", "", "");
g_iStart=t; g_iStart=t;
llSay(card_channel, llList2Json(JSON_OBJECT, ["type", "alive", "boot", t])); llSay(card_channel, llList2Json(JSON_OBJECT, ["type", "alive", "boot", t]));

View file

@ -1,6 +1,8 @@
integer g_iStartParam; integer g_iStartParam;
key g_kUser; key g_kUser;
key g_kTable; key g_kTable;
key g_kActualTable;
integer DEBUG=FALSE;
integer card_channel = -32988199; integer card_channel = -32988199;
integer hud_channel = -328478727; integer hud_channel = -328478727;
@ -15,9 +17,13 @@ Cards(){
integer e = 10; integer e = 10;
integer CurCard = 1; integer CurCard = 1;
integer NCard = 0; integer NCard = 0;
if(DEBUG)llSay(0, "CARD LIST: "+llDumpList2String(g_lCards, " - "));
for(x=0;x<e;x++){ for(x=0;x<e;x++){
if(llGetListLength(g_lCards) > x){ if(llGetListLength(g_lCards) > x){
string card_params = llList2String(g_lCards,x); string card_params = llList2String(g_lCards,x);
if(DEBUG)llSay(0,"Card Parameters: "+card_params);
llMessageLinked(LINK_SET,0,llJsonGetValue(card_params,["text"]), "fw_data : card_text"+(string)CurCard); llMessageLinked(LINK_SET,0,llJsonGetValue(card_params,["text"]), "fw_data : card_text"+(string)CurCard);
} else { } else {
NCard++; NCard++;
@ -30,21 +36,25 @@ Cards(){
if(NCard>0){ if(NCard>0){
integer CardsToRequest = NCard; integer CardsToRequest = NCard;
if(CardsToRequest>0)CardsToRequest=1;
if(CardsToRequest == 0)return; if(CardsToRequest == 0)return;
else { else {
llRegionSayTo(g_kTable,hud_channel, llList2Json(JSON_OBJECT, ["type","card_request","count", CardsToRequest])); llOwnerSay("Drawing "+(string)CardsToRequest+" cards");
llRegionSayTo(g_kActualTable,hud_channel, llList2Json(JSON_OBJECT, ["type","card_request","count", CardsToRequest]));
} }
} }
} }
integer g_iVis=0;
POS(){ POS(){
if(!llGetAttached())return; if(!llGetAttached())return;
g_iVis=1;
vector local = <0.02395, 0.47113, -0.15166>; vector local = <0.02395, 0.47113, -0.15166>;
llSetPrimitiveParams([PRIM_POS_LOCAL, local]); llSetPrimitiveParams([PRIM_POS_LOCAL, local]);
} }
POS2(){ POS2(){
if(!llGetAttached())return; if(!llGetAttached())return;
g_iVis=0;
vector local = <0.02395, 1.77734, -0.15166>; vector local = <0.02395, 1.77734, -0.15166>;
llSetPrimitiveParams([PRIM_POS_LOCAL, local]); llSetPrimitiveParams([PRIM_POS_LOCAL, local]);
} }
@ -122,10 +132,12 @@ default
} }
listen(integer c,string n,key i,string m){ listen(integer c,string n,key i,string m){
if(DEBUG)llSay(0, m);
if(g_iStartParam == c){ if(g_iStartParam == c){
// listen for the UUID of who to attach the HUD to! // listen for the UUID of who to attach the HUD to!
if(llJsonGetValue(m,["type"])=="activate"){ if(llJsonGetValue(m,["type"])=="activate"){
g_kTable = (key)llJsonGetValue(m,["table"]); g_kTable = (key)llJsonGetValue(m,["table"]);
g_kActualTable = i;
llWhisper(0, "HUD now activating..."); llWhisper(0, "HUD now activating...");
key g_kUser = (key)llJsonGetValue(m, ["user"]); key g_kUser = (key)llJsonGetValue(m, ["user"]);
llRequestPermissions(g_kUser, PERMISSION_ATTACH); llRequestPermissions(g_kUser, PERMISSION_ATTACH);
@ -138,13 +150,16 @@ default
if(llGetListLength(g_lCards)<10 && llListFindList(g_lCards,[llJsonGetValue(m,["card"])])==-1){ if(llGetListLength(g_lCards)<10 && llListFindList(g_lCards,[llJsonGetValue(m,["card"])])==-1){
g_lCards += llJsonGetValue(m,["card"]); g_lCards += llJsonGetValue(m,["card"]);
s("Added card: "+llJsonGetValue(m,["card", "text"])); s("Added card: "+llJsonGetValue(m,["card", "text"]));
Cards();
} }
} }
} else if(llJsonGetValue(m,["type"]) == "select"){ } else if(llJsonGetValue(m,["type"]) == "select"){
if(g_kTable != (key)llJsonGetValue(m,["table"]))return;
if(llJsonGetValue(m,["czar"]) == (string)g_kUser){ if(llJsonGetValue(m,["czar"]) == (string)g_kUser){
s("You are the Card Czar, hiding the HUD"); s("You are the Card Czar, hiding the HUD");
POS2(); POS2();
g_iCanSelect=0; g_iCanSelect=0;
Cards();
} else { } else {
g_iSelectNum = (integer)llJsonGetValue(m,["sel_count"]); g_iSelectNum = (integer)llJsonGetValue(m,["sel_count"]);
POS(); POS();
@ -156,6 +171,7 @@ default
g_iCanSelect=1; g_iCanSelect=1;
} }
} else if(llJsonGetValue(m,["type"]) == "judging"){ } else if(llJsonGetValue(m,["type"]) == "judging"){
if(g_kTable != (key)llJsonGetValue(m,["table"]))return;
s("Judging begun. HUD hidden!"); s("Judging begun. HUD hidden!");
POS2(); POS2();
g_lSelected=[]; g_lSelected=[];
@ -167,7 +183,7 @@ default
g_iChan=0; g_iChan=0;
} }
} else if(llJsonGetValue(m,["type"])=="die"){ } else if(llJsonGetValue(m,["type"])=="die"){
llSay(0, "(DEBUG)\nm: "+m+"\n-> Table: "+(string)g_kTable+"\n-> User: "+(string)g_kUser); if(DEBUG)llSay(0, "(DEBUG)\nm: "+m+"\n-> Table: "+(string)g_kTable+"\n-> User: "+(string)g_kUser);
if(llJsonGetValue(m,["table"])==(string)g_kTable){ if(llJsonGetValue(m,["table"])==(string)g_kTable){
if(llJsonGetValue(m,["avatar"])==(string)g_kUser || llJsonGetValue(m,["avatar"])==(string)NULL_KEY || llJsonGetValue(m,["avatar"])==""){ if(llJsonGetValue(m,["avatar"])==(string)g_kUser || llJsonGetValue(m,["avatar"])==(string)NULL_KEY || llJsonGetValue(m,["avatar"])==""){
llSay(0, "Deactivating HUD"); llSay(0, "Deactivating HUD");
@ -193,6 +209,7 @@ default
integer CardNum = llList2Integer(g_lSelected, x); integer CardNum = llList2Integer(g_lSelected, x);
string CardQuery = llList2String(g_lCards, (CardNum-1)); string CardQuery = llList2String(g_lCards, (CardNum-1));
lToRemove += CardQuery; lToRemove += CardQuery;
CardQuery = llJsonSetValue(CardQuery, ["user"], g_kUser);
sActualCardData = llJsonSetValue(sActualCardData, [x], CardQuery); sActualCardData = llJsonSetValue(sActualCardData, [x], CardQuery);
} }
x=0; x=0;
@ -210,7 +227,7 @@ default
Highlight(); Highlight();
Cards(); Cards();
//llSay(0, "(DEBUG) Sending card(s) to table: "+sActualCardData); //llSay(0, "(DEBUG) Sending card(s) to table: "+sActualCardData);
llRegionSayTo(g_kTable, hud_channel, llList2Json(JSON_OBJECT, ["type", "cards", "cards", sActualCardData])); llRegionSayTo(g_kActualTable, hud_channel, llList2Json(JSON_OBJECT, ["type", "cards", "cards", sActualCardData]));
POS2(); POS2();
} }
} }
@ -232,7 +249,7 @@ default
attach(key id){ attach(key id){
if(id == NULL_KEY){ if(id == NULL_KEY){
llWhisper(0, "HUD is deactivating..."); llWhisper(0, "HUD is deactivating...");
llRegionSayTo(g_kTable, hud_channel, llList2Json(JSON_OBJECT, ["type", "leave", "avatar", g_kUser])); llRegionSayTo(g_kActualTable, hud_channel, llList2Json(JSON_OBJECT, ["type", "leave", "avatar", g_kUser]));
//llRemoveInventory(llGetScriptName()); //llRemoveInventory(llGetScriptName());
} else { } else {
g_kUser=id; g_kUser=id;
@ -306,7 +323,7 @@ state detach
state_entry(){ state_entry(){
integer i=0; integer i=0;
integer end = llGetNumberOfPrims(); integer end = llGetNumberOfPrims();
for(i=1;i<=end;i++){ for(i=2;i<=end;i++){
llSetLinkPrimitiveParamsFast(i,[PRIM_SIZE,ZERO_VECTOR,PRIM_POS_LOCAL,ZERO_VECTOR,PRIM_ROT_LOCAL,ZERO_ROTATION]); llSetLinkPrimitiveParamsFast(i,[PRIM_SIZE,ZERO_VECTOR,PRIM_POS_LOCAL,ZERO_VECTOR,PRIM_ROT_LOCAL,ZERO_ROTATION]);
} }
llSleep(2); llSleep(2);

View file

@ -6,6 +6,7 @@ integer card_channel = -32988199;
integer hud_channel = -328478727; integer hud_channel = -328478727;
list g_lPoints; list g_lPoints;
integer g_iStarted;
GiveUserPoint(key kUser){ GiveUserPoint(key kUser){
// point list - user, num of points // point list - user, num of points
integer index = llListFindList(g_lPoints,[kUser]); integer index = llListFindList(g_lPoints,[kUser]);
@ -16,10 +17,38 @@ GiveUserPoint(key kUser){
curPoint++; curPoint++;
g_lPoints=llListReplaceList(g_lPoints,[curPoint], index+1,index+1); g_lPoints=llListReplaceList(g_lPoints,[curPoint], index+1,index+1);
} }
UpScores();
} }
UpScores(){
integer i=0;
integer iScores;
integer end = llGetNumberOfPrims();
for(i=0;i<=end;i++){
string name = llGetLinkName(i);
if(name == "Scores"){
iScores=i;
jump outScore;
}
}
@outScore;
i=0;
end=llGetListLength(g_lPoints);
string sScores;
for(i=0;i<end;i+=2){
sScores += llKey2Name(llList2String(g_lPoints, i))+": "+llList2String(g_lPoints,i+1)+"\n";
}
llSetLinkPrimitiveParams(iScores, [PRIM_TEXT, sScores, <1,0,0>,1]);
}
list g_lJudgePile;
integer g_iTotalJudgeUsers;
string g_sVersion = "1.0.0.0000"; string g_sVersion = "1.0.0.0000";
key g_kToken; key g_kToken;
integer DEBUG = FALSE; integer DEBUG = FALSE;
float offset;
list g_lReqs; list g_lReqs;
string URL = "https://api.zontreck.dev/ls_bionics"; string URL = "https://api.zontreck.dev/ls_bionics";
Send(string Req,string method){ Send(string Req,string method){
@ -142,11 +171,14 @@ key g_kID;
integer g_iBlockRez = 0; integer g_iBlockRez = 0;
key g_kCurrentBlackCard; key g_kCurrentBlackCard;
list g_lPendingCards; list g_lPendingCards;
default default
{ {
state_entry() state_entry()
{ {
llSitTarget(ZERO_VECTOR,ZERO_ROTATION);
Chairs=[]; Chairs=[];
UpScores();
//llSay(0, "Activating Setup Mode"); //llSay(0, "Activating Setup Mode");
//llSay(0, "Scanning linkset for positions of prims"); //llSay(0, "Scanning linkset for positions of prims");
integer i=0; integer i=0;
@ -246,12 +278,13 @@ state active
g_iBlockRez=0; g_iBlockRez=0;
g_lPending=[]; g_lPending=[];
llSay(card_channel, llList2Json(JSON_OBJECT, ["type", "die", "table", g_kID]));
llListen(hud_channel, "", "", ""); llListen(hud_channel, "", "", "");
llListen(card_channel, "", "", "");/* llListen(card_channel, "", "", "");/*
integer chan = llRound(llFrand(548378)); integer chan = llRound(llFrand(548378));
g_lPendingCards += [chan, "null|black"]; g_lPendingCards += [chan, "null|black"];
llRezObject("Playing Card [LS]", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, chan);*/ llRezObject("Playing Card [LS]", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, chan);*/
llSitTarget(<0,0,1>, ZERO_ROTATION);
} }
http_response(key r,integer s,list m,string b){ http_response(key r,integer s,list m,string b){
@ -260,14 +293,16 @@ state active
g_lReqs = llDeleteSubList(g_lReqs,0,1); g_lReqs = llDeleteSubList(g_lReqs,0,1);
list lTmp = llParseString2List(b,[";;",";"],[]); list lTmp = llParseString2List(b,[";;",";"],[]);
if(DEBUG)llSay(0, "HTTP REPLY: "+b);
string Script = llList2String(lTmp,0); string Script = llList2String(lTmp,0);
if(Script == "Modify_Deck"){ if(Script == "Modify_Deck"){
llSay(0, "Deck generated!"); llSay(0, "Deck generated!");
} else if(Script == "Get_Card"){ } else if(Script == "Get_Card"){
key Sender = (key)llList2String(lTmp,1); key Sender = (key)llList2String(lTmp,1);
list Params = llJson2List(llBase64ToString(llList2String(lTmp,2)));//llParseString2List(llBase64ToString(llList2String(lTmp,2)), ["|"],[]); list Params = llJson2List(llBase64ToString(llList2String(lTmp,2)));
if(DEBUG)llSay(0, "HTTP REPLY: "+b);
if(DEBUG)llSay(0, "PARAMETER LIST: "+llList2CSV(Params)); if(DEBUG)llSay(0, "PARAMETER LIST: "+llList2CSV(Params));
//llParseString2List(llBase64ToString(llList2String(lTmp,2)), ["|"],[]);
integer i=0; integer i=0;
integer end = llGetListLength(Params); integer end = llGetListLength(Params);
for(i=0;i<end;i++){ for(i=0;i<end;i++){
@ -276,7 +311,7 @@ state active
integer num_req = (integer)llJsonGetValue(llList2String(Params,i),["num"]); integer num_req = (integer)llJsonGetValue(llList2String(Params,i),["num"]);
integer rezzed = (integer)llJsonGetValue(llList2String(Params,i), ["rezzed"]); integer rezzed = (integer)llJsonGetValue(llList2String(Params,i), ["rezzed"]);
if(rezzed==0) if(rezzed==0)
llRegionSayTo(Sender, hud_channel, llList2Json(JSON_OBJECT, ["type", "card", "avatar", llGetOwnerKey(Sender), "card", llList2Json(JSON_OBJECT, ["text", llList2String(Params,i)])])); llRegionSayTo(Sender, hud_channel, llList2Json(JSON_OBJECT, ["type", "card", "avatar", llGetOwnerKey(Sender), "card", llList2Json(JSON_OBJECT, ["text", llJsonGetValue(llList2String(Params,i), ["text"])])]));
else{ else{
if(color){ if(color){
g_kCurrentBlackCard = Sender; g_kCurrentBlackCard = Sender;
@ -292,11 +327,39 @@ state active
} }
key czar = llList2String(Players,g_iCzar); key czar = llList2String(Players,g_iCzar);
llRegionSay(hud_channel, llList2Json(JSON_OBJECT, ["type", "select", "czar", czar, "sel_count", num_req])); llSay(0, "Card Czar is: secondlife:///app/agent/"+(string)czar+"/about");
llRegionSay(hud_channel, llList2Json(JSON_OBJECT, ["type", "select", "czar", czar, "sel_count", num_req, "table", g_kID]));
} }
llRegionSayTo(Sender, card_channel, llList2Json(JSON_OBJECT, ["type", "set", "card", llList2Json(JSON_OBJECT, ["text", card_text, "color", color, "num", num_req])])); llRegionSayTo(Sender, card_channel, llList2Json(JSON_OBJECT, ["type", "set", "card", llList2Json(JSON_OBJECT, ["text", card_text, "color", color, "num", num_req, "czar", llList2String(Players,g_iCzar), "user", llList2String(lTmp,3)])]));
} }
} }
} else if(Script == "Modify_Card"){
string Sender = llList2String(lTmp,6);
string Color = llList2String(lTmp,2);
string Text = llBase64ToString(llList2String(lTmp,3));
integer num = llList2Integer(lTmp,4);
string user = llList2String(lTmp,5);
if(DEBUG)llSay(0, "SEARCH RESULT: "+Text);
} else if(Script == "No More Cards"){
llSay(0, "Game over! No more black cards exist in the deck... Checking for winner...");
integer iLastHigh;
key kLastHigh;
integer x=0;
integer xe = llGetListLength(g_lPoints);
for(x=0;x<xe;x++){
key User = llList2Key(g_lPoints,x);
integer points = llList2Integer(g_lPoints,x+1);
if(points>iLastHigh){
iLastHigh=points;
kLastHigh = User;
}
}
llSay(0, "WINNER IS: secondlife:///app/agent/"+(string)kLastHigh+"/about with "+(string)iLastHigh+" points total!!");
llResetScript();
} }
@ -324,24 +387,62 @@ state active
llRegionSayTo(i,llList2Integer(g_lPending,index+1), llList2Json(JSON_OBJECT, ["type", "activate", "user", llList2String(g_lPending,index), "table", g_kID])); llRegionSayTo(i,llList2Integer(g_lPending,index+1), llList2Json(JSON_OBJECT, ["type", "activate", "user", llList2String(g_lPending,index), "table", g_kID]));
g_lPending = llDeleteSubList(g_lPending, index,index+1); g_lPending = llDeleteSubList(g_lPending, index,index+1);
} }
} else if(llJsonGetValue(m,["type"]) == "cards"){
list lCards = llJson2List(llJsonGetValue(m,["cards"]));
g_lJudgePile += lCards;
g_iTotalJudgeUsers++;
if(g_iTotalJudgeUsers == llGetListLength(Players)-1){
llSay(hud_channel, llList2Json(JSON_OBJECT, ["type", "judging", "table", g_kID]));
llSay(0, "Card Czar: Pick the card you want!");
// Initiate the rezzing procedure
integer x =0;
integer e = llGetListLength(g_lJudgePile);
for(x=0;x<e;x++){
integer bootNum = llRound(llFrand(34857483));
string json = llList2String(g_lJudgePile, x);
key user = llJsonGetValue(json, ["user"]);
g_lPendingCards += [bootNum, (string)user+"|"+llJsonGetValue(json,["text"])];
llRezObject("Playing Card [LS]", llGetPos(), ZERO_VECTOR,ZERO_ROTATION, bootNum);
}
}
} }
} else if(c==card_channel){ } else if(c==card_channel){
if(llJsonGetValue(m,["type"])=="alive"){ if(llJsonGetValue(m,["type"])=="alive"){
llSay(0, "IN ALIVE BLOCK"); //llSay(0, "IN ALIVE BLOCK");
integer index = llListFindList(g_lPendingCards,[(integer)llJsonGetValue(m,["boot"])]); integer index = llListFindList(g_lPendingCards,[(integer)llJsonGetValue(m,["boot"])]);
if(index==-1){ if(index==-1){
return; return;
} }
string pendingCommand = llList2String(g_lPendingCards,index+1);
list lCmd = llParseString2List(pendingCommand, ["|"],[]);
g_lPendingCards = llDeleteSubList(g_lPendingCards,index,index+1); g_lPendingCards = llDeleteSubList(g_lPendingCards,index,index+1);
llRegionSayTo(i, (integer)llJsonGetValue(m,["boot"]), llList2Json(JSON_OBJECT, ["type", "activate", "table", g_kID])); llRegionSayTo(i, (integer)llJsonGetValue(m,["boot"]), llList2Json(JSON_OBJECT, ["type", "activate", "table", g_kID]));
// Calculate position offset // Calculate position offset
llSleep(1); llSleep(1);
llRegionSayTo(i, card_channel, llList2Json(JSON_OBJECT, ["type", "position", "pos", llGetPos()+<0,0,0.5>])); if(llList2String(lCmd,0) == "null"){
offset = 0.0;
}
llRegionSayTo(i, card_channel, llList2Json(JSON_OBJECT, ["type", "position", "pos", llGetPos()+<0,offset,0.75>]));
if(DEBUG)llSay(0, "Alive request on the Cards Channel: "+m); if(DEBUG)llSay(0, "Alive request on the Cards Channel: "+m);
Send("/Modify_Card.php?TYPE_OVERRIDE=GET_CARD&TABLE_ID="+(string)g_kID+"&COLOR=1&DRAW_COUNT=1&SENDER="+(string)i+"&REZZED=1", "POST");
string color = "1";
offset += 0.25;
string cmd= "GET_CARD";
if(llList2String(lCmd,1) != "black"){
//cmd = "SEARCH&CARD_TEXT="+llStringToBase64(llList2String(lCmd,1))+"&AVATAR="+llList2String(lCmd,0);
color="0";
llRegionSayTo(i, card_channel, llList2Json(JSON_OBJECT, ["type", "set","card", llList2Json(JSON_OBJECT, ["text", llList2String(lCmd,1), "color", 0, "num", 0, "czar", llList2String(Players, g_iCzar), "user", llList2String(lCmd,0)])]));
return;
}
Send("/Modify_Card.php?TYPE_OVERRIDE="+cmd+"&TABLE_ID="+(string)g_kID+"&COLOR="+color+"&DRAW_COUNT=1&SENDER="+(string)i+"&REZZED=1", "POST");
} else if(llJsonGetValue(m,["type"]) == "final"){ } else if(llJsonGetValue(m,["type"]) == "final"){
key kUser = (key)llJsonGetValue(m,["user"]); key kUser = (key)llJsonGetValue(m,["user"]);
@ -351,6 +452,19 @@ state active
llSay(card_channel, llList2Json(JSON_OBJECT, ["type", "die", "table", g_kID])); llSay(card_channel, llList2Json(JSON_OBJECT, ["type", "die", "table", g_kID]));
// Start next round! // Start next round!
// Load the next black card to trigger selection mode // Load the next black card to trigger selection mode
integer boot = llRound(llFrand(5483758));
g_lPendingCards += [boot, "null|black"];
integer x =0;
integer ends = llGetListLength(g_lJudgePile);
g_iTotalJudgeUsers = 0;
for(x=0;x<ends;x++){
string card = llList2String(g_lJudgePile,x);
Send("/Modify_Card.php?TYPE_OVERRIDE=INSERT&TABLE_ID="+(string)g_kID+"&CARD_TEXT="+llStringToBase64(llJsonGetValue(card,["text"])), "POST");
}
g_lJudgePile=[];
llRezObject("Playing Card [LS]", llGetPos(), ZERO_VECTOR,ZERO_ROTATION,boot);
} }
} else if(llListFindList(g_lListener,[c])!=-1){ } else if(llListFindList(g_lListener,[c])!=-1){
integer index = llListFindList(g_lListener,[c]); integer index = llListFindList(g_lListener,[c]);
@ -379,14 +493,21 @@ state active
llResetScript(); llResetScript();
} }
timer(){
Sends();
}
touch_start(integer t){ touch_start(integer t){
string name = llGetLinkName(llDetectedLinkNumber(0)); string name = llGetLinkName(llDetectedLinkNumber(0));
if(name == "START"){ if(name == "START"){
if(g_iStarted)return;
g_iStarted=TRUE;
if(!(llGetListLength(Players) > 1)){ if(!(llGetListLength(Players) > 1)){
llSay(0, "Must have more than 1 player to start!"); llSay(0, "Must have more than 1 player to start!");
return;
} }
// Begin the game loop // Begin the game loop
llSetTimerEvent(5);
integer chan = llRound(llFrand(548378)); integer chan = llRound(llFrand(548378));
g_lPendingCards += [chan, "null|black"]; g_lPendingCards += [chan, "null|black"];
llRezObject("Playing Card [LS]", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, chan); llRezObject("Playing Card [LS]", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, chan);
@ -398,6 +519,11 @@ state active
llDialog(i, "Are you male or female?", ["Female", "Male"], rnd); llDialog(i, "Are you male or female?", ["Female", "Male"], rnd);
llRequestPermissions(i, PERMISSION_TRIGGER_ANIMATION); llRequestPermissions(i, PERMISSION_TRIGGER_ANIMATION);
} else if(name == "STOP"){
if(g_iStarted){
Send("/Modify_Card.php?TYPE_OVERRIDE=NULCARD&TABLE_ID="+(string)g_kID,"GET");
llSay(0, "Stopping the game please wait...");
}
} }
} }
} }

102
SOURCE/LSL/UserCard.lsl Normal file
View file

@ -0,0 +1,102 @@
string g_sPath;
integer g_iColor;
integer g_iNum;
string g_sText;
key g_kAuthor;
integer g_iChan;
integer g_iLstn;
default
{
state_entry()
{
llMessageLinked(LINK_SET,0,"","fw_reset");
}
changed(integer x){
if(x&CHANGED_REGION_START){
llResetScript();
}
}
on_rez(integer t){
if(t == 0){
llResetScript();
}
}
link_message(integer s,integer n,string m,key i){
if(n==0){
if(i=="fw_ready"){
g_sPath = "/";
llMessageLinked(LINK_SET,0,"c=black", "fw_conf : card_text");
llMessageLinked(LINK_SET,0,"c=black", "fw_conf : card_helpertext");
llSetLinkColor(LINK_ROOT, <1,1,1>, 0);
llSetLinkColor(LINK_ROOT, <1,1,1>, 1);
g_iChan = llRound(llFrand(54738577));
g_iLstn = llListen(g_iChan, "", llGetOwner(), "");
llDialog(llGetOwner(), "[Playing Card]\n\nIs this card supposed to be a black card or a white card?", ["White", "Black"], g_iChan);
}
}
}
listen(integer c,string n,key i,string m){
if(g_sPath == "/"){
if(m == "White"){
g_iColor=0;
llMessageLinked(LINK_SET,0,"Cards Against Humanity", "fw_data : card_helpertext");
llTextBox(llGetOwner(), "[Playing Card]\n\nWhat text should be on the card?", g_iChan);
g_sPath = "/text";
} else if(m == "Black"){
g_iColor=1;
llMessageLinked(LINK_SET,0,"c=white","fw_conf : card_text");
llMessageLinked(LINK_SET,0,"c=white","fw_conf : card_helpertext");
llSetLinkColor(LINK_ROOT,<0.2,0.2,0.2>,1);
llSetLinkColor(LINK_ROOT,<0.2,0.2,0.2>,0);
g_sPath = "/num_req";
llDialog(llGetOwner(), "[Playing Card]\n\nHow many cards do you want to require the player to draw?", ["1","2", "3","4","5","6","7","8","9","10"], g_iChan);
}
} else if(g_sPath == "/text"){
llMessageLinked(LINK_SET,0,m,"fw_data : card_text");
g_sText = m;
g_sPath = "/confirm";
llDialog(llGetOwner(), "Does this card look correct?\n\nIf you select yes, your card will be uploaded to the community deck for this year. If you decide you no longer wish your card to be uploaded, you will need to contact LS Bionics Support", ["Yes", "No"], g_iChan);
} else if(g_sPath == "/num_req"){
g_iNum = (integer)m;
g_sPath = "/text";
if(g_iNum == 1){
llMessageLinked(LINK_SET,0,"Cards Against Humanity", "fw_data : card_helpertext");
}else llMessageLinked(LINK_SET,0,"Pick ("+(string)g_iNum+")\nDraw ("+(string)g_iNum+")", "fw_data : card_helpertext");
llTextBox(llGetOwner(), "What text do you want on this card?", g_iChan);
} else if(g_sPath == "/confirm"){
if(m == "Yes"){
llSay(0, "Uploading card...");
list dat = llParseString2List(llGetDate(),["-"],[]);
llSetObjectName("CAH: "+llList2String(dat,0)+" Playing Card [LS]");
llSetObjectDesc("Card created by: "+llKey2Name(llGetOwner()));
g_kAuthor = llGetOwner();
string CARD_ID = (string)llGetOwner()+"-"+(string)llGetUnixTime();
llHTTPRequest("https://api.zontreck.dev/ls_bionics/Modify_Card.php", [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], "DECK="+llList2String(dat,0)+"&CARD_TEXT="+llStringToBase64(g_sText)+"&COLOR="+(string)g_iColor+"&DRAW_COUNT="+(string)g_iNum+"&CARD_ID="+llEscapeURL(CARD_ID));
state myCard;
} else if(m == "No"){
llSay(0, "Card creation cancelled! Deleting temp data");
llResetScript();
}
}
}
}
state myCard
{
state_entry(){
llRemoveInventory("FURWARE text v2.0.1");
llSay(0, "You now have the only permanent physical copy of this card on the grid as you are the card's creator!");
llSay(0, "You can play with this card if you have this year's community deck purchased.");
llSay(0, "NOTE: If you decide to remove this card from play in the community deck, you will need to send this physical card object to the LS support representative.");
llSay(0, "(This card is now read-only. The required script for modification of the mesh text has been removed)");
}
touch_start(integer t){
llSay(0, "/me created by secondlife:///app/agent/"+(string)g_kAuthor+"/about");
}
}