Events question...

Thanks for the pointers and patience, ProfG - I have made the event trigger when it has to, and that was the holy grail for the scenario.

The entire diplo menu is hidden, even though the Soviets are restricted only with the Germans...Not a biggie. I can get around this.
It might be a ToTPP bug - If so, I will work something out. I can find a method to make these things work, using Lua, and Macro if needed.
 
Fixed the city problem, by removing the events, which work fine in macro.

Now I am getting this error, when the units try to spawn during the triggerEvents code...

[C]: in function 'error'
...s\CIV2 TOT\1_Overlords Update\LuaCore\generalLibrary.lua:2759: in metamethod '__index'
...OT\1_Overlords Update\LuaTriggerEvents\triggerEvents.lua:196: in local 'limitedFunction'
...s\CIV2 TOT\1_Overlords Update\LuaCore\generalLibrary.lua:3116: in function 'generalLibrary.limitedExecutions'
...s\CIV2 TOT\1_Overlords Update\LuaCore\generalLibrary.lua:3123: in function 'generalLibrary.justOnce'
...OT\1_Overlords Update\LuaTriggerEvents\triggerEvents.lua:193: in function 'triggerEvents.afterProduction'
C:\CIV2 Games\CIV2 TOT\1_Overlords Update\events.lua:182: in upvalue 'doAfterProduction'
C:\CIV2 Games\CIV2 TOT\1_Overlords Update\events.lua:189: in function <C:\CIV2 Games\CIV2 TOT\1_Overlords Update\events.lua:186>
 
Not sure what's going on there.

Did you put the most recent version of the General library in the LuaCore folder? The general library line number don't match what I have.

Can you provide more of the text from the console (just in case there is info above it that could help me figure out the problem.)
 
The new General library file was causing errors on loading - I list them here...

WARNING: setGuaranteeUnitActivationType was set to nil. The functionality to guarantee that a tribe will have an active unit is disabled. Some events may not work properly until a unit type is specified.
File number 1 event ending at line 15 successfully parsed. Event number is 1.
File number 1 event ending at line 24 successfully parsed. Event number is 2.
File number 1 event ending at line 35 successfully parsed. Event number is 3.
File number 1 event ending at line 44 successfully parsed. Event number is 4.
File number 1 event ending at line 55 successfully parsed. Event number is 5.
File number 1 event ending at line 64 successfully parsed. Event number is 6.
File number 1 event ending at line 75 successfully parsed. Event number is 7.
File number 1 event ending at line 84 successfully parsed. Event number is 8.
File number 1 event ending at line 95 successfully parsed. Event number is 9.
File number 1 event ending at line 104 successfully parsed. Event number is 10.
File number 1 event ending at line 130 successfully parsed. Event number is 11.
File number 1 event ending at line 150 successfully parsed. Event number is 12.
File number 1 event ending at line 170 successfully parsed. Event number is 13.
C:\CIV2 Games\CIV2 TOT\1_Overlords Update\events.lua:71: module 'calculateCityYield' not found:
no field package.preload['calculateCityYield']
no file 'C:\CIV2 Games\CIV2 TOT\1_Overlords Update\calculateCityYield.lua'
no file 'C:\CIV2 Games\CIV2 TOT\1_Overlords Update\LuaCore\calculateCityYield.lua'
no file 'C:\CIV2 Games\CIV2 TOT\1_Overlords Update\LuaRulesEvents\calculateCityYield.lua'
no file 'C:\CIV2 Games\CIV2 TOT\1_Overlords Update\LuaTriggerEvents\calculateCityYield.lua'
no file 'C:\CIV2 Games\CIV2 TOT\1_Overlords Update\LuaParameterFiles\calculateCityYield.lua'
no file 'C:\CIV2 Games\CIV2 TOT\calculateCityYield.dll'
no file 'C:\CIV2 Games\CIV2 TOT\..\lib\lua\5.3\calculateCityYield.dll'
no file 'C:\CIV2 Games\CIV2 TOT\loadall.dll'
no file '.\calculateCityYield.dll'
stack traceback:
[C]: in function 'require'
C:\CIV2 Games\CIV2 TOT\1_Overlords Update\events.lua:71: in main chunk


With the old General library file, this error ran when the units tried to spawn...Error below:

