Posted: Sun Oct 30, 2022 6:43 am Post subject: String interpolation in lua
I was wondering, is it possible to use string interpolation when using `readInteger`?
Code:
local myValue = readInteger("[[[mygame.exe-00000104]+DB4]+3C]+B48")
I would love to use variables here, e.g.:
Code:
local offs0 = "DB4"
local offs1 = "3C"
local offs2 = "B48"
local myValue = readInteger("[[[mygame.exe-00000104]+offs0]+offs1]+offs2")
Perhaps this is very lua specific? Does anyone have something nice implemented already?
EDIT:
Seems something like this goes:
Code:
local var0 = "mygame.exe-00000104"
local var1 = "DB4"
local var2 = "3C"
local var3 = "B48"
local addy = string.format("[[[%s]+%s]+%s]+%s", var0, var1, var2, var3)
One twist if apply in AA script, we may have to check the value type and if it is number type and integer, we may need to convert to hexadecimal string instead of just tostring, like some html template that some html escaping/un-escaping may be need. _________________
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum