All is fine and dandy until the other blocks in my world turn black.
I (think) that my turf icon_state might be overwriting the other turfs? Please correct me if I'm wrong.
Code:
turf
icon = 'space.dmi'
icon_state = "1"
layer = 1
New()
icon_state = pick("1","2","3","4","5")
floor
name = "Ground"
icon = 'floor.dmi'
icon_state = "ground_default"
desc = "This is the floor."
layer = 2
In the map editor
Once launched with the randomizer code
Once launched with the randomizer code removed (isolating the issue to the randomizer code)
I have tried adding layer = 1 to the base turf and layer = 2 to the other turfs with no success, if anyone has any idea on how I could remedy this issue it is greatly appreciated!
Basically, in BYOND, a child of a thing inherits all the behavior and properties of its parent thing.
/turf/floor is a child of /turf. This means that your floor types are inheriting all of the behavior of /turf by default. This means that your New() proc that you declared on /turf is also running on /turf/floor too, and since you don't have icon_states 1 through 5 defined on your floor icon's icon_states, they are showing up as a null icon state.
You can get around this in a few ways.
1) Override New() on floor without invoking the supercall to remove all parent behavior from New(). (This is not preferred)
2) Implement a heritable property to gate parent behavior: (This is a better way to go about this)
3) Move the behavior to an overridable proc, so that you can change this behavior per-type without having to cut off all behavior of the New() hook:
4) Change the polymorphic hierarchy so that behavior you don't want to happen is isolated in a separate chain of inheritance: (This is preferred)