I have trouble updating LUA functions

Kjulo

Chieftain
Joined
Aug 10, 2013
Messages
3
I have been toying around with LUA, and managed to make some basic new additions. But i have trouble replacing existing lua functions. I want to make it so when you have to choose a belief, it will allow you to select all types of beliefs, like bzyantiums bonus belief. Here is what i do for the pantheon: (And yes, i have set import to vfs to true)

Code:
function OnPantheonBeliefClick()

	if(ToggleBeliefContext("[B][COLOR="red"]BonusBelief[/COLOR][/B]")) then
		local availablePantheonBeliefs = {};
		for i,v in ipairs(Game.[B][COLOR="Red"]GetAvailableBonusBeliefs[/COLOR][/B]()) do
			local belief = GameInfo.Beliefs[v];
			if(belief ~= nil and v ~= g_Beliefs[6]) then
				table.insert(availablePantheonBeliefs, {
					ID = belief.ID,
					Name = Locale.Lookup(belief.ShortDescription),
					Description = Locale.Lookup(belief.Description),
				});
			end
		end
		
		table.sort(availablePantheonBeliefs, function(a,b) return Locale.Compare(a.Name, b.Name) < 0; end);
		
		SelectFromBeliefs(availablePantheonBeliefs, function(belief)
			Controls.PantheonBeliefName:SetText(belief.Name);
			Controls.PantheonBeliefDescription:SetText(belief.Description);
			g_Beliefs[1] = belief.ID;
			
			CheckifCanCommit();
		end);
	end

end

Here is the standard code in the game:

Code:
function OnPantheonBeliefClick()

	if(ToggleBeliefContext("PantheonBelief")) then
		local availablePantheonBeliefs = {};
		for i,v in ipairs(Game.GetAvailablePantheonBeliefs()) do
			local belief = GameInfo.Beliefs[v];
			if(belief ~= nil and v ~= g_Beliefs[6]) then
				table.insert(availablePantheonBeliefs, {
					ID = belief.ID,
					Name = Locale.Lookup(belief.ShortDescription),
					Description = Locale.Lookup(belief.Description),
				});
			end
		end
		
		table.sort(availablePantheonBeliefs, function(a,b) return Locale.Compare(a.Name, b.Name) < 0; end);
		
		SelectFromBeliefs(availablePantheonBeliefs, function(belief)
			Controls.PantheonBeliefName:SetText(belief.Name);
			Controls.PantheonBeliefDescription:SetText(belief.Description);
			g_Beliefs[1] = belief.ID;
			
			CheckifCanCommit();
		end);
	end

end

Solved: It HAS to be the same name as the file it replaces, since it is not like XML. I feel stupid now.
 
Back
Top Bottom