I have quick phrases on a radio, with items like “LOCATION” and “CALLSIGN”, both of which I have the variables for, I’m just wondering on how to actually replace them?
Eg: “Show CALLSIGN 10-8 at LOCATION” would be “Show 1P23 10-8 at Spawn”
I don’t think I can use Gsub, one of my other methods was to use :split() and then loop through them and change depending on what it says, but thats not really efficient, so was gonna ask you guys.
local ex = "Hello world" -- this is the string we want to remove the stuff from
local word = 'world' -- this is the string we want to remove from ex
local replace = "" -- this is the string we want to replace the word(s) with
ex = string.gsub(ex, word, replace)
print(ex) -> Hello
Also for the word, it can actually be as many words, phrases, etc as you like.
if you leave replace as “” or blank, it will basically just remove it,
but if replace was like “Tomato” ex would print Hello Tomato.