Jump to content


DingleNutZ

Member Since 15 Nov 2010
Offline Last Active Apr 19 2012 10:34 AM

Topics I've Started

3 in a row problem

17 April 2012 - 05:50 AM

Hey everyone. im protoyping a game in game maker and im having a little bit of trouble coming up with a script for checking if 3 objects are touching, then to change the youngest object into another instance, so heres my code so far:
for(i=0; i<=5; i+=1){
    for(j=0; j<=5; j+=1){
        for(k=1; k<=2; k+=1;){
            switch(field[i,j]==k){
                case field[i+1,j]==k: switch(field[i,j]==k){
                    case field[i+1,j]==k: return true; 
                    case field[i-1,j]==k: return true; 
                    case field[i,j+1]==k: return true; 
                    case field[i,j-1]==k: return true;}
                case field[i-1,j]==k: switch(field[i,j]==k){
                    case field[i+1,j]==k: return true; 
                    case field[i-1,j]==k: return true; 
                    case field[i,j+1]==k: return true; 
                    case field[i,j-1]==k: return true; }
                case field[i,j+1]==k: switch(field[i,j]==k){
                    case field[i+1,j]==k: return true; 
                    case field[i-1,j]==k: return true; 
                    case field[i,j+1]==k: return true; 
                    case field[i,j-1]==k: return true; }
                case field[i,j-1]==k: switch(field[i,j]==k){
                    case field[i+1,j]==k: return true; 
                    case field[i-1,j]==k: return true; 
                    case field[i,j+1]==k: return true; 
                    case field[i,j-1]==k: return true; }
                    
             }
        }
    }
}
/*
q1=instance_position(50+(64*i),155+(64*j),obj_1);
q2=instance_position(50+(64*i),155+(64*j),obj_1);
q3=instance_position(50+(64*i),155+(64*j),obj_1);
min(q1,q2,q3);
*/
The field array is the grid that im trying to find the connections on, var i is the x axis and var j is the y axis. k is the instance type (eg, obj1, obj2, etc..), starting at one. the code only needs to find if an instance is next to it, or above it, not on the diagonal. and it only needs to find an instance that is the same object as it.
the commented code is something i was trying out to try and figure out the youngest instance, the numbers in there are used to get the x and y co-ords as they are not stored in the field array. the field array is used to store if something is in there or not. (now that i read this, it seems kinda hard to understand, the i and j vars represent the x and y positions in the array, if you know what i mean.)
So does any one have any ideas on how i can make it work?
i was thinking once i have found the youngest instance, i can store it's co-ords in a temp var, delete the touching instances, then set the instance represented by k+1 into co-ords previously occupied by the youngest instance.
also, how would i be able to go about checking more than 3 instances?
sorry if this is hard to understand. thankyou very much for any help in advance.

Mitch

Script not entering for loop

07 April 2012 - 06:45 AM

My script here is not entering the for loop, any ideas on why this is happening?
MainFile = XML_Init(argument0,0);
for(i=0;i=20;i+=1)
{
    LineString = XML_Readln(MainFile);
    if(XML_Check_Tag(LineString,"Category",0)=global.TAG_OPENCLOSE_SINGLE){
        cat[i]=XML_Get_Contents(LineString,"Category",global.XML_Level,"Error");
    }
    //...this is repated a few times for different xml scripts. this section of the code works correctly
    if(XML_Check_Tag(LineString,"ProductDescription",0)=global.TAG_OPENCLOSE_SINGLE){
        des[i]=XML_Get_Contents(LineString,"ProductDescription",global.XML_Level,"Error");
    }
    file_text_readln(MainFile)
}
XML_Close(MainFile);
dct=string(date_current_datetime());
f=file_text_open_write(string("products")+dct+string(".sql"));
file_text_write_string(f,"INSERT INTO `zen_products` (`products_id`, `products_type`, `products_quantity`, `products_model`, `products_upc`, `products_isbn`, `products_ean`, `products_asin`, `products_sku`, `products_image`, `products_price`, `products_msrp`, `products_price_w`, `products_virtual`, `products_date_added`, `products_last_modified`, `products_date_available`, `products_weight`, `products_actual_weight`, `products_weight_type`, `products_dim_type`, `products_length`, `products_height`, `products_ready_to_ship`, `products_width`, `products_status`, `products_tax_class_id`, `manufacturers_id`, `products_ordered`, `products_quantity_order_min`, `products_quantity_order_units`, `products_priced_by_attribute`, `product_is_free`, `product_is_call`, `products_quantity_mixed`, `product_is_always_free_shipping`, `products_qty_box_status`, `products_quantity_order_max`, `products_sort_order`, `products_discount_type`, `products_discount_type_from`, `products_price_sorter`, `master_categories_id`, `products_mixed_discount_quantity`, `metatags_title_status`, `metatags_products_name_status`, `metatags_model_status`, `metatags_price_status`, `metatags_title_tagline_status`, `products_condition`, `products_secret`, `out_of_stock`, `products_diameter`) VALUES");
file_text_writeln(f);
for(j=0;j=20;j+=1){   //this for loop is not started
if (stk[j]>0){rts="1"}else{rts="0"};
if (rrp[j]>=200){fs=1;}else{fs=0;};
if (j=20){term=";"}else{term=","};
file_text_write_string(f,string("(")+string(pid[j])+string(",1,")+string(stk[j])+string(",")+string(pno[j])+string(",NULL,NULL,NULL,NULL,NULL,")+string(img[j])+string(".jpg,")+string(rrp[j])+string(",")+string(rrp[j])+string(",0,0,")+dct+string(",")+dct+string(",NULL,")+string(wgt[j])+string(",")+string(wgt[j])+string(",KGs,CM,")+string(bl[j])+string(",")+string(bh[j])+string(",")+string(rts)+string(",")+string(bw[j])+string(",")+rts+string(",1,")+string(pno[j])+string(",0,1,1,0,0,0,1,0,1,0,0,0,0,")+string(rrp[j])+string(",cat id,1,0,0,0,0,0,NULL,0,0,NULL)")+term);
file_text_writeln(f);
show_message("wroteline");
}
file_text_close(f);
show_message("done");

im not worried about script optimization or speed, i just want it to work.
Thank you in advance for any help.

Rover

16 November 2010 - 12:40 AM

hey there every one its been a while, but im back.
i have a site for yas, free unlimited life long hosting at:

pro-rover.com/upload

i would like to see it used, i pay heaps for it.

the site will be getting a facelift but the files will stay where you put them.

upload your games, sources and resources.