This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

Say I have a class and I load it into a script as this issue here.

How do I save it from the current script? The last comment says "Well, we can have subclasses export variables as well, can't we?" What does that comment mean?

extends Node

const Grid = preload("addons/terrain/")

# Error: export hint is not a type or resource
export(Grid) var save = null

func _ready():
    save = Grid.create(8,5,1)

Or perhaps I am thinking about this in the wrong way? Would the Godot way be to put the subclass script on a sub-node?

in Engine by (251 points)
edited by

1 Answer

+2 votes
Best answer

This is currently not supported. In my terrain plugin I had to work around it by putting the raw grid array in export, and wrapping it later with C-style static functions:

var _data = []

func _get_property_list():
    return [
        # We just want to hide the following properties
            "name": "_data",
            "type": TYPE_ARRAY,
            "usage": PROPERTY_USAGE_STORAGE

Util.grid_resize(_data, new_size)
var cp = Util.grid_clone(_data)
# Etc...

I think the last comment was a suggestion to have this feature in the future... then nobody looked into it yet. If you want to discuss this issue you can eventually do it on Github.

by (29,510 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.