ID:133001
 
I was just thinking that it would be nice if variables that were initialized as "in list" would be able to be used with a "Generate Instances from..." using the map editor, similar to the already-existing "Generate Instances from Icon-states" and "Generate Instances from Directions".

First, an example of what I mean:

obj/car
var/color = "black" as text in list("black", "white", "red")
var/brand = "Ford" as text in list("Ford", "Chrysler", "etc.")

var/year = 1908 as num

var/mob/driver


Basically, there would be a right-click menu option "Generate Instances..." that could be selected which would bring up a check-list of variables which used an "in list" initialization, along with icon-states and directions (which might have to have a selection for 4 or 8 directions). You could check any of these and it would generate every possible combination of listed values for the selected variables as instances to be placed on the map.

Additionally, anything specified "as num" could also be selected as a range, using a similar format as a for() loop (for X to Y step Z).

Variables not selected would still have an input box to select what value it should be for the instances. It would be a combination text-input and drop-down box, so you could select any of the listed variables but could input anything as desired. Anything using an "as type" declaration (or rather, any fundamental types, "as mob" wouldn't work out) would be available to be specified this way.

Of course, I'm not sure if more than a dozen people even know about the current Generate Instances options, so it might all be wasted effort.
So basically a faster way of making a new instance and editing a variable of that new instance? Faster as in one or two steps faster?

I like it!
In response to Kaiochao
The issue is that the current edit instance window is rather clunky. Rather VERY clunky.

And the most useful thing would be to generate instances from multiple sets of variables. So, if you want (using my stupid example) cars from every company from every year since 2000 in every color, you wouldn't need to edit hundreds of instances by hand.

And the fact that those instances go away if they aren't immediately put on the map makes it even worse.
While I could see this being pretty handy I doubt it would be even remotely trivial to implement. Not only would the compiler itself have to be changed, but the map editor would require an update too.
In response to Nadrew
I got the impression from his post that the "in list" format was already working code. That may be possible I think because "in list" declarations can be done for proc args. If so, then the only issue would be changing the map editor.

I'm not sure if the syntax works because I've never tried this with a var myself.

Lummox JR
In response to Lummox JR
You're right, the code does compile. I'm not exactly sure how it ends up in the bytecode though.