Sukritact's Events and Decisions

Thanks a ton! Seems like I did a little better with it than I expected to (I thought it would just be a mess of errors, lol). This seems to be by far the most complicated thing I'm trying to do, so once I figure this out, I should be fairly good :)

Would I be correct in presuming I could remove the playerID code line that doesn't make sense (and other instances), and it shouldn't break the event?

Both Ivan and Vlad apparently had a fondness for nailing hats to heads. Vlad supposedly did it with some Ottoman emissaries, and Ivan did it to a French ambassador, if I remember my stories correctly.
 
You don't need Sukritact's MCIS. Its a tool for modders to incorporate into their own mods, and not really needed for users. And yes, Viregel might want to take a look at those errors about the Kalmar Union.

However, I can't find anything that relates to the issue you were having; which is odd. Hopefully it's a one-time occurrence.
OK, thanks. Should I disable it or would it corrupt my current saves? I'll definitely remove it next game.
 
It depends what you're doing there. You have a check which, if true, declares war on the player receiving the event (by who, I'm not sure. The random civ?), otherwise give some faith. If you just remove the playerID code, then you'll have an else clause without an if clause to begin with.

OK, thanks. Should I disable it or would it corrupt my current saves? I'll definitely remove it next game.

Not sure. When in doubt, leave it as is for now, and just remove it for your next game.
 
I see.

I think I messed it up. The event is supposed to get faith even if declared on/denounced. I thought there might have been too many "else" instances in there.

But yeah, what's supposed to happen is you get your faith, and then the random civ (I should replace "GameInfoTypes[randomCiv]" with "randomCiv:GetCivilizationType()" there, right?) has the chance of denouncing or declaring war. It's the faith bit at the end that made me wonder about the "else" clause in there, because that's supposed to happen anyway.

If I understand that right, then that line would be looking for the playerID of the randomCiv?
 
