Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object "Variable Definitions" are not checked by the Stitch parser #205

Open
softwareantics opened this issue Feb 9, 2024 · 4 comments
Open
Labels
🌳 parser ✨ feature New feature or request

Comments

@softwareantics
Copy link

Here is an object with two variable definitions:

image

However, I am getting errors:

image

@adam-coster
Copy link
Member

adam-coster commented Feb 19, 2024

Ah yeah, that's currently unsupported in Stitch. We declare all of our instance variables in Create Events, so I've never understood the purpose of putting variable definitions in this way. Can you provide any insight on putting variables in via this menu versus defining them in the Create event?

@adam-coster
Copy link
Member

Closing for now, but this can be re-opened if someone has a use case for creating object variables this way rather than in Create events.

@softwareantics
Copy link
Author

Ah yeah, that's currently unsupported in Stitch. We declare all of our instance variables in Create Events, so I've never understood the purpose of putting variable definitions in this way. Can you provide any insight on putting variables in via this menu versus defining them in the Create event?

This can be important in a situation for UI, as an example:

// Variable definitions
color = c_red;
text = "Hello, World";

Placing a UI element in the room - where I'd like to change the color would involve me updating it's creation code which can be tedious for multiple elements. With variables definitions it's as simple as clicking on the element and modifying the variable definition.

@adam-coster
Copy link
Member

adam-coster commented Feb 29, 2024

Ah, gotcha. We do all of our object placement programmatically, so I didn't even know this was a thing! I'll re-open since it'd be good to support that, though since we don't use that feature ourselves I'm not sure if/when I'll get it addressed.

While perhaps less than ideal, you can use the following workaround:

  • In the Create event for an object with variables like that,
  • Add a comment containing the Stitch-specific (i.e. unknown to GameMaker + Feather) @instancevar JSDoc to describe your variable.

So in your example, you'd have something like:

// (In the create event)
/// @instancevar {Constant.Color} color
/// @instancevar {String} text

Note for future self, or for anyone who wants to take a crack at this:

Instance variables defined via the GameMaker "Variable Definitions" UI will end up somewhere in the object's .yy file. That will be easy to ingest during load, since we already have a full schema for this content:

properties: z.array(yyObjectPropertySchema).default([]),

We'd just need a mapping of the numeric type IDs to the corresponding Feather/Stitch type names. They wouldn't get re-parsed on update without some additional work, and aren't meaningfully available to edit via Stitch VSCode, but that'd be a start.

@adam-coster adam-coster reopened this Feb 29, 2024
@adam-coster adam-coster added ✨ feature New feature or request 🌳 parser labels Feb 29, 2024
@adam-coster adam-coster changed the title Variable Definitions are not being checked Object "Variable Definitions" are not checked by the Stitch parser Feb 29, 2024
@github-project-automation github-project-automation bot moved this to Inbox in Stitch Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌳 parser ✨ feature New feature or request
Projects
Status: Inbox
Development

No branches or pull requests

2 participants