WARNING: setGuaranteeUnitActivationType was set to nil. The functionality to guarantee that a tribe will have an active unit is disabled. Some events may not work properly until a unit type is specified.
File number 1 event ending at line 15 successfully parsed. Event number is 1.
File number 1 event ending at line 24 successfully parsed. Event number is 2.
File number 1 event ending at line 35 successfully parsed. Event number is 3.
File number 1 event ending at line 44 successfully parsed. Event number is 4.
File number 1 event ending at line 55 successfully parsed. Event number is 5.
File number 1 event ending at line 64 successfully parsed. Event number is 6.
File number 1 event ending at line 75 successfully parsed. Event number is 7.
File number 1 event ending at line 84 successfully parsed. Event number is 8.
File number 1 event ending at line 95 successfully parsed. Event number is 9.
File number 1 event ending at line 104 successfully parsed. Event number is 10.
File number 1 event ending at line 130 successfully parsed. Event number is 11.
File number 1 event ending at line 150 successfully parsed. Event number is 12.
File number 1 event ending at line 170 successfully parsed. Event number is 13.
...s\CIV2 TOT\1_Overlords Update\LuaCore\generalLibrary.lua:2759: The Global table doesn't have a value associated with count.
stack traceback:
[C]: in function 'error'
...s\CIV2 TOT\1_Overlords Update\LuaCore\generalLibrary.lua:2759: in metamethod '__index'
...OT\1_Overlords Update\LuaTriggerEvents\triggerEvents.lua:178: in local 'limitedFunction'
...s\CIV2 TOT\1_Overlords Update\LuaCore\generalLibrary.lua:3116: in function 'generalLibrary.limitedExecutions'
...s\CIV2 TOT\1_Overlords Update\LuaCore\generalLibrary.lua:3123: in function 'generalLibrary.justOnce'
...OT\1_Overlords Update\LuaTriggerEvents\triggerEvents.lua:175: in function 'triggerEvents.afterProduction'
C:\CIV2 Games\CIV2 TOT\1_Overlords Update\events.lua:182: in upvalue 'doAfterProduction'
C:\CIV2 Games\CIV2 TOT\1_Overlords Update\events.lua:189: in function <C:\CIV2 Games\CIV2 TOT\1_Overlords Update\events.lua:186>
 
Please send me your files, and I'll get the latest template version running.

...s\CIV2 TOT\1_Overlords Update\LuaCore\generalLibrary.lua:2759: The Global table doesn't have a value associated with count.
stack traceback:
...OT\1_Overlords Update\LuaTriggerEvents\triggerEvents.lua:175: in function 'triggerEvents.afterProduction'

Check around line 175 in triggerEvents.lua. It looks like you're trying to use a variable named 'count' when you haven't defined it. What probably happened is that it is supposed to be a key to a table, but you wrote it in incorrectly. I'd have to see the code around that line to know for sure.
 
ATM - The only Lua file I have active in the "LuaTriggerEvents" folder, is the triggerevents.lua I have zipped above,

Loading the basic scen save game, I am getting this error...

C:\CIV2 Games\CIV2 TOT\1_Overlords Update\events.lua:71: module 'calculateCityYield' not found:
no field package.preload['calculateCityYield']
no file 'C:\CIV2 Games\CIV2 TOT\1_Overlords Update\calculateCityYield.lua'
no file 'C:\CIV2 Games\CIV2 TOT\1_Overlords Update\LuaCore\calculateCityYield.lua'
no file 'C:\CIV2 Games\CIV2 TOT\1_Overlords Update\LuaRulesEvents\calculateCityYield.lua'
no file 'C:\CIV2 Games\CIV2 TOT\1_Overlords Update\LuaTriggerEvents\calculateCityYield.lua'
no file 'C:\CIV2 Games\CIV2 TOT\1_Overlords Update\LuaParameterFiles\calculateCityYield.lua'
no file 'C:\CIV2 Games\CIV2 TOT\calculateCityYield.dll'
no file 'C:\CIV2 Games\CIV2 TOT\..\lib\lua\5.3\calculateCityYield.dll'
no file 'C:\CIV2 Games\CIV2 TOT\loadall.dll'
no file '.\calculateCityYield.dll'
stack traceback:
[C]: in function 'require'
C:\CIV2 Games\CIV2 TOT\1_Overlords Update\events.lua:71: in main chunk


I think it is those new files, and/or I am missing a file or two, as you pointed out.

EDIT:
I have stripped all events, and the error is still going. Can't be the code.
 
When you're finished for the night, please PM me the scenario. I'll make sure you have all the necessary files, with their current versions and send it back. This latest error means you're missing a file, one of the new ones. This sort of thing shouldn't be a regular issue, it just so happened I did a fairly major update (to take advantage of v16s new fetaures) to the template just after you started using it.
 
No probs, @Prof. Garfield !
I have attached the scenario...It currently has the previous library and events before the updates today, so feel free to over-write anything.

If you check the triggerEvents file, you will see the only events code I have entered so far. It's only one I need to make work. My sincere thanks.

And as ever, no rush. Your help is a big boost, sir.
 

Attachments

  • OverlordsUpdate WIP1.zip
    1.9 MB · Views: 44
Here is the scenario, with the updated files.

There is some sort of bug with the Legacy Events diplomacy. If I comment out all the negotiation events, I get access to the foreign affairs menu. If I leave any of them in, negotiation is stopped. I'll have to look into that.

For the moment, just use Lua.

In negotiationSettings.lua:
Code:
local legacy = require("legacyEventEngine")
local negotiationSettings = {}
local object = require("object")
function negotiationSettings.negotiation(talker,listener)
    -- Britain can't initiate conversation with anyone
    if talker == object.tBritain then
        return false
    end
    -- No one can initiate conversation with britain
    if listener == object.tBritain then
        return false
    end
    -- Germany can't send an envoy to USSR
    if talker == object.tGermany and listener == object.tUSSR then
        return false
    end
   
    -- all other cases, they can talk, so return true
    return true
end
return negotiationSettings
 

Attachments

  • Overlords_WIP1_update.zip
    1.8 MB · Views: 41
Thanks for the update, @Prof. Garfield ! Got the diplo menu back...I'll edit the negotiationSettings code to reference the other civ's negotiations.

The only stand out problem I have at the moment, is what to do about making the following event run only once.

Code:
function triggerEvents.afterProduction(turn,tribe)
    context[getContext()]["afterProduction"](turn,tribe)
    universal["afterProduction"](turn,tribe)
    delay.doAfterProduction(turn,tribe)
    
if civ.hasTech(object.tRussians, object.aSovEuropeanFront) then
        gen.justOnce("SovietsAttackGermany",function()
        civlua.createUnit(object.uRedArmy, object.tRussians, {{19,33,0},{25,21,0},{27,17,0}}, {count=9, randomize=false, veteran=false})
        civlua.createUnit(object.uArtillery, object.tRussians, {{19,33,0},{25,21,0},{27,17,0}}, {count-5, randomize=false, veteran=false})
        civlua.createUnit(object.uLightTank, object.tRussians, {{19,33,0},{25,21,0},{27,17,0}}, {count=5, randomize=false, veteran=false})
        civlua.createUnit(object.uTB3, object.tRussians, {{19,33,0},{25,21,0},{27,17,0}}, {count=3, randomize=false, veteran=false})
        civlua.createUnit(object.uRedArmy, object.tRussians, {{21,41,0},{30,30,0},{36,28,0}}, {count=9, randomize=false, veteran=false})
        civlua.createUnit(object.uArtillery, object.tRussians, {{21,41,0},{30,30,0},{36,28,0}}, {count=5, randomize=false, veteran=false})
        civlua.createUnit(object.uLightTank, object.tRussians, {{21,41,0},{30,30,0},{36,28,0}}, {count=5, randomize=false, veteran=false})
        civlua.createUnit(object.uTB3, object.tRussians, {{21,41,0},{30,30,0},{36,28,0}}, {count=3, randomize=false, veteran=false})
        civlua.createUnit(object.uRedArmy, object.tRussians, {{22,46,0},{28,46,0},{39,43,0}}, {count=9, randomize=false, veteran=false})
        civlua.createUnit(object.uArtillery, object.tRussians, {{22,46,0},{28,46,0},{39,43,0}}, {count=5, randomize=false, veteran=false})
        civlua.createUnit(object.uLightTank, object.tRussians, {{22,46,0},{28,46,0},{39,43,0}}, {count=5, randomize=false, veteran=false})
        civlua.createUnit(object.uTB3, object.tRussians, {{22,46,0},{28,46,0},{39,43,0}}, {count=3, randomize=false, veteran=false})
    end)
end
    
end

It seems the justOnce command needs to be tied into a function, and I am wondering where I should reference the "SovietsAttackGermany" part?
It's one area where Macro seems simple by comparison...I just add the word and it works...Lua seems to be a bit more demanding...:)
 
I'm a clownshoe - Obvious count error in the code...

Code:
        civlua.createUnit(object.uArtillery, object.tRussians, {{19,33,0},{25,21,0},{27,17,0}}, {count-5, randomize=false, veteran=false})
Should be...
Code:
        civlua.createUnit(object.uArtillery, object.tRussians, {{19,33,0},{25,21,0},{27,17,0}}, {count=5, randomize=false, veteran=false})

Durpa-durp. :)

The error was popping up right after the 9 red army were spawned...I should have known. Staring at the same lines too long...:D
 
he only stand out problem I have at the moment, is what to do about making the following event run only once.

Change count-5 to count=5 in this line (167)

civlua.createUnit(object.uArtillery, object.tRussians, {{19,33,0},{25,21,0},{27,17,0}}, {count-5, randomize=false, veteran=false})

Once an error occurs, the function it was in stops. That means that gen.justOnce doesn't store the data that makes sure it is "just once".

I agree that just once is a bit complicated, and I can't really think of an easier way to do it.

Perhaps

Code:
if condition and flag.value("Event not happened") then
-- code
flag.setFalse("Event not happened")
end
but that isn't necessarily much better, and requires defining the flag elsewhere as well.
 
Success!
I finally got the Russian Invasion event to fire immediately after the tech was discovered...:)
A big Soviet unit horde spawned properly, along with emergency random German defenders.
The attack is begun, ending the Ger/Sov locked alliance (which stopped premature wars) as planned.

Now I have this test case complete (with excellent help from ProfG) I can now add the invasion events for the other civs.
This event was by far the big challenge holding back progress...The Lua event for spawning units is much more efficent.

Onwards and sideways!
 
Top Bottom