DivusIulius wrote:How do I create
LifeHistory cells in state e.g. '5' using Perl scripting?
I tried
but I get a
state value is out of range message! Just state 0 and 1 are allowed.
Multi-state g_setcell() definitely does work fine in Perl, most of the time -- try running invert.pl on a LifeHistory selection, for example.
But I've seen something similar in Python scripting -- drove me crazy on a couple of occasions, too. I
think it's always turned out that the rule for the current active layer was set to a two-state universe, for whatever reason -- a new universe had been created, or the active layer had been switched to a two-state layer, or something like that.
Have you tried a g_setrule("LifeHistory") line right before the line you get an error on? Or if you need to keep the current layer as a two-state layer -- though that doesn't make sense if you're using g_setcell(), I suppose -- you could add a new temporary layer, set that layer's rule to LifeHistory, do your work there, and then remove the layer.
This is something of a design limitation for Golly, I think -- it makes it strangely awkward to do certain operations on cell lists. I'll try to remember, and post some details on, the most recent case where I ran into this problem and spent half an hour wondering why I was getting cell-state-out-of-range errors.
Edit: One mistake that I make every now and then that causes the state-out-of-range error is when I maintain a cell list incorrectly -- for example, if I combine two multi-state cell lists directly instead of using g.join(). Sometimes it works fine (i.e., as long as the first list has an odd number of cells, so it doesn't need the extra marker zero at the end).
But it sounds like your problem really is with g_set_cell(), not with g_putcells(), so this is probably not too relevant.