Discuss and request scripts and script accessories.
POST REPLY
Post May 20, 2019 01:57
So I'm putting together an export script to dump maps into a JSON file for use with my game. I was going to use notes to define event trigger zones, but there's no reference for that in the API docs. Is there a way to do this?
Site Admin
Post May 20, 2019 13:00
Hi rdominick, right now unfortunately there isn't any way to access the notes on a map via the scripting API.

This is a great idea though and I'll implement at least read access for the next version.

Also since you mentioned JSON, I'll see what I can do about simplifying the output there (since Squirrel is very JavaScript like) to make it easier.

If you have more script API requests then please let me know, this is something I'm keen to support but until now hasn't been something I've had much demand for from customers.
Site Admin
Post May 20, 2019 16:25
Okay, there's now a GCNote API in my development build, ready for the next update.

So far the functions are:

* GCNote.Count() - returns the number of notes on the floor
* GCNote.Entry( index: int ) - returns a table for the note at the given index. The table has slots with the x/y position and text (converted to UTF-8)
* GCNote.GetAtPos( x: int, y: int ) - does a lookup at the given position and returns a table in the same format as above.

So basically you can iterate over all the notes on the active floor for dumping to JSON or some other format as needed, or access specific ones at random if you need that.

Let me know if there are other requirements I can fit into the API before release.
Site Admin
Post May 20, 2019 17:17
I've also now implemented a version of JSON.stringify to make JSON export much easier.

The squirrel table object:

Code: Select all

{
	x = 5,
	y = 8,
	text = "Hello, World"
}
becomes the string

Code: Select all

{ "x": 5, "y": 8, "text": "Hello, World" }
Post May 20, 2019 19:24
No, those are the ones I needed; I'm not (currently) programmatically adding notes. And I'll try that stringify! Thanks a lol for implementing these.

This is my first time messing with JSON, really -- I'm using it because it's much easier to work with in Godot.
POST REPLY