I already thought that this would be the case, well although i didnt want to post the code but i want to get this thing running.
The only thing that is missing here are the script in the buttons but that only tells this one via linkmessage which one got pressed. This comes with num = 20 with the msg as button name.
float dcol = 0.3;
float lcol = 1.0;
vector blank_color = <0.9,0.9,0.9>;
vector color_1 = <lcol,dcol,dcol>;
vector color_2 = <dcol,dcol,lcol>;
vector color_3 = <lcol,lcol,dcol>;
vector color_4 = <dcol,lcol,dcol>;
vector color_5 = <lcol,dcol,lcol>;
vector color_6 = <dcol,lcol,lcol>;
list colors = [color_1,color_2,color_3,color_4,color_5,color_6];
list button_ids;
list button_colors;
string selected = "";
key player;
integer score;
integer checks;
integer fills;
integer getids;
integer getcols;
integer setcols;
integer getfree;
integer swaps;
SetScoreCells(){
integer prims = llGetNumberOfPrims();
integer i; string name; integer s;
for(i = 1; i <= prims; i++){
name = llGetLinkName(i);
if(llGetSubString(name,0,4) == "Score"

{
s = (integer)llGetSubString(name,5,5);
llMessageLinked(i, 204004, llList2CSV([-100, 8-s]), "''''"

;
}
}
}
integer GetButtonID(integer x, integer y){
getids+=1;
string btns = llList2String(button_ids,x-1);
return llList2Integer(llCSV2List(btns),y-1);
}
integer GetButtonID2(string ID){
return GetButtonID((integer)llGetSubString(ID,0,0),(integer)llGetSubString(ID,1,1));
}
vector GetButtonColor(integer x, integer y){
getcols+=1;
string cols = llList2String(button_colors,y-1);
return (vector)llList2String(llParseString2List(cols,[";"],[]),x-1);
}
vector GetButtonColor2(string ID){
return GetButtonColor((integer)llGetSubString(ID,0,0),(integer)llGetSubString(ID,1,1));
}
SwapColors(string ID1, string ID2){
swaps+=1;
integer x1 = (integer)llGetSubString(ID1,0,0);
integer y1 = (integer)llGetSubString(ID1,1,1);
integer x2 = (integer)llGetSubString(ID2,0,0);
integer y2 = (integer)llGetSubString(ID2,1,1);
list l1 = llParseString2List(llList2String(button_colors,y1-1),[";"],[]);
list l2 = llParseString2List(llList2String(button_colors,y2-1),[";"],[]);
list nl1; list nl2;
vector col1; vector col2;
if(((x1 == x2-1 || x1 == x2+1) && y1 == y2) || ((y1 == y2-1 || y1 == y2+1) && x1 == x2)){
//if(y1 >= y2-1 && y1 <= y2+1){
col1 = GetButtonColor2(ID1);
col2 = GetButtonColor2(ID2);
SetButtonColor(x1,y1,col2);
SetButtonColor(x2,y2,col1);
//if(y1 == y2){
//nl1 = llListReplaceList(l1,[col2],x1-1,x1-1);
//nl1 = llListReplaceList((nl1 = [])+nl1,[col1],x2-1,x2-1);
//button_colors = llListReplaceList((button_colors = []) + button_colors,[llDumpList2String(nl1,";"

],y1-1,y1-1);
//}else{
//nl1 = llListReplaceList(l1,[col2],x1-1,x1-1);
//nl2 = llListReplaceList(l2,[col1],x2-1,x2-1);
//button_colors = llListReplaceList((button_colors = []) + button_colors,[llDumpList2String(nl1,";"

],y1-1,y1-1);
//button_colors = llListReplaceList((button_colors = []) + button_colors,[llDumpList2String(nl2,";"

],y2-1,y2-1);
//}
string id_1 = (string)GetButtonID2(ID1);
string id_2 = (string)GetButtonID2(ID2);
llSetLinkColor((integer)id_1,col2,0);
llSetLinkColor((integer)id_2,col1,0);
//ReColor();
llMessageLinked(GetButtonID2(id_1),11,"disable",""

;
llMessageLinked(GetButtonID2(id_2),11,"disable",""

;
//}
}
}
SetButtonColor(integer x, integer y, vector color){
setcols+=1;
list l1 = llParseString2List(llList2String(button_colors,y-1),[";"],[]);
//llOwnerSay((string)l1);
l1 = llListReplaceList((l1 = []) + l1, [color], x-1,x-1);
//llOwnerSay((string)l1);
button_colors = llListReplaceList((button_colors=[])+button_colors,[llDumpList2String(l1,";"

],y-1,y-1);
//ReColor();
//nl1 = llListReplaceList(l1,[col2],x1-1,x1-1);
//nl1 = llListReplaceList((nl1 = [])+nl1,[col1],x2-1,x-1);
//button_colors = llListReplaceList((button_colors = []) + button_colors,[llDumpList2String(nl1,";"

],y1-1,y1-1);
llSetLinkColor(GetButtonID(x,y),color,0);
}
ReColor(){
integer x;
integer y;
for(y = 1; y < 8; y++){
for(x = 1; x < 8; x++){
llSetLinkColor(GetButtonID(x,y),GetButtonColor(x,y),0);
}
}
}
ShuffleBoard(){
button_colors = [];
integer x; integer y;
string cols;
for(y = 1; y < 8; y++){
cols = "";
for(x = 1; x < 8; x++){
vector col = llList2Vector(colors,(integer)llFrand(5));
cols += (string)col + ";";
llSetLinkColor(GetButtonID(x,y),col,0);
}
button_colors += [cols];
}
CheckColors();
//SetButtonColor(4,4,<1,1,1>

;
}
vector GetFreeColor(list cols){
getfree+=1;
integer i; integer i2;
vector c;
list avail = [] + colors;
for(i=0;i<llGetListLength(cols);i++){
c = llList2Vector(cols,i);
if(c == <0,0,0>

{
cols = llDeleteSubList(cols,i,i);
i--;
}else{
i2 = llListFindList(avail,[c]);
if(i2 > -1){
avail = llDeleteSubList(avail,i2,i2);
}
}
}
return llList2Vector(avail,0);
}
CheckColors(){
integer x; integer y; vector col;
vector col_u; vector col_d; vector col_l; vector col_r;
for(y = 1; y < 8; y++){
for(x = 1; x < 8; x++){
col = GetButtonColor(x,y);
if(y > 1){col_u = GetButtonColor(x,y-1);}
if(y < 7){col_d = GetButtonColor(x,y+1);}
if(x > 1){col_l = GetButtonColor(x-1,y);}
if(x < 7){col_r = GetButtonColor(x+1,y);}
if((col == col_u && col == col_d) || (col == col_l && col == col_r)){
SetButtonColor(x,y,GetFreeColor([col,col_u,col_d,col_l,col_r]));
}
}
}
}
Check4Three(){
integer x; integer y; vector col; integer setted; integer cols_detc;
vector col_u; vector col_d; vector col_l; vector col_r; integer i;
do{
checks += 1;
for(y = 1; y < 8; y++){
for(x = 1; x < 8; x++){
col_l = <0,0,0>;
col_r = col_l;
col_u = col_l;
col_d = col_l;
setted = 0;
col = GetButtonColor(x,y);
if(y > 1){col_u = GetButtonColor(x,y-1);}
if(y < 7){col_d = GetButtonColor(x,y+1);}
if(x > 1){col_l = GetButtonColor(x-1,y);}
if(x < 7){col_r = GetButtonColor(x+1,y);}
if((col == col_u && col == col_d) && col != <0,0,0>

{
cols_detc = 1;
for(i=y-1;i>0;i--){
if(GetButtonColor(x,i) == col){cols_detc+=1;SetButtonColor(x,i,<0,0,0>

;}
else{i=0;}
}
for(i=y+1;i<8;i++){
if(GetButtonColor(x,i) == col){cols_detc+=1;SetButtonColor(x,i,<0,0,0>

;}
else{i=8;}
}
//SetButtonColor(x,y-1,<0,0,0>

;
//SetButtonColor(x,y+1,<0,0,0>

;
if(cols_detc > 2){
score += cols_detc * cols_detc;
setted = 1;
}
}
if((col == col_l && col == col_r) && col != <0,0,0>

{
cols_detc = 1;
for(i=x-1;i>0;i--){
if(GetButtonColor(i,y) == col){cols_detc+=1;SetButtonColor(i,y,<0,0,0>

;}
else{i=0;}
}
for(i=x+1;i<8;i++){
if(GetButtonColor(i,y) == col){cols_detc+=1;SetButtonColor(i,y,<0,0,0>

;}
else{i=8;}
}
//SetButtonColor(x-1,y,<0,0,0>

;
//SetButtonColor(x+1,y,<0,0,0>

;
if(cols_detc > 2){
score += cols_detc * cols_detc;
setted = 1;
}
}
if(setted == 1){SetButtonColor(x,y,<0,0,0>

;}
}
}
}while(Refill() == 1);
ShowScore();
}
integer Refill(){
integer x; integer y; integer i; vector col; integer filled = 0;
for(y = 1; y < 8; y++){
for(x = 1; x < 8; x++){
col = GetButtonColor(x,y);
if(col == <0,0,0>

{
filled = 1;
if(y == 1){SetButtonColor(x,y,llList2Vector(colors,llRound(llFrand(5))));}
else{SetButtonColor(x,y,GetButtonColor(x,y-1)); SetButtonColor(x,y-1,<0,0,0>

;}
}
}
}
fills += 1;
return filled;
//if(filled == 1){Refill();Check4Three();}
}
ShowScore(){
llSetText("Checks: " + (string)fills + " - Fills: " + (string)fills + " - GetCols: " + (string)getcols + " - SetCols: " + (string)setcols + " - Swaps: " + (string)swaps + " - GetIDs: " + (string)getids + " - GetFree: " + (string)getfree,<1,1,1>,1);
string s = (string)score;
integer space = 8 - llStringLength(s);
for(space = space; space > 0; space--){
s = "0" + s;
}
llMessageLinked(LINK_ALL_OTHERS,-100,s,""

;
}
default
{
state_entry()
{
fills = 0;
checks = 0;
SetScoreCells();
ShowScore();
integer l_name; list buttons;
integer i; integer prims = llGetNumberOfPrims();
for(i = 0; i <= prims; i++){
l_name = (integer)llGetLinkName(i);
if(l_name >= 11 && l_name <= 77){
buttons += [(string)(l_name) + "_" + (string)i];
}
}
integer x; integer y;
for(x = 1; x < 8; x++){
string button_row;
for(y = 1; y < 8; y++){
for(i = 0; i < llGetListLength(buttons); i++){
string btn = llList2String(buttons,i);
if(((x*10)+y) == (integer)llGetSubString(btn,0,1)){
button_row += llGetSubString(btn,3,-1)+",";
}
}
}
button_ids += [button_row];
}
//llSetLinkColor(GetButtonID(1,1),<1.0,0.0,0.0>,0);
//llSetLinkColor(GetButtonID(7,1),<1.0,1.0,0.0>,0);
//llSetLinkColor(GetButtonID(1,7),<1.0,0.0,1.0>,0);
ReColor();
llMessageLinked(LINK_ALL_OTHERS,9,"cpu prim",(string)llGetLinkNumber());
}
link_message(integer s_num, integer num, string msg, key id){
//if(num == 11){
//llOwnerSay("num: "+(string)num);
//llOwnerSay("msg: "+msg);
//llOwnerSay("id: "+(string)id);
//}
if(num == 20){
if(selected == ""

{
selected = msg;
llMessageLinked(GetButtonID2(msg),11,"select",""

;
}else{
SwapColors(msg,selected);
llMessageLinked(GetButtonID2(msg),11,"disable",""

;
llMessageLinked(GetButtonID2(selected),11,"disable",""

;
Check4Three();
selected = "";
}
}
}
touch_start(integer num){
ShuffleBoard();
}
on_rez(integer param){llResetScript();}
}