So I made a little function to find/replace words and bold them. You pass it text and a string[int] array and then it iterates over each %s it finds and each words replacing them one by one. (So "%s is a good %s" with {"fido","dog"} would become "fido is a good dog")
However, there seems to be a bug with how initialization happens for an array within a loop.
(Safeguard_Array() just returns a map in the form int [string,item]).* This whole function is just to handle preveting some items from getting PVP'd, selling other items, etc.
Consider the following:
vs.
These should be provide identical output. However, what I get is the following (bolded not included)..
For the first one:
For the second:
This is still true if I change the second bit of code so that all of its elements are initialized as variables first outside of the array initialization (e.g. they are initialized like the first bit of code, then the array is initialized all at once).
Makes things take up more space, but at least there's a workaround.
*I use this to load from a file if the array in memory doesn't have anything in it, otherwise it returns the array in memory.
However, there seems to be a bug with how initialization happens for an array within a loop.
(Safeguard_Array() just returns a map in the form int [string,item]).* This whole function is just to handle preveting some items from getting PVP'd, selling other items, etc.
Consider the following:
Code:
foreach it in Safeguard_Array()[type]
{
string itname = it.to_string();
string numstr = Safeguard_Array()[type,it].to_string();
string[int] word_array;
word_array[0] = itname;
word_array[1] = type;
word_array[2] = numstr;
print_html("%s, %s all but %s", word_array);
}
vs.
Code:
foreach it in Safeguard_Array()[type]
{
string[int] word_array;
word_array = string[int]{it.to_string(),type,Safeguard_Array()[type,it].to_string()};
print_html("%s, %s all but %s", word_array);
}
These should be provide identical output. However, what I get is the following (bolded not included)..
For the first one:
Code:
seal-clubbing club, junk all but 0
disco mask, junk all but 0
moxie weed, junk all but 0
strongness elixir, junk all but 0
magicalness-in-a-can, junk all but 0
For the second:
Code:
seal-clubbing club, junk all but 0
seal-clubbing club, junk all but 0
seal-clubbing club, junk all but 0
seal-clubbing club, junk all but 0
This is still true if I change the second bit of code so that all of its elements are initialized as variables first outside of the array initialization (e.g. they are initialized like the first bit of code, then the array is initialized all at once).
Makes things take up more space, but at least there's a workaround.
*I use this to load from a file if the array in memory doesn't have anything in it, otherwise it returns the array in memory.
Last edited: