Quantcast
Channel: Homeworld Mods and Modding - The Official Gearbox Software Forums
Viewing all articles
Browse latest Browse all 663

Random number not being generated on startup

$
0
0

Hi Everyone,

For the Star Trek vs. Homeworld mod, there’s a random number that determines which TOTALLY COOL background gets shown in the menus. It works after every game ends, but on startup it always chooses the middle value. Any ideas on what could cause this or how to fix it?

Thanks!

Heres the file: (it always chooses 4 on startup, but if you set the random number to 3 then it chooses 2 for example)

-- LUA CONFIG FOR THE FE BACKGROUND

--dofilepath("player:STC_DATE.TXT")

local bgnr = random(6)
--local bgnr = Rand(2)

Background = {
	size = {0, 0, 1200, 800},
	stylesheet = "HW2StyleSheet",
	
	RootElementSettings = {
		--backgroundColor = {0,0,0,255},
	Layout = {
				size_WH = { w = 1, h = 1, wr = "scr", hr = "scr" },
		},

	},
	
	-- Flags
	pixelUVCoords = 1, -- Enter pixel coords for texture coords
	preUI = 1,

	;
	
	{
		type = "Frame",
		visible = 1,
		
		Layout = {
			--pos_XY = { x = 0.5, y = 0.5, xr = "par", yr = "par" },
			size_WH = { w = 1, h = 1, wr = "scr", hr = "scr" },
			pivot_XY = { 0.5, 0.5 },
			pos_XY = { x = .5, y = .5, xr = "scr", yr = "scr" },
			--size_WH = { w = 1, h = 1, wr = "scr", hr = "scr" },

			lockAspect=-2,
		},
		
		--local bgnr = (Rand(2))
		
		
		BackgroundGraphic = {
			type = "Graphic",
			--size = {2048, 1024},
			--textureUV = { 0, 0, 2048, 1024},
			uvRect = { 0, 1, 1, 0 },

			--texture = "Data:UI\\NewUI\\Background\\main_bg_"..dateMonth..".tga", -- multires texture

			texture = "Data:UI\\NewUI\\Background\\main_bg_"..bgnr..".tga", -- multires texture

			--texture = "Data:UI\\NewUI\\Background\\main_bg_6.tga", -- multires texture
		},
		
		-- BackgroundVideo = {
			-- filenameV = "data:animatics/mainmenu.webm",
			-- loop = 1,
			-- fitScreen = 1,
			-- fixedAspectRatio = 1,
		-- },
	},
}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 663