World creation array (WRITE error) problems

You must understand the Game Editor concepts, before post here.

World creation array (WRITE error) problems

Postby savvy » Sun Jun 24, 2012 1:20 pm

Ok, I'm working on sandbox loading scripts and level creating, my issue is currently in the creating; I have this script:
Code: Select all
if(type==1)
    {
        //RANDOMIZE!!!!!!
        k=rand(30);
        tracker=30+k;
        //ground levels
        for(j=0;j<16000;j++)
        {
            for(i=0;i<rand(3)+2;i++)
            {
            world[((tracker+i)*16000)+j][1]=2; //LINE 42
            }
            for(i=0;i<120-tracker;i++)
            {
                world[(tracker+i)*16000][1]=1; //LINE 46
            }
            k=rand(2);
            if(k==0)
            {
                k=rand(2);
            if(k==0)tracker-=1;
            if(k==1)tracker+=1;
            }
            if(k==1)
            {
                k=rand(2);
                if(k==0)tracker-=rand(5);
                if(k==1)tracker+=rand(5);
            }
        }
    }

the array I am using is a large one of 'world[1920000][10];'.

When I run this script (it's part of a void function) I have the error:
"view -> Create Actor, in makeworld function, line 42: WRITE attempt before allowed access area"

It also happens if I remove line 42 to line 46.

I have labelled lines 42 and 46 in the script above with comments,
any suggestions?

Thanks, savvy.

EDIT:

Here is some assistance with my issue actually :)
On line 42 the largest sum that can happen IS ((60+3)*16000)+16000 which comes out as 1024000, LOWER than the array limit.
Surely a WRITE error such as the above is going out of the array?
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: World creation array (WRITE error) problems

Postby savvy » Sun Jun 24, 2012 3:44 pm

Sorry, unthoughtful error was made here, I found the problem.

problem: tracker was going up and out of bounds.

Solution: Always make sure you put limiters on things to keep them IN bounds of the array.

savvy
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron