Saving JSON bug/error (?) #2650
-
im coding a menu where you can create charts in json format, the idea is - you click a tile, it gets a note in it, you right click a tile, it removes a note, then you hit save and voila! chart ready code for adding/removing notes function onTileOverlap(tile:ChartTile, mouse:FlxObject)
{
if (FlxG.mouse.justPressed)
{
tile.filled = true;
tile.color = FlxColor.fromRGB(255, 165, 165);
if (!notechart.contains([tile.step, tile.dir]))
{
notechart.push([tile.step, tile.dir]);
}
if (FlxG.mouse.justPressedRight)
{
tile.filled = false;
tile.color = FlxColor.fromRGB(255, 165, 165);
for (i in notechart)
{
if (i == [tile.step, tile.dir])
{
notechart.remove(i);
}
}
}
}
} code for saving function saveChart()
{
var chart = {noteChart: noteChart};
var jsoned = Json.stringify(chart, "\t");
FileSystem.deleteFile('assets/data/song1.json');
File.saveContent('assets/data/song1.json', jsoned);
} it DOES save the chart properly.. as long as i didnt remove any notes, because the app just ignores it does this have smth to do with the way I save the chart or the way I place/remove them? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
first off please use code tags when sharing code here, rather than screenShots. screenshots make it much, MUCH harder to copy and test your code, and provide edits and solutions to your code. I painstakingly edited your post to use code tags, next time please do so. like this: ```hx Will become: function someFunc()
{
// code here
} Second, whenever you ask for help, be sure to describe the behavior you expected to see, and the behavior you are seeing, and why that is strange to you. I don't really know what advice to give you until you tell me what's wrong. is there a compile error? a run-time error? is the file not saving, not loading? are you expecting a different visual result when loading a saved file? I see a lot of general problems with your code, and I'm fairly certain that Json is likely working just fine, but your code is wrong. for instance check out this example: https://try.haxe.org/#f00E3F9e var a = [5, 10];
trace(a == [5, 10]); // false
trace([5, 10] == [5, 10]); // false
trace(a[0] == 5 && a[1] == 10); // true
var b = a;
b[0] = 10;
trace(a == b); // true
trace(a); // 10, 10 I recommend learning more of the fundamentals of haxe before asking us to debug your mod |
Beta Was this translation helpful? Give feedback.
first off please use code tags when sharing code here, rather than screenShots. screenshots make it much, MUCH harder to copy and test your code, and provide edits and solutions to your code. I painstakingly edited your post to use code tags, next time please do so. like this:
```hx
function someFunc()
{
// code here
}
```
Will become:
Second, whenever you ask for help, be sure to describe the behavior you expected to see, and the behavior you are seeing, and why that is strange to you.
I don't really know what advice to give you until you tell me what's wrong. is there a compile error? a run-time error? is the file not saving, not loading? are you ex…