CyberDemon765 Posted December 24, 2018 (edited) instead of the rivers flowing with blood im getting grass rivers, I suspect i'm not doing arrays correctly. #library "myscript" // Name of the library #include "zcommon.acs" script "Randomize" open // A unique name is less likely to conflict with other maps with scripts { //replace outdoor textures str outdoor_flat[5] = {"GRASS1","GRASS2","MFLR8_2","MFLR8_3","MFLR8_4"}; str Water[2] = {"BLOOD1","FWATER1"}; //outdoors ReplaceTextures("GRASS1",outdoor_flat[random(1, 5)]); ReplaceTextures("GRASS2",outdoor_flat[random(1, 5)]); ReplaceTextures("MFLR8_2",outdoor_flat[random(1, 5)]); ReplaceTextures("MFLR8_3",outdoor_flat[random(1, 5)]); ReplaceTextures("MFLR8_4",outdoor_flat[random(1, 5)]); //water ReplaceTextures("FWATER1",Water[random(1, 2)]); ReplaceTextures("FWATER2",Water[random(1, 2)]); ReplaceTextures("FWATER3",Water[random(1, 2)]); ReplaceTextures("FWATER4",Water[random(1, 2)]); //blood ReplaceTextures("BLOOD1",Water[random(1, 2)]); ReplaceTextures("BLOOD2",Water[random(1, 2)]); ReplaceTextures("BLOOD3",Water[random(1, 2)]); } Edited December 24, 2018 by CyberDemon765 0 Share this post Link to post
CyberDemon765 Posted December 24, 2018 as expected I found out I was using arrays wrong I needed to reference them like this. //outdoors ReplaceTextures("GRASS1", outdoor_flat[random(0, 4)]); ReplaceTextures("GRASS2", outdoor_flat[random(0, 4)]); ReplaceTextures("MFLR8_2", outdoor_flat[random(0, 4)]); ReplaceTextures("MFLR8_3", outdoor_flat[random(0, 4)]); ReplaceTextures("MFLR8_4", outdoor_flat[random(0, 4)]); //water ReplaceTextures("FWATER1", Water[random(0, 1)]); ReplaceTextures("FWATER2", Water[random(0, 1)]); ReplaceTextures("FWATER3", Water[random(0, 1)]); ReplaceTextures("FWATER4", Water[random(0, 1)]); ReplaceTextures("BLOOD1", Water[random(0, 1)]); ReplaceTextures("BLOOD2", Water[random(0, 1)]); ReplaceTextures("BLOOD3", Water[random(0, 1)]); 0 Share this post Link to post
Nevander Posted December 24, 2018 Sometimes when I'm lazy I'll just create a dummy string for position 0 in the array just so I know my real list is 1 to x. For example: str list[4] = {"0", "item1", "item2", "item3"}; 0 Share this post Link to post
Mordeth Posted December 24, 2018 You can make your code a bit cleaner and easier to modify by looping through your arrays. To add more stuff, you just need to add a name to your array and update the counters. I usually put these counters into their own variable, to avoid mistakes. script "Randomize" OPEN { str org_flat[5] = {"GRASS1","GRASS2","MFLR8_2","MFLR8_3","MFLR8_4"}; str org_watr[7] = {"FWATER1","FWATER2","FWATER3","FWATER4","BLOOD1","BLOOD2","BLOOD3"}; str rpl_flat[5] = {"GRASS1","GRASS2","MFLR8_2","MFLR8_3","MFLR8_4"}; str rpl_watr[2] = {"BLOOD1","FWATER1"}; int n0; for ( n0 = 0; n0 < 5; n0++ ) { ReplaceTextures( org_flat[n0], rpl_flat[random(0,4)] ); } for ( n0 = 0; n0 < 7; n0++ ) { ReplaceTextures( org_watr[n0], rpl_watr[random(0,1)] ); } } 1 Share this post Link to post