Skip to content
Snippets Groups Projects
Commit 69600822 authored by Florent Berthaut's avatar Florent Berthaut
Browse files

Added variable property size mechanism

parent a6aed180
No related branches found
No related tags found
No related merge requests found
......@@ -46,18 +46,9 @@ func declare() :
func _allow_send_data(value : bool):
_send_data = value
func _add_property(prop, values) :
func _add_property(prop, values) -> void :
_properties[prop] = load("res://addons/ivmi-builder/core/IvmiProperty.gd").new()
_properties[prop].set_values(values)
var tags = ""
for v in values :
if v is float :
tags+="f"
elif v is int :
tags+="f"
elif v is String :
tags+="s"
_properties[prop].set_tags(tags)
_properties[prop].init_values(values)
_properties[prop].set_ivmi_node(self)
_properties[prop].set_name(prop)
......
......@@ -11,16 +11,33 @@ var _tags = ""
var _immediate = false
var _ivmi_node = null
func set_values(vals) :
for v in range(0, min(_values.size(), vals.size())) :
if vals[v] != _values[v] :
_changed=true
_values.assign(vals)
func set_values(vals : Array) :
if vals.size() == _values.size() :
for v in range(0, min(_values.size(), vals.size())) :
if vals[v] != _values[v] :
_changed=true
_values.assign(vals)
else :
init_values(vals)
if _immediate and _listen :
_changed = false
_ivmi_node.send_prop(_name)
func init_values(vals : Array) :
var tags = ""
for v in vals :
if v is float :
tags+="f"
elif v is int :
tags+="f"
elif v is String :
tags+="s"
set_tags(tags)
_values.assign(vals)
_changed=true
func set_tags(t):
_tags=t
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment