Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Displaying variables

A topic by Breezy created Apr 03, 2025 Views: 149 Replies: 2
Viewing posts 1 to 2

In Decker, is there any way for me to create a text field with a variable and then display that variable?

(1 edit) (+3)

The short answer is "Yeah!" Variables are usually stored in widgets in one way or another.

The long answer is "Yeah! But there's a lot of ways this could be done depending on what you need, so it would help to narrow it down."

A field is always a good option for storing numbers and strings of text to refer to later.

Here's an example of making a user-entered name appear in an alert:

Button script:

on click do
 alert["Your name is ", namefield.text, "!"]
end
field.text is useful for referring to the simple (non-Rich Text) contents of a field in scripts.
(replace the "field" here with the name of your actual field widget!)

If you're using something like the Dialogizer module there's a helpful reference for how to do this same thing in the dialog boxes created by the module.

Or it might be handy to know how to how to refer to a widget on another card....?

Reusing the example above.... if I needed to check this same stored string of text from a different card later, I could write it like this:

alert["Your name is still ", othercardname.widgets.namefield.text, "!"] 

You can also store numbers in fields and use field.text to set them, and modify them and so on.

This is sort of just a general answer -- it might not be what you needed for your project at this exact moment. 

I'd love to make a more specific answer for you if you can narrow it down to a more specific question. :D

(+2)

Thank you so much for replying and being so thoughtful about it! It was exactly what I needed, especially for the multiple cards thing, since I'm trying to emulate a chat that will show character names in it, and the user would be able to input their own username. Thank you so much! I will play with Decker a little more until I can finally get a grasp on these basic concepts!