Hello folks!
I am a newbie programmer, just learned some Python and then the basics of Lua.
I have been thinking for a while about having random elements in my train carriage mod for which I am currently making internal model. The idea is to randomize the id value in children in a mdl or grp file in order to call different mesh that displays different texture. For example, mesh 0 to 9 that contains different number, and when I randomly call different mesh for different car, each carriage gets a different registration number written on the body, so that I can avoid a sense of repetition.
I tested my thought with the curtain, for which I made 8 mesh files that call different curtain textures; and put "id = Randomize.Curtain("25T_Large_Window_Curtain")," in the children list.
local Randomize = {}
local function Initialization()
if Initialized == nil then
math.randomseed(os.time())
Initialized = 1
end
end
function Randomize.Curtain(filenameCore)
Initialization()
return string.format("%s_%d.msh", filenameCore, math.random(0,7))
end
return Randomize
Alles anzeigen
The problem is I do get curtain looking randomized each time I load the game, but inside the same scenery, all carriages have the same order of curtain looking, like in the screenshots.
I guess the game only loads the parameters once so the script is only executed once. Seems it will make my idea impossible to realize.
I would like to seek for idea what might be other ways to realize it? Does anyone have some insights? Thanks.