Loading tilemaps from project files using JSON and AJAX?

Post » Thu May 18, 2017 7:52 pm

I'm trying to load a tilemap that I previously downloaded using the JSON download action. I placed this file in my project files and told the AJAX plugin to load it, and when it finished I told the tilemap object to load this tilemap. In the debug the JSON is loaded by the AJAX plugin but the tilemap doesn't change. Can anyone help me?
B
6
Posts: 2
Reputation: 242

Post » Thu May 18, 2017 8:26 pm

You need to pay attention to the expression and action you are using when dealing with tiles JSON. Objects have a common expression "AsJSON" that saves their entire state in a JSON string, and a common action "Set from JSON" to load their state from such a string. However, the tilemap have specific expression / action to save / load only its tile data, namely "TilesJSON" and "Load". You should be using "TileJSON" with "Load", or "AsJSON" with "Set from JSON", not a mix of both set.

Or maybe your problem is something else entirely, but we lack information to really help you. :roll:
B
74
S
31
G
26
Posts: 994
Reputation: 20,198

Post » Thu May 18, 2017 8:42 pm

Magistross wrote:You need to pay attention to the expression and action you are using when dealing with tiles JSON. Objects have a common expression "AsJSON" that saves their entire state in a JSON string, and a common action "Set from JSON" to load their state from such a string. However, the tilemap have specific expression / action to save / load only its tile data, namely "TilesJSON" and "Load". You should be using "TileJSON" with "Load", or "AsJSON" with "Set from JSON", not a mix of both set.

Or maybe your problem is something else entirely, but we lack information to really help you. :roll:

I double checked that but i was using tile data download and upload for both situations. I think the problem might have to do with how I am referencing it. Right now I'm using AJAX.LastData to reference the string. Is that correct or should I reference it differently?
B
6
Posts: 2
Reputation: 242

Post » Thu May 18, 2017 8:55 pm

AJAX.LastData inside the "on completed" trigger is the way to go.
B
74
S
31
G
26
Posts: 994
Reputation: 20,198


Return to General Discussion

Who is online

Users browsing this forum: Darktoz and 1 guest