Hello all
I’m new to Defold, Arcweave, and DefArc. Please bare with me; I’m learning every day a bit more
I hope someone can advise me on creating the basic code structure for a 2D dialogue game I started developing.
I followed a video tutorial from Unfolding Defold on making basic interactive dialogs in Defold. And I was wondering what the best way is to create the following:
I want to create stand-alone Arcweave boards per character and export them to JSON. (every character has its JSON file) And I want to start a character dialogue randomly or based on something that happened in the game.
Two questions:
- How to not display the dialogue anymore after the player finishes it?
I was thinking about writing a function that removes the dialogue from the screen instead of hiding it. Is this better for in-game memory usage?
- How do you launch a new dialogue after the first is finished? Let’s say after 30 seconds.
Maybe someone can share a simple timer.delay() code snippet with me that launch a new JSON file?
At the moment I have the following code:
local defarc = require "defarc.defarc"
local small_node = vmath.vector3(0.9)
local normal_node = vmath.vector3(1)
local options = {}
function show_text_and_options()
-- Get and set text:
local text = defarc.get_text()
local node = gui.get_node("game")
gui.set_text(node, text)
-- Get and set options:
options = defarc.get_options_table()
for i = 1,4 do
local option_text = options[i] and options[i].label or ""
local option_node = gui.get_node("option"..i)
gui.set_text(option_node, option_text)
gui.get_blend_mode(node)
end
end
function init(self)
msg.post(".", "acquire_input_focus")
defarc.load("/assets/character-1.json")
local starting_element = defarc.get_starting_element_id()
defarc.select_element(starting_element)
show_text_and_options()
end
-- hide hide_dialogue function
local function hide_dialogue()
print("close dialogue")
end
function on_input(self, action_id, action)
for i = 1,4 do
local current_option_node = gui.get_node("option"..i)
if gui.pick_node(current_option_node, action.x, action.y) then
if action.pressed then
gui.set_scale(current_option_node, small_node)
elseif action.released then
gui.set_scale(current_option_node, normal_node)
defarc.select_element(options[i].target_id) -- select el
show_text_and_options()
-- hide the dialogue
print("need to close dialogue")
hide_dialogue()
end
end
end
end
Always happy to learn more, and thanks in advance
*Excuse any spelling mistakes; I’m dyslexic.