frontispiece / packages / ink-processor / src / utils / ink-utils.ts
ink-utils.ts
Raw
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

import { InkStory } from "../inkTypes"


// FUNCTIONS TO LOAD AND SAVE STORY STATE

// in a way that ink can understand.
export const getStoryStateObject = (story: InkStory) => {
	return JSON.parse(story.state.ToJson())
}

export const loadStoryStateObject = (story: InkStory, state: Record<string, any>) => {
	story.state.LoadJsonObj(state)
}