civ2units
Emperor
Ok, I found the problem. I made a spelling mistake and therfore the code couldn't work.
Sorry for my stupid question.
Sorry for my stupid question.
if turn ==20 and object.pOttomanEmpire.isHuman == true then
gen.justOnce("Celali Rebellions", function()
local dialog = civ.ui.createDialog()
dialog.title = "Celali Rebellions"
dialog.width = 700
local multiLineText = "A series of rebellions ..."
text.addMultiLineTextToDialog(multiLineText,dialog)
if object.pOttomanEmpire.money >= 700 then
dialog:addOption("Invest money (costs 700 ducats).", 1)
dialog:addOption("Crush down the rebellions....", 1)
local choice = dialog:show()
if choice == 1 then
object.pOttomanEmpire.money = object.pOttomanEmpire.money - 700
end
elseif choice == 2 then
flag.setTrue("CelaliRebellions")
end
end)
end
local choice == dialog:show()
Both these options are given the value '1'. That might be causing your issue.Code:dialog:addOption("Invest money (costs 700 ducats).", 1) dialog:addOption("Crush down the rebellions....", 1)
local choice == dialog:show()
local choice = dialog:show()
if turn ==20 and object.pOttomanEmpire.isHuman == true then
gen.justOnce("Celali Rebellions", function()
local dialog = civ.ui.createDialog()
dialog.title = "Celali Rebellions"
dialog.width = 700
local multiLineText = "A series of rebellions..."
text.addMultiLineTextToDialog(multiLineText,dialog)
if object.pOttomanEmpire.money >= 700 then
dialog:addOption("Invest money...", 1)
end
dialog:addOption("Crush down the ...", 2)
local choice = dialog:show()
if choice == 1 then
object.pOttomanEmpire.money = object.pOttomanEmpire.money - 700
elseif choice == 2 then
flag.setTrue("CelaliRebellions")
end
end)
end
Check the locations table that you provided, since that is where the error is in the civlua.lua file. Remember that even if you have only one location, it must be of the form {{x,y,z}}. (If you have multiple locations, it is {{x,y,z},{x,y,z}}.) You can also try gen.createUnit, which is a bit more flexible about the arguments it can take.if Lua shows me the following error message does it mean that I have too many units at a certain square if the event is fired?
Line 926 in concolidated is the 'civlua.createUnit(...' code
This is very easy to do.would it be possible to fire an event if a unit is destroyed on a certain terrain tile?
For example, I would like to fire an event if the player destroys the Fortress unit on tile 184, 110.
object.lSpecialFortressTile = civ.getTile(184,110,0)
function discreteEvents.onUnitKilled(loser,winner,aggressor,victim,loserLocation,winnerVetStatus,loserVetStatus)
if loser.type == object.uFortress and loserLocation == object.lSpecialFortressTile then
text.simple("An island Fortress was destroyed")
end
end
That error should be fixed by updating the discreteEventsRegistrar.lua file (in the LuaCore). It shouldn't really matter to use the events.lua that you already have. The only change is that if the very last unit available to a player triggers the "region event" I wrote for you on its very last movement point, the penalty won't be triggered until the player's turn ends, rather than when the player clicks a mouse button.I have to say that I'm currently using not the latest version of your lua template. Maybe this is why the error appears.
I'm now using the former events.lua again file which works without problems.
There is keyPressSettings.lua in the MechanicsFiles folder. onKeyPress is also in the consolidatedEvents.lua, and you can make a discrete event in any required folder (keyPressSettings.lua has examples of this).Many thanks for the updated file. Now everything works fine again.
I would like to use the mercenary purchase menu you wrote for my first scenario version, but unfortunately I don't know how to define the key '3' in the current lua template.
In the old template there was a file called 'keyPressEvents.lua' but this file doesn't exist anymore in the new version.
gen.isUnitVisible(unitOrTile,tribe) --> boolean
There is keyPressSettings.lua in the MechanicsFiles folder. onKeyPress is also in the consolidatedEvents.lua, and you can make a discrete event in any required folder (keyPressSettings.lua has examples of this).