Modding game turns.

nokmirt

Emperor
Joined
Feb 14, 2009
Messages
5,088
Location
Iowa USA
If I wanted to start my game the first week of August, 1942. Then have each turn be a week thereafter. How would I do that with xml?
 
I guess there is no way to do this. Oh well I tried. Just one more thing I miss about Civ IV.
 
Are you sure there's not a way? Doesn't R.E.D. WWII do something like that? You might just have to make a special gamespeed or something.

I am not sure. I may download it to see.
 
I've coded my own in RED and use an override in TopPanel.lua to display mine instead of civ5 calendar.

IIRC, the following should be enough:

this at the beginning of the file, before function UpdateData() (You can add or remove days in dayList to fit your game speed.)
Code:
g_Calendar = {}
local monthList = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }
local dayList = { "1", "5", "10", "15", "20", "25" }
local turn = 0
for year = 1939, 1946 do -- see large
	for month = 1, #monthList do
		for day = 1, #dayList do
			local bStart = (month >= 7 and year == 1939) -- Start date = july, 1st 1939
			if bStart or (year > 1939) then
				local numMonth, numDay
				if month < 10 then numMonth = "0"..month; else numMonth = month; end
				if tonumber(dayList[day]) < 10 then numDay = "0"..dayList[day]; else numDay = dayList[day]; end
				g_Calendar[turn] = { Text = monthList[month] .. " " .. dayList[day] .. ", " .. year, Number = tonumber(year..numMonth..numDay)}
				turn = turn + 1
			end		
		end
	end
end


and this at the end of the UpdateData() function (just before the 2 closing "end")
Code:
		local realDate = g_Calendar[Game.GetGameTurn()].Text or "You should really end this war now !"
		Controls.CurrentDate:SetText(realDate)


edit: but the savegames will still show the civ5 calendar, you'll need more works to fix that.
 
I've coded my own in RED and use an override in TopPanel.lua to display mine instead of civ5 calendar.

Thank you Gedemon. I will try it out. Quite interesting. Although I am lost about how to implement this code.
 
I posted this code. It didn't work so I must have something fouled up. Do I have to use the whole TopPanel.lua file?

Code:
-- Lua Script1
-- Author: nokmirt
-- DateCreated: 5/5/2015 2:58:40 PM
--------------------------------------------------------------

-- Update date
g_Calendar = {}
local monthList = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }
local dayList = { "1", "7", "14", "21", "28", }
local turn = 0
for year = 1939, 1946 do -- see large
	for month = 1, #monthList do
		for day = 1, #dayList do
			local bStart = (month >= 7 and day ==7 and year == 1942) -- Start date = august, 7th 1942
			if bStart or (year > 1939) then
				local numMonth, numDay
				if month < 10 then numMonth = "0"..month; else numMonth = month; end
				if tonumber(dayList[day]) < 10 then numDay = "0"..dayList[day]; else numDay = dayList[day]; end
				g_Calendar[turn] = { Text = monthList[month] .. " " .. dayList[day] .. ", " .. year, Number = tonumber(year..numMonth..numDay)}
				turn = turn + 1
			end		
		end
	end
end
                local date = Game.GetTurnString();
		Controls.CurrentDate:SetText(date);
                local realDate = g_Calendar[Game.GetGameTurn()].Text or "You should really end this war now !"
		Controls.CurrentDate:SetText(realDate)
	end
end

function OnTopPanelDirty()
	UpdateData();
end

I tried taking this out which did not work.

Code:
                local date = Game.GetTurnString();
		Controls.CurrentDate:SetText(date);
 
Do I have to use the whole TopPanel.lua file?
That's the method Gedemon is describing, yes. Get a copy of TopPanel.lua from your game installation [for BNW, in Assets\DLC\Expansion2\UI\InGame], make the edits, then add it to your mod, VFS=true. It must be named TopPanel.lua. You don't need to set an entry point since you're just doing a wholesale replacement of the game file.
 
That's the method Gedemon is describing, yes. Get a copy of TopPanel.lua from your game installation [for BNW, in Assets\DLC\Expansion2\UI\InGame], make the edits, then add it to your mod, VFS=true. It must be named TopPanel.lua. You don't need to set an entry point since you're just doing a wholesale replacement of the game file.

Okay thanks. I got it just need to make a few turn adjustments.
 
I just wanted to add this code as a reference for anyone wanting to use it. Add this to TopPanel.lua.

Code:
-- Update date
g_Calendar = {}
local monthList = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }
local dayList = { "1", "7", "14", "21", "28" }
local turn = 0
for year = 1939, 1946 do -- see large
	for month = 1, #monthList do
		for day = 1, #dayList do
			local bStart = (month >= 8 and year == 1942) -- Start date = august, 1st 1942
			if bStart or (year > 1946) then
				local numMonth, numDay
				if month < 10 then numMonth = month; else numMonth = month; end
				if tonumber(dayList[day]) < 10 then numDay = dayList[day]; else numDay = dayList[day]; end
				g_Calendar[turn] = { Text = monthList[month] .. " " .. dayList[day] .. ", " .. year, Number = tonumber(year..numMonth..numDay)}
				turn = turn + 1
			end		
		end
	end
end
                local date = Game.GetTurnString();
		Controls.CurrentDate:SetText(date);
                local realDate = g_Calendar[Game.GetGameTurn()].Text or "You should really end this war now !"
		Controls.CurrentDate:SetText(realDate)
	end
end

function OnTopPanelDirty()
	UpdateData();
end
 
Top Bottom