Use of Subtype Editable?

Trying to make a constrained class container selection for a device for the user to choose which container to use for different editables but ‘where’ only works in parameter definitions and numerical constraints.

constrainted_type := type{T:type where type:subtype(some_class)}
...
@editable
Type:constrained_type = some_subclass

My other attempt used a subtype editable instead.

@editable
Type:subtype(some_class) = some_subclass

This is what was displayed by the editable.

There’s no definition of using a subtype as an editable in the documentation so was curious if anyone would know the use or if there would be a solution to my original problem.

This is only possible in NPC Behaviors (as of v32.00), creative device editables do not support that kind of thing, what you can do instead is expose your both subtypes as optionals :

@editable
FirstMethod : ?some_subclass1 = false

@editable
SecondMethod : ?some_subclass2 = false

Another method would be to use getters to force the children classes to implement those editables :

parent_device := class(creative_device):
    GetMyClass()<transacts><decides>:some_class = (__:?some_class=false)?

child_device_1 := class(parent_device):
    @editable
    MyClass : some_subclass1 = some_subclass1{}

    GetMyClass<override>()<transacts><decides>:some_class = MyClass

child_device_2 := class(parent_device):
    @editable
    MyClass : some_subclass2 = some_subclass2{}

    GetMyClass<override>()<transacts><decides>:some_class = MyClass
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.