L
Logan Bevans
Guest
Hello I'm following a tutorial and i can't get it to work any help would be greatly appreciated
Error Code:
FATAL ERROR in
action number 1
of Step Event0
for object obj_player:
Pop :: Execution Error - Variable Index [0,-54] out of range [1,55] - -5.ah(100026,-54)
at gml_Script_scr_worldgen (line 19) - for(xx = starting_room; xx < ending_room; xx += 32) {
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_worldgen (line 19)
called from - gml_Object_obj_player_StepNormalEvent_1 (line 142) - global.chunk2 = scr_worldgen(global.chunk2 - 3456);
Link to Tutorial:
scr_worldgen: --------
var sh,ah,dirt_level,stone_level,water_level,adl,starting_room,ending_room, tree, biome,hill;
sh = 1920;
randomize();
//Starting Height
ah = sh;
starting_room = argument0;
ending_room = argument0 + 1728;
tree = choose(1);
biome = choose(1,2,3);
hill = choose(true,false,false);
for(i=0;i<55;i+=1) {
global.ah = 0;
}
for(xx = starting_room; xx < ending_room; xx += 32) {
if biome = 1{
//Biomes
//------PLAINS------//
instance_create(xx,ah,obj_grass);
dirt_level = ah + 32*choose(2,3,3,3);
stone_level = 4192; //room_height poss inf down
water_level = 1920;
//Dirt Level
for(yy = ah; yy < dirt_level; yy += 32){
instance_create(xx, yy + 32, obj_dirt);
adl = yy
}
//Stone Level
for(yy = adl; yy < adl + 64; yy += 32){
u = round(random(choose(3)));
if u = 1{
instance_create(xx, yy + 64, obj_stone);
}else {
instance_create(xx, yy + 64, obj_dirt);
}
}
for(yy = adl + 64; yy < stone_level; yy += 32){
instance_create(xx, yy + 64, obj_stone);
}
//Height Variation In Biome
if (hill){
amp = 7;
} else {
amp = 5 + random(4);
}
ah += amp*sin((2*pi)/1728*(xx-864))+((8+random(8))*sin((2*pi)/choose(54,108,240)*xx))+((15+random(2))*sin((2*pi/240)*xx));
}
if biome = 2{
///-----PLAINSwTrees--///
instance_create(xx,ah,obj_grass);
//global.th = choose(5,6,6,6,6,6,7,7,7);
global.th = choose(5);
dirt_level = ah + 32*choose(2,3,3,3);
stone_level = 4192; //room_height poss inf down
water_level = 1920;
if (ah <= water_level){
tree += 1;
}
//Trees
if (tree = 9) && (ah <= water_level){
c = choose(1,1,2);
if c = 1{
with(instance_create(xx,ah - 32,choose(obj_logspawn_oak,obj_logspawn_birch))){
canGrow = true;
}
}
tree = choose(1,2,2,3,3,4,4,5);
}
//Dirt Level
for(yy = ah; yy < dirt_level; yy += 32){
instance_create(xx, yy + 32, obj_dirt);
adl = yy
}
//Stone Level
for(yy = adl; yy < adl + 64; yy += 32){
u = round(random(choose(3)));
if u = 1{
instance_create(xx, yy + 64, obj_stone);
}else {
instance_create(xx, yy + 64, obj_dirt);
}
}
for(yy = adl + 64; yy < stone_level; yy += 32){
instance_create(xx, yy + 64, obj_stone);
}
//Height Variation In Biome
if (hill) {
amp = 16;
} else {
amp = 10 + random(4);
}
ah += amp*sin((2*pi)/1728*(xx-864))+((8+random(8))*sin((2*pi)/choose(54,108,240)*xx))+((15+random(2))*sin((2*pi/240)*xx));
}
if biome = 3{
/// ----FOREST----/////
instance_create(xx,ah,obj_grass);
global.th = choose(5,6,6,6,6,6,7,7,7);
dirt_level = ah + 32*choose(2,3,3,3);
stone_level = 4192; //room_height poss inf down
water_level = 1920;
if (ah <= water_level){
tree += 1;
}
//Trees
if (tree = 9) && (ah <= water_level){
c = choose(1,1,2);
if c = 1{
with(instance_create(xx,ah - 32,choose(obj_logspawn_oak,obj_logspawn_birch))){
canGrow = true;
}
}
tree = choose(2,3,3,4);
}
//Dirt Level
for(yy = ah; yy < dirt_level; yy += 32){
instance_create(xx, yy + 32, obj_dirt);
adl = yy
}
//Stone Level
for(yy = adl; yy < adl + 64; yy += 32){
u = round(random(choose(3)));
if u = 1{
instance_create(xx, yy + 64, obj_stone);
}else {
instance_create(xx, yy + 64, obj_dirt);
}
}
for(yy = adl + 64; yy < stone_level; yy += 32){
instance_create(xx, yy + 64, obj_stone);
}
//Height Variation In Biome
if (hill) {
amp = 16;
} else {
amp = 10 + random(4);
}
ah += amp*sin((2*pi)/1728*(xx-864))+((8+random(8))*sin((2*pi)/choose(54,108,240)*xx))+((15+random(2))*sin((2*pi/240)*xx));
}
for(yy=ah-320;yy<ah;yy+=32){
instance_create(xx,yy,obj_empty);
}
global.ah[xx/32] = ah;
}
return ending_room;
Error Code:
FATAL ERROR in
action number 1
of Step Event0
for object obj_player:
Pop :: Execution Error - Variable Index [0,-54] out of range [1,55] - -5.ah(100026,-54)
at gml_Script_scr_worldgen (line 19) - for(xx = starting_room; xx < ending_room; xx += 32) {
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_worldgen (line 19)
called from - gml_Object_obj_player_StepNormalEvent_1 (line 142) - global.chunk2 = scr_worldgen(global.chunk2 - 3456);
Link to Tutorial:
scr_worldgen: --------
var sh,ah,dirt_level,stone_level,water_level,adl,starting_room,ending_room, tree, biome,hill;
sh = 1920;
randomize();
//Starting Height
ah = sh;
starting_room = argument0;
ending_room = argument0 + 1728;
tree = choose(1);
biome = choose(1,2,3);
hill = choose(true,false,false);
for(i=0;i<55;i+=1) {
global.ah = 0;
}
for(xx = starting_room; xx < ending_room; xx += 32) {
if biome = 1{
//Biomes
//------PLAINS------//
instance_create(xx,ah,obj_grass);
dirt_level = ah + 32*choose(2,3,3,3);
stone_level = 4192; //room_height poss inf down
water_level = 1920;
//Dirt Level
for(yy = ah; yy < dirt_level; yy += 32){
instance_create(xx, yy + 32, obj_dirt);
adl = yy
}
//Stone Level
for(yy = adl; yy < adl + 64; yy += 32){
u = round(random(choose(3)));
if u = 1{
instance_create(xx, yy + 64, obj_stone);
}else {
instance_create(xx, yy + 64, obj_dirt);
}
}
for(yy = adl + 64; yy < stone_level; yy += 32){
instance_create(xx, yy + 64, obj_stone);
}
//Height Variation In Biome
if (hill){
amp = 7;
} else {
amp = 5 + random(4);
}
ah += amp*sin((2*pi)/1728*(xx-864))+((8+random(8))*sin((2*pi)/choose(54,108,240)*xx))+((15+random(2))*sin((2*pi/240)*xx));
}
if biome = 2{
///-----PLAINSwTrees--///
instance_create(xx,ah,obj_grass);
//global.th = choose(5,6,6,6,6,6,7,7,7);
global.th = choose(5);
dirt_level = ah + 32*choose(2,3,3,3);
stone_level = 4192; //room_height poss inf down
water_level = 1920;
if (ah <= water_level){
tree += 1;
}
//Trees
if (tree = 9) && (ah <= water_level){
c = choose(1,1,2);
if c = 1{
with(instance_create(xx,ah - 32,choose(obj_logspawn_oak,obj_logspawn_birch))){
canGrow = true;
}
}
tree = choose(1,2,2,3,3,4,4,5);
}
//Dirt Level
for(yy = ah; yy < dirt_level; yy += 32){
instance_create(xx, yy + 32, obj_dirt);
adl = yy
}
//Stone Level
for(yy = adl; yy < adl + 64; yy += 32){
u = round(random(choose(3)));
if u = 1{
instance_create(xx, yy + 64, obj_stone);
}else {
instance_create(xx, yy + 64, obj_dirt);
}
}
for(yy = adl + 64; yy < stone_level; yy += 32){
instance_create(xx, yy + 64, obj_stone);
}
//Height Variation In Biome
if (hill) {
amp = 16;
} else {
amp = 10 + random(4);
}
ah += amp*sin((2*pi)/1728*(xx-864))+((8+random(8))*sin((2*pi)/choose(54,108,240)*xx))+((15+random(2))*sin((2*pi/240)*xx));
}
if biome = 3{
/// ----FOREST----/////
instance_create(xx,ah,obj_grass);
global.th = choose(5,6,6,6,6,6,7,7,7);
dirt_level = ah + 32*choose(2,3,3,3);
stone_level = 4192; //room_height poss inf down
water_level = 1920;
if (ah <= water_level){
tree += 1;
}
//Trees
if (tree = 9) && (ah <= water_level){
c = choose(1,1,2);
if c = 1{
with(instance_create(xx,ah - 32,choose(obj_logspawn_oak,obj_logspawn_birch))){
canGrow = true;
}
}
tree = choose(2,3,3,4);
}
//Dirt Level
for(yy = ah; yy < dirt_level; yy += 32){
instance_create(xx, yy + 32, obj_dirt);
adl = yy
}
//Stone Level
for(yy = adl; yy < adl + 64; yy += 32){
u = round(random(choose(3)));
if u = 1{
instance_create(xx, yy + 64, obj_stone);
}else {
instance_create(xx, yy + 64, obj_dirt);
}
}
for(yy = adl + 64; yy < stone_level; yy += 32){
instance_create(xx, yy + 64, obj_stone);
}
//Height Variation In Biome
if (hill) {
amp = 16;
} else {
amp = 10 + random(4);
}
ah += amp*sin((2*pi)/1728*(xx-864))+((8+random(8))*sin((2*pi)/choose(54,108,240)*xx))+((15+random(2))*sin((2*pi/240)*xx));
}
for(yy=ah-320;yy<ah;yy+=32){
instance_create(xx,yy,obj_empty);
}
global.ah[xx/32] = ah;
}
return ending_room;