Refinement/Fixes from using %nodepath and $nodepath changes for a few weeks#241
Refinement/Fixes from using %nodepath and $nodepath changes for a few weeks#241greenfox1505 wants to merge 6 commits intofunc-godot:mainfrom
Conversation
…with target_destination except where Godot-like syntax is seen
|
Further expansion on the particular code changes that made this work. |
| if typeof(node.get(property)) == typeof(properties[property]): | ||
| node.set(property, properties[property]) | ||
| else: | ||
| match typeof(node.get(property)): |
There was a problem hiding this comment.
Looks like if it gets a type mismatch it displays the error twice. Don't need the third match statement.
But also, what happens if node property is a NodePath but properties[property] is an integer? Or a float? Should check if we're trying to send a string.
if typeof(node.get(property)) == typeof(properties[property]):
node.set(property, properties[property])
elif typeof(properties[property] == TYPE_STRING):
match typeof(node.get(property)):
TYPE_STRING, TYPE_STRING_NAME:
node.set(property, properties[property])
TYPE_NODE_PATH:
node.set(property, NodePath(properties[property]))
_:
push_error("Entity %s property \'%s\' type mismatch with matching generated node property." % [node.name, property])
else:
push_error("Entity %s property \'%s\' type mismatch with matching generated node property." % [node.name, property])There was a problem hiding this comment.
I think I must have mangled that somewhere in my copy/pasting from my project version to the PR version. My project version of this is:
if property in node:
if typeof(node.get(property)) == typeof(properties[property]):
node.set(property, properties[property])
else:
match typeof(node.get(property)):
TYPE_STRING,TYPE_STRING_NAME:
node.set(property,properties[property])
TYPE_NODE_PATH:
node.set(property,NodePath(properties[property]))
_:
push_error("Entity %s property \'%s\' type mismatch with matching generated node property." % [node.name, property])There was a problem hiding this comment.
Your version handles source/target data type mangling better than mine.
|
A side effect of this system is that ownership of nodes matters a lot. This isn't really a FuncGodot issue, as long as you're building maps in Editor and not at Runtime, this usually wouldn't cause an issue. But I've run into some unique errors due to my mostly-runtime map building: I have an Entity called MapEntity. It loads and builds a sub map. This lets me make props in Trenchbroom and then place those props in a separate TrenchBroom level without having to duplicate or use linked groups. It also lets that prop be used in multiple levels. (I have a caching system that turns maps into reusable prefabs so we don't generate multiple copies of the same mesh, etc) For |
|
Okay, but I still need that |
Yeah, I was mid-writing the above when you posted that. I'm looking at it now. |
|
I'd like to change that to this, to avoid the text duplication: if property in node:
const TYPE_MISMATCH_ERROR = "Entity %s property \'%s\' type mismatch with matching generated node property."
if typeof(node.get(property)) == typeof(properties[property]):
node.set(property, properties[property])
elif typeof(properties[property] == TYPE_STRING):
match typeof(node.get(property)):
TYPE_STRING, TYPE_STRING_NAME:
node.set(property, properties[property])
TYPE_NODE_PATH:
node.set(property, NodePath(properties[property]))
_:
push_error(TYPE_MISSMATCH_ERROR % [node.name, property])
else:
push_error(TYPE_MISSMATCH_ERROR % [node.name, property])But duplicated error messages in the rest of the repo are not handled this way. I'll push your version if you'd prefer that. |
I would prefer my version in this case. Sometimes it's better to not construct and allocate data if you don't need to. I'm still not convinced that the Using Right now, I believe the only truly obfuscated parts of the plugin are what many of the Godot Variants translate to when written to the FGD and other class property construction tricks. I'd rather not add to the pile and I'd also prefer to avoid potentially breaking someone's project for an unnecessary convenience. Something to remember is that a change like this affects hundreds of users; any changes that could adversely affect their use needs to be with very good reason or worked around. The |
I have been doing this for a long time and yet users continue to surprise me, both in good and bad ways.
I think this would be the best option for now. |

Couple of issues arose when working with these changes. These are my fixes for that.
These changes only applied to Solid Entities, not Point Entities. The functionality is now pulled out of
generate_solid_entity_node(and called from both that andgenerate_point_entity_node(.apply_entity_properties(didn't handle the type change between String/StringName and NodePath. This handles that now. It's been a few weeks since I encountered this problem, I'm not totally sure what the issue was, but I am certain it fixed a type issue.generate_entity_node(now detects$node_nameand treats it like%node_name, but without making it unique for naming nodes without the"entity_" +naming.