I remember you from an earlier mc post.. atm it seems you do not change the variables when dropping items into your grid, but I can try to put some ligth on a method you can use to find out what item to create:
let's say we placed two planks at 1,1 and 1,2:
000
010
010
but later we have a case where we place them at 2,0 and 2,1:
001
001
000
what we must do is to run a code to find the area that is beeing used, so after running that code it will just search that area that is:
1
1
and we then turn that into a string where | is line seperatior, so then we know that:
"1|1" should turn into a stick:
same with a bowl:
000
101
010
101 // are beeing used
010
"1 1| 1 " // I put spaces instead of your -1
does this code make any sence?
var i,j,imin,imax;
// find the min and max area to check
imin=4; imax=noone; // variables that hold max and min search area
jmin=4; jmax=noone;
for(i=0;i<=2;i+=1)
for(j=0;j<=2;j+=1)
if slot[i,j]!=-1{ // when you find a empty slot then log the min and max i and j
imin=min(i,imin); imax=max(i,imax);
jmin=min(j,jmin); jmax=max(j,jmax);
}
s=''
// loop thru it and fill in the string
if imin!=4
for(i=imin;i<=imax;i+=1){ // use the min and max in the loop to just search the area we found item data in
if s!='' s+='|';
for(j=jmin;j<=jmax;j+=1){
if slot[i,j]=-1 s+=' ' else s+=string_replace_all(string_format(slot[i,j],3,0),' ','0')
}
}that is the idea behind it .. so then you can have a switch statement to find out what the result will be:
switch(s){
case "001|001": result=280; break; // I made all the characters 3 digits, since minecraft used that many
case "001 001| 001 ": result=281; break;
}280 and 281 are the mc indexes for stick and bowl ^^
hope that made any sence.
Edited by FoxInABox, 09 December 2011 - 09:46 AM.