diff --git a/SOURCE/LSL/Card.lsl b/SOURCE/LSL/Card.lsl index 1f14365..444c6c3 100644 --- a/SOURCE/LSL/Card.lsl +++ b/SOURCE/LSL/Card.lsl @@ -1,6 +1,7 @@ integer card_channel = -32988199; +string g_sText; integer g_iStart; key g_kTable; integer genericListen = -1; @@ -35,6 +36,7 @@ default touch_start(integer t){ if(llDetectedKey(0) == g_kCzar){ if(!g_iConfirm){ + llWhisper(0, g_sText); llSay(0, "Touch this card again to confirm you want to select this card as winner for this round!"); llSetColor(<0,1,0>,2); llSetTexture(TEXTURE_BLANK, 2); @@ -90,7 +92,10 @@ default llSetLinkColor(LINK_ROOT, <1,1,1>,0); llMessageLinked(LINK_SET,0,"c=black", "fw_conf"); } - + g_sText=text; + if(llStringLength(text)>128){ + llSay(0, text); + } llMessageLinked(LINK_SET,0,text, "fw_data : card_text"); if(num > 1){ diff --git a/SOURCE/LSL/Deck.lsl b/SOURCE/LSL/Deck.lsl new file mode 100644 index 0000000..44b24a6 --- /dev/null +++ b/SOURCE/LSL/Deck.lsl @@ -0,0 +1,27 @@ + +integer ingredient_channel = -8392888; + +default +{ + state_entry() + { + llListen(ingredient_channel, "", "", ""); + llSetText("Deck of Cards\n-----\nQuantity: 1", <0,1,0>,1); + } + + touch_start(integer t){ + llSay(0, llGetObjectDesc()+" Deck of Cards; Quantity: 1"); + } + + on_rez(integer t){ + llResetScript(); + } + + listen(integer c,string n,key i,string m){ + if(m == "scan"){ + llSay(c+1, "Deck"); + }else if(m == (string)llGetKey()){ + llDie(); + } + } +} diff --git a/SOURCE/LSL/DeckHandler.lsl b/SOURCE/LSL/DeckHandler.lsl new file mode 100644 index 0000000..ff39357 --- /dev/null +++ b/SOURCE/LSL/DeckHandler.lsl @@ -0,0 +1,186 @@ +list g_lSelectedDecks= ["OFFICIAL",1]; +DecksMenu(key id){ + integer i=0; + list Buttons = []; + string Prompt; + integer end = llGetListLength(g_lSelectedDecks); + for(i=0;i; s(string m){ llInstantMessage(g_kUser,m); } list g_lCards; Cards(){ + if(!llGetAttached())return; integer x = 0; integer e = 10; integer CurCard = 1; @@ -25,6 +27,10 @@ Cards(){ 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); + + if(llStringLength(llJsonGetValue(card_params,["text"]))>128){ + s("Card "+(string)x+": "+llJsonGetValue(card_params,["text"])); + } } else { NCard++; llMessageLinked(LINK_SET,0,"", "fw_data : card_text"+(string)CurCard); @@ -48,7 +54,7 @@ integer g_iVis=0; POS(){ if(!llGetAttached())return; g_iVis=1; - vector local = <0.02395, 0.47113, -0.15166>; + vector local = g_vLastPos1; llSetPrimitiveParams([PRIM_POS_LOCAL, local]); } @@ -56,39 +62,40 @@ POS2(){ if(!llGetAttached())return; g_iVis=0; vector local = <0.02395, 1.77734, -0.15166>; - llSetPrimitiveParams([PRIM_POS_LOCAL, local]); + if(llVecDist(llGetLocalPos(),local)>1){ + g_vLastPos1 = llGetLocalPos(); + llSetPrimitiveParams([PRIM_POS_LOCAL, local]); + } } list g_lSelected = []; +list g_lActualCards = [1, 2, + 2, 23, + 3, 44, + 4, 65, + 5, 86, + 6, 107, + 7, 128, + 8, 149, + 9, 170, + 10, 191 + ]; Highlight(){ - integer i=1; - integer end = 10; - for(i=1;i<=end;i++){ - if(llListFindList(g_lSelected,[i])==-1){ - integer x=0; - integer end2 = llGetNumberOfPrims(); - for(x=1;x<=end2;x++){ - string LinkName = llGetLinkName(x); - if(LinkName=="Card"+(string)i){ - llSetLinkColor(x, <1,1,1>, 2); - jump stopFor; - } - } - @stopFor; + integer i=0; + integer end = llGetListLength(g_lActualCards); + for(i=0;i, 2); + //llSay(0, "set "+llList2String(g_lActualCards,i+1)+" to white on face 2"); } else { - integer x = 0; - integer end2 = llGetNumberOfPrims(); - for(x=1;x<=end2;x++){ - string LinkName = llGetLinkName(x); - if(LinkName == "Card"+(string)i){ - llSetLinkColor(x,<0,1,0>,2); - jump stopFor2; - } - } - @stopFor2; + //llSay(0, "number : "+(string)llList2Integer(g_lActualCards,i)+" found in selected card list."); + llSetLinkColor(llList2Integer(g_lActualCards,i+1), <0,1,0>, 2); + //llSay(0, "set "+llList2String(g_lActualCards,i+1)+" to green on face 2"); } } + } integer g_iSelectNum=0; @@ -117,6 +124,7 @@ default g_kUser=llGetOwner(); g_kTable = llGetOwner(); + //g_lSelected = [5, 7, 1]; Highlight(); } @@ -238,6 +246,8 @@ default if(g_iCanSelect){ llMessageLinked(LINK_SET,0,llGetLinkName(llDetectedLinkNumber(0)),"fw_touchquery : "+(string)llDetectedLinkNumber(0) + ":" + (string)llDetectedTouchFace(0)); }else s("You can't select a card right now"); + + if(DEBUG)llSay(0, "TOUCHED NUMBER: "+(string)llDetectedLinkNumber(0)); } run_time_permissions(integer p){ diff --git a/SOURCE/LSL/Table.lsl b/SOURCE/LSL/Table.lsl index 6282d7c..f0729d4 100644 --- a/SOURCE/LSL/Table.lsl +++ b/SOURCE/LSL/Table.lsl @@ -5,8 +5,27 @@ integer updater_channel = 15418070; integer card_channel = -32988199; integer hud_channel = -328478727; +integer g_iSelectNum; list g_lPoints; integer g_iStarted; +integer g_iExpectDeckLoad; + +list StrideOfList(list src, integer stride, integer start, integer end) +{ + list l = []; + integer ll = llGetListLength(src); + if(start < 0)start += ll; + if(end < 0)end += ll; + if(end < start) return llList2List(src, start, start); + while(start <= end) + { + l += llList2List(src, start, start); + start += stride; + } + return l; +} + + GiveUserPoint(key kUser){ // point list - user, num of points integer index = llListFindList(g_lPoints,[kUser]); @@ -20,6 +39,20 @@ GiveUserPoint(key kUser){ UpScores(); } +SetupDeck(){ + string deckStr; + list decks; + integer i=0; + integer end = llGetListLength(g_lSelectedDecks); + for(i=0;i])); - if(DEBUG)llSay(0, "Alive request on the Cards Channel: "+m); + //if(DEBUG)llSay(0, "Alive request on the Cards Channel: "+m); string color = "1"; offset += 0.25; @@ -447,24 +500,33 @@ state active } else if(llJsonGetValue(m,["type"]) == "final"){ key kUser = (key)llJsonGetValue(m,["user"]); GiveUserPoint(kUser); - llWhisper(0, "secondlife:///app/agent/"+(string)kUser+"/about won the round and gets the point."); + g_iSelectNum--; - llSay(card_channel, llList2Json(JSON_OBJECT, ["type", "die", "table", g_kID])); - // Start next round! - // Load the next black card to trigger selection mode - integer boot = llRound(llFrand(5483758)); - g_lPendingCards += [boot, "null|black"]; + if(g_iSelectNum == 0){ - integer x =0; - integer ends = llGetListLength(g_lJudgePile); - g_iTotalJudgeUsers = 0; - for(x=0;x=15.0 && g_iExpectDeckLoad){ + g_iExpectDeckLoad=0; + llWhisper(0, "No nearby deck found"); + } } touch_start(integer t){ @@ -502,6 +590,7 @@ state active if(name == "START"){ if(g_iStarted)return; g_iStarted=TRUE; + llMessageLinked(LINK_SET,11,"",""); if(!(llGetListLength(Players) > 1)){ llSay(0, "Must have more than 1 player to start!"); return; @@ -526,4 +615,46 @@ state active } } } + + link_message(integer s,integer n,string m,key i){ + if(n==-2){ + llResetScript(); + } else if(n == 10){ + g_iExpectDeckLoad=1; + llResetTime(); + llSay(ingredient_channel, "scan"); + llWhisper(0, "Scanning for a deck of cards"); + } + } +} + +state ingred +{ + state_entry(){ + llSetTimerEvent(0); + llListen(ingredient_channel, "", "", ""); + llSetText("Cards Against Humanity Settings\n----\nQuantity: 1", <0,1,0>,1); + } + on_rez(integer t){ + llListen(ingredient_channel, "", "", ""); + } + + changed(integer c){ + if(c&CHANGED_REGION_START){ + llListen(ingredient_channel, "", "", ""); + } + } + + listen(integer c,string n,key i,string m){ + if(m == "scan"){ + llRegionSayTo(i,ingredient_channel+1, "CAH_TABLE"); + }else if(m == (string)llGetKey()){ + llDie(); + } + } + + touch_start(integer t){ + llSay(0, "Cards Against Humanity Settings; Quantity: 1"); + llSay(ingredient_channel+1, "CAH_TABLE"); + } } \ No newline at end of file