Create temporary variables for use in construction script only?

I have a dialogue system that works like this. The player presses a button, a raycast is sent and if it hits an NPC it reads that NPC actor’s Dialogue Integer Array and uses it to set tiles on the player’s Dialogue Tilemap. Those integers in that array correspond to tile #'s on a tileset which I am using as my fonts.

Now, to set an NPC’s Dialogue Integer Array I have a bunch of variables, which are only used in the construction script, that take text typed into the editor by me and turns it into an array of integers. Basically several string variables and a String/Integer map.

I’m kind of bugged at the thought of all those string variables and that heavy String/Int map hogging up memory on every NPC in the game when those were only needed when placing NPC’s into the level. Is that what will happen, and if so, what can I do about it besides making sure to manually delete those variables before packaging?

Is this something I even need to be concerned about, or does the compiler take care of this automatically?

what is “Dialogue Tilemap”?

As far as I know you cannot have them being “temp”. Though I suppose the compiler will find a way around this. Furthermore, if they are spawned in map by actors they will need to be kept. What you can maybe try is to use a function, though it will not completely do what you want, it is a local variable.

I don’t really understand what you do, but I would recommend you to have a look at datatables. I guess it will fit what you need and it’s more easy to work with (you can also export/import to /csv). if it goes south - make some screenshots of what you (try to) do - it’s quite hard to understand your setup :slight_smile:

It’s a tilemap component on the Player’s blueprint actor.

Since I’m not 100% sure variables on actors that are never used outside of the construction script are discarded by the compiler, what I’ve decided to do is to make an actor who’s sole purpose is converting dialogue strings into integer arrays. Instead of entering dialogue into a string variable on an NPC actor and having a function on the NPC’s construction script do the conversion, I’ll enter it on the Dialogue Actor, have it’s construction script populate its Int Array, then just copy paste that value over to the NPC’s Int Array manually. Then I can just add Destroy Self to the Dialogue actor’s Begin Play during testing, and then manually delete it from the map when I’m done.Now all my NPC’s will just have the one variable they actually need, the array of integers that represent tileset values.

Update:
I just learned about calling Custom Events in the editor. This is exactly what I need. An Actor that will set everything up on my NPC actors in the level without burdening them with all the variables and functions needed to set that Int Array.

Yes, I recommend either creating a function library or using datatables