How to access variables from another class, and change them?

Given the code below:

Foo := class():
@editable var TestInt : int = 0

MainClass := class(creative_device):

  OnBegin<override>()<suspends>:void=
        # Code here

How would you be able to access the ‘TestInt’ variable at its’ current state and change it?

You need a reference to an object of type Foo in MainClass

@editable FooRef : Foo = Foo{}

If Foo is a creative_device, you can point your MainClass device to your Foo device, and you can do set FooRef.Test = 5 in MainClass and it will work

If Foo isn’t a creative_device then you need some other way of passing the reference from wherever you instantiate a Foo object

How could I use the above to reference to this example:

MainDevice := class(creative_device):

@editable NewFoo : Foo = Foo{}

Foo := class(MainDevice):

@editable var FooInt : int = 0

The @editable part in the “MainDevice” seems to not work at all unless I use an array of type Foo. Any idea how to fix this? Also if you noticed, Foo inherits from MainDevice.

Stacking onto my previous question, how can I make the Foo class which inherits MainDevice not show the @editables in the editor from MainDevice? I want to make the MainDevice class set the settings for the Foo device, and have the Foo device have an @editable variable that the MainDevice won’t

@editable only works for some types. See: Customize Device Properties

If you want some property only editable from MainClass but not Foo, I think you might need to use inheritance: