Chat ability?

Defold’s text triggers make typed input very easy. I never did a chat system but this little snippet is all it took to get basic typing and backspace in one of my projects:

function on_input(self, action_id, action)
	if action_id == hash("text") then
		mytext = mytext .. action.text
		gui.set_text(textnode, mytext)

	elseif action_id == hash("backspace") then
		if action.pressed or action.repeated then
			mytext = string.sub(mytext, 1, -2)
			gui.set_text(textnode, mytext)
		end
	end
end

Britzl posted step-by-step instructions on how to set up something like this here: How to get text input from the user? (SOLVED)

The rest of your design idea sounds sensible to me. I’m sure others who have more experience with this stuff will chime in.

5 Likes