In that case, the entire function for the first outcome should look like this (I've taken out the notifications for tidiness, but you just add them back in to the actual code):

Code:
function(pPlayer)
   local iFaithReward = math.ceil(200 * iMod)
   local randomNumber = GetRandom(1, 100) 
   if randomNumber <= 5 then
        Teams[randomCiv:GetTeam()]DeclareWar(pPlayer:GetTeam())
   elseif randomNumber <= 10 then
       randomCiv:DoForceDenounce(pPlayer:GetID())
   end
   
   pPlayer:ChangeFaith(iFaithReward)
   save(pPlayer, "Event_WallachiaEmissaries", true)
end
 
That looks so much cleaner. I always hate to be a bother, but you've helped IMMENSELY! Thank you! :)
 
Just wanting to see if the coding on the decisions for Wallachia are solid:

http://pastebin.com/DVX1PWWG

My only questions are if the part about using Piety and Prestige means it HAS to be on, or if Wallachia can still be played without it, and with the part in the first decision where I attempt to give all cities one of the four defensive buildings. The idea was to have the function see if the city had walls and give it some if it didn't; if it did, it would move on to the castle building. I'm hoping it's not set to give ALL the defensive buildings, really.

Oh, and I forgot to put the "1" after the Arsenal and Military Base, but it's after each in the lua file.
 
Just wanting to see if the coding on the decisions for Wallachia are solid:

http://pastebin.com/DVX1PWWG

My only questions are if the part about using Piety and Prestige means it HAS to be on, or if Wallachia can still be played without it, and with the part in the first decision where I attempt to give all cities one of the four defensive buildings. The idea was to have the function see if the city had walls and give it some if it didn't; if it did, it would move on to the castle building. I'm hoping it's not set to give ALL the defensive buildings, really.

Oh, and I forgot to put the "1" after the Arsenal and Military Base, but it's after each in the lua file.


Code:
Decisions_OrderDragon.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_WALLACHIA_ORDER_OF_THE_DRAGON_DESC", religionType, goldCost, reward, yield)

The problem here is that you've got three empty variables: religionType, reward, and yield. You need to define them above that line. Presumably you're switching faith for piety, in which case add in:

Code:
local reward = mathCeil(70 * iMod)
local yield = "[ICON_PEACE] Faith"
local religionType = "majority religion"
if isUsingPietyPrestige then
	religionType = "State Religion"
	yield = "[ICON_JFD_PIETY] Piety"
	reward = mathCeil(25 * iMod)
end

The line about the "local magistrateCost = 2" is not needed, as you don't use it. There's also a discrepancy - you say the player needs 2, but it only removes 1 in the function below it. The "local magistrateCost = 1" variable is not needed either as, again, you check for the number directly when you remove the magistrates with ChangeNumResourceTotal.

Code:
 player:ChangeFaith=math.ceil(30 * pPlayer:GetNumCities() * iMod)

Rogue "=" sign. Destroy it before it destroys you!

Your defensive buildings part will not work as pPlayer doesn't exist (the player object is called "player," as can be seen in the " function(player)" part. I also don't think it's doing what you want it to do, so it should be:

Code:
for city in player:Cities() do
      if not (city:IsHasBuilding(GameInfoTypes.BUILDING_WALLS)) then 
             city:GetNumFreeBuilding(GameInfoTypes.BUILDING_WALLS, 1)
      elseif not (city:IsHasBuilding(GameInfoTypes.BUILDING_CASTLE)) then
              city:GetNumFreeBuilding(GameInfoTypes.BUILDING_CASTLE, 1)  
      elseif not (city:IsHasBuilding(GameInfoTypes.BUILDING_ARSENAL)) then
              city:GetNumFreeBuilding(GameInfoTypes.BUILDING_ARSENAL, 1)   
      elseif not (city:IsHasBuilding(GameInfoTypes.BUILDING_MILITARY_BASE)) then
               city:GetNumFreeBuilding(GameInfoTypes.BUILDING_MILITARY_BASE, 1)
      end
end

pCity to city is just a style choice, but there may only be one "else" clause in a declarative statement. Use elseif to setup additional conditions.

Everything else seems to be in order with the first decision, though you'll want to use:

Code:
Decisions_AddCivilisationSpecific(civilisationID, "Decisions_OrderDragon", Decisions_OrderDragon)

Instead of
Code:
tDecisions["Decisions_OrderDragon"] = Decisions_OrderDragon

That way, the decision won't be added unless Wallachia is actually in the game - saving precious processing power.

The second decision has a few of the same errors. See if you can fix them up given what I've highlighted above.

Oh, and yes, P&P support will switch on naturally, but if one is not using P&P, then it'll revert to default (in the case of the first decision, requiring the majority religion and giving faith).
 
Got up to the testing part, and the events and decisions aren't showing up. I'm only getting three errors in my lua log:

[740452.630] Runtime Error: C:\Users\Michael\Documents\My Games\Sid Meier's Civilization 5\MODS\Events and Decisions\Lua\EventsAndDecisions_Utilities.lua:307: attempt to index field '?' (a nil value)

I'm not sure what's going on with that one.

[740452.645] Syntax Error: C:\Users\Michael\Documents\My Games\Sid Meier's Civilization 5\MODS\Wallachia\Lua\WallachiaDecisions.lua:51: ')' expected (to close '(' at line 45) near 'if'

I've attempted to put in the ")" it says I'm missing, but I can't get rid of the error.
Pastebin with lines marked: http://pastebin.com/LSVii2kh

[740454.018] Syntax Error: C:\Users\Michael\Documents\My Games\Sid Meier's Civilization 5\MODS\Wallachia\Lua\WallachiaEvents.lua:55: 'end' expected (to close 'function' at line 35) near 'print'

As above, attempted to add an end in the general area (since I really only had a print function there) but no dice.
Pastebin with lines marked: http://pastebin.com/XDcg84PJ

Any help would be appreciated :)
 
[740452.630] Runtime Error: C:\Users\Michael\Documents\My Games\Sid Meier's Civilization 5\MODS\Events and Decisions\Lua\EventsAndDecisions_Utilities.lua:307 : attempt to index field '?' (a nil value)

Have you defined an alpha atlas? It's looking for one and can't find it.

I can't fix the other two, whatever mistake is causing them is happening before this. As a note, don't ever bother trusting the "missing a whatever" comments on the particular location, they are rarely ever correct. The changes you made will cause additional errors.

As a note, if your functions fire correctly, those print statements will never appear since they come after returns.

I HIGHLY suggest getting Notepad++, this should help you with future mods, a correctly coded function should be enclosed in a single block (with sub-blocks)

Spoiler :
4k46oZq.png


Whereas if you're missing or have too many "end"s or parentheses anywhere you get something like this (in this case the extra ) you added is causing the problem):

Spoiler :
VC2hDeQ.png
 
I thought I did. Both the decision and event luas start with:

local Decisions_OrderDragon = {}
Decisions_OrderDragon.Name = "TXT_KEY_DECISIONS_WALLACHIA_ORDER_OF_THE_DRAGON"
Decisions_OrderDragon.Desc = "TXT_KEY_DECISIONS_WALLACHIA_ORDER_OF_THE_DRAGON_DESC"
HookDecisionCivilizationIcon(Decisions_OrderDragon, "CIVILIZATION_WALLACHIA")

With the specifics changed, of course. But "CIVILIZATION_WALLACHIA" is the key for the civ itself.

I'll try putting the lua through that program you mention with your generator, see if it helps.
 
I thought I did. Both the decision and event luas start with:



With the specifics changed, of course. But "CIVILIZATION_WALLACHIA" is the key for the civ itself.

I'll try putting the lua through that program you mention with your generator, see if it helps.
It could be a different civ. I personally get that error when playing with P&P since it adds decisions for civs that I might not have active.
 
Makes sense on that error.

I've been trying to troubleshoot in NotePad++, but haven't had any luck so far. I'll try combing through and making sure every "if" "local" and "function" have an end, and count my parenthesis along the way.

*edit*

Looking at your examples, it could be because my indentation and such is all over the place, making it harder to keep track of what ends where.
 
Makes sense on that error.

I've been trying to troubleshoot in NotePad++, but haven't had any luck so far. I'll try combing through and making sure every "if" "local" and "function" have an end, and count my parenthesis along the way.

*edit*

Looking at your examples, it could be because my indentation and such is all over the place, making it harder to keep track of what ends where.

"local" doesn't have an end. You need to make sure every "if" and "function" have an appropriate "end", and that every parenthesis or bracket is properly closed. Post the whole file on pastebin and link it here if you continue having issues.
 
http://pastebin.com/DsdXb3Af

Repl.it is telling me I'm trying to index global "Decisions_OrderDragon" when I'm trying to close the function. I've tried to play around with it to no avail.

http://pastebin.com/ZMSvBLYG

For this one, it tells me there needs to be a "=" near the DeclareWar function. Whatever's wrong with this one sends a red line down the rest of the document.
 
http://pastebin.com/DsdXb3Af

Repl.it is telling me I'm trying to index global "Decisions_OrderDragon" when I'm trying to close the function. I've tried to play around with it to no avail.

http://pastebin.com/ZMSvBLYG

For this one, it tells me there needs to be a "=" near the DeclareWar function. Whatever's wrong with this one sends a red line down the rest of the document.

I can't see anything obviously incorrect with the first one. In the second, you're missing a colon

Teams[randomCiv:GetTeam()]:DeclareWar(pPlayer:GetTeam())

Edit: Wait? Repl.it? I'm guessing you tried to run the function in repl.it? That simply won't work at all. The problem with the index thing probably was because you didn't define the table first. You also need to include "Decisions_OrderDragon = {}" as well. You still can't use repl.it to test it regardless; since too much of the code is specific to civ.
 
Yeah, I don't know what's coming up incorrect, either. I finally got repl.it to quit telling me I had unexpected characters near the ")" at the end of each segment, but the decisions still won't show in-game, and I'm getting the same errors (but on different lines) in the lua logs.

I figure I'll post the full pastebins of each here, and maybe someone will figure out what I'm missing.

Events: http://pastebin.com/f06dCd7T
Decisions: http://pastebin.com/5Jv6sjAz

Pretty sure I have some extra ")"s in there from trying to get repl.it to quit giving me errors.
 
Not wanting to wade through 20 pages of posts, will this work on YnAEMP or no? Just wondering.

Also, isn't this mod available via Steam's modhub?
 
Back
Top Bottom