Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

having troubles with replacetextures in acs

Recommended Posts

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"};

  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)]);
  ReplaceTextures("FWATER1",Water[random(1, 2)]);
  ReplaceTextures("FWATER2",Water[random(1, 2)]);
  ReplaceTextures("FWATER3",Water[random(1, 2)]);
  ReplaceTextures("FWATER4",Water[random(1, 2)]);

  ReplaceTextures("BLOOD1",Water[random(1, 2)]);
  ReplaceTextures("BLOOD2",Water[random(1, 2)]);
  ReplaceTextures("BLOOD3",Water[random(1, 2)]);  


Edited by CyberDemon765

Share this post

Link to post

as expected I found out I was using arrays wrong I needed to reference them like this.


  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)]);
  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)]);  

Share this post

Link to post

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"};

Share this post

Link to post

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)] );


Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now