Way to improve my workflow

I’m working on this thing and I have a system for in-game events that lets me create branching chains of decisions, skill checks etc. It looks something like this:

list.distress[1] = {
	stage_type = "dice",
	dice_type = "detect",
	dice_difficulty = 0.4,
	failure = 2,
	success = 3
}

list.distress[2] = {
	stage_type = "end",
	title = "An uneventful journey",
	description = "Nothing of importance happened."
}

list.distress[3] = {
	stage_type = "choice",
	title = "A distress signal!",
	description = "You have detected an emergency signal from a vessel. Someone may be in trouble. Or they are setting an ambush...",
	choices = {}
}
list.distress[3].choices[1] = {text = "Investigate", result = 4}
list.distress[3].choices[3] = {text = "Ignore it", result = 5}

list.distress[4] = {
	stage_type = "dice",
	dice_type = "luck",
	dice_difficulty = 0.5,
	failure = 6,
	success = 7
}

…and so on. This particular bit checks the player’s ability to use comms and then either tells them nothing happened, or gives them a choice to investigate or ignore a distress signal, the later option having two different outcomes depending on blind luck.

I was thinking that there has to be a better way to create these events than just typing out this mess. I’m sure I could write a a nice little program to do this, but it would definitely take me more time than I would save. Typing the data into an excel sheet would be enough, but I have no idea how I’d go about exporting that. I even looked up what JSON is (as I felt like I saw that format mentioned a lot in similar topics), but that looked like it would be even more work than just writing this directly.

Is there a good existing framework that would help me out here?

Exporting it to csv (comma separated values) would make it quite easy to parse using Lua.

JSON wouldn’t have any obvious advantages over Lua.

Could you maybe use Twine or some other tool for Interactive Fiction or similar to create and edit the data needed?

1 Like

You can check out my Defork example available in assets - it uses JSON data from Twine - maybe this tool could be useful for you, I’ve even adapted it to creating not only dialogs, but quests too, so it’s possible - only your imagination is your limit :smiley: JSON table is a friendly structure, try to load some into Defold and see a table in printout console (pprint(table)). Also you can use more general Excel sheet to your needs - @AGulev someday on forum posted a workflow with adding data from Google Sheet (it’s not working for me because the script is not actual and I failed to update it) but if you have MS Excel there is an embedded possibility to export data to JSON - then use Defold’s built-in parser or some other parser from our assets and see what you can do with this :wink:

1 Like

Thank you both for the suggestions! I’ll check out Twine, might be exactly what I need, and in either case I’ll learn something new.

Edit: So I checked out Twine and it’s going to make creating events a lot smoother. It really is exactly what I needed.

The Twinson output looks surprisingly similar to what I had going on, so that’s nice. I figured how to load the resulting JSON files as custom resources and json.decode() gives me a nice lua table.

Now I just have to either write a little bit of code to make the table look like the format I was using until now or modify my code to be able to utilize the Twinson output directly. Probably a bit of both.

Thanks a lot!

1 Like

Good to know it helps! :wink:

1 Like

You could probably modify the Twine exporter so that it generates the required Lua structure straight away without intermediate JSON

2 Likes

I thought about that, but it’s most likely a bit above my paygrade. At any rate, the amount of work I’d have to put into it would negate any time saved.