Skip to content

Commit

Permalink
17
Browse files Browse the repository at this point in the history
see changelogs txt files
  • Loading branch information
Serpens66 committed Feb 7, 2024
1 parent 9f5d0c8 commit 1b64fc8
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 107 deletions.
2 changes: 2 additions & 0 deletions shared_LuaCoopCounter/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.01:
- updated shared_LuaOnGameLoaded to 1.01
2 changes: 1 addition & 1 deletion shared_LuaCoopCounter/modinfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Version": "1.0",
"Version": "1.01",
"ModID": "shared_LuaCoopCounter_Serp",
"IncompatibleIds": null,
"ModDependencies": null,
Expand Down
2 changes: 2 additions & 0 deletions shared_LuaCoopCounter/shared_LuaOnGameLoaded/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.01:
- some lua code improvemts, thanks "nky/pnski"
Original file line number Diff line number Diff line change
Expand Up @@ -42,57 +42,43 @@ local LoadingScreenLeft_ID = 60
-- It also happens when we went from within a SP game to the main menu and then again back into the same game.


local function table_contains_value(tbl, x)
for _,v in pairs(tbl) do
if v == x then
return true
end
end
return false
end
local function modlog(t)
if type(t)~="string" then
t = tostring(t)
end
local file = io.open("logs/modlog.txt", "a")
io.output(file)
io.write(t,"\n")
io.close(file)
end

local function Execute_SavegameLoadedEvent()
-- modlog("Execute_SavegameLoadedEvent")
-- wait 1 second, to make sure other mods added their functions to g_saveloaded_events_serp already. And also on every call from g_OnLeaveUIState_serp use a delay (at least 1 second), because multiplayer needs this for the code to be executed already ingame (because LeaveUIState fires too fast there)
system.waitForGameTimeDelta(1000)
for id,fn in pairs(g_saveloaded_events_serp) do
if fn~=nil then
if fn~=nil and type(fn)=="function" then
local status, err = pcall(fn)
if status==false then -- error
print("Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." had an error: "..tostring(err))
pcall(modlog,"Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." had an error: "..tostring(err))
-- pcall(modlog,"Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." had an error: "..tostring(err))
end
else
print("Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." has no function: "..tostring(fn))
end
end
end



g_OnLeaveUIState_serp = g_OnLeaveUIState_serp
if not table_contains_value(event.OnLeaveUIState,g_OnLeaveUIState_serp) then -- only add it once
-- important to really define the g_OnLeaveUIState_serp function after the table_contains_value check, otherwise it will be a new object on every lua call!
function g_OnLeaveUIState_serp(UILeft_ID)
if UILeft_ID == LoadingScreenLeft_ID then
-- modlog("g_OnLeaveUIState_serp")
system.start(Execute_SavegameLoadedEvent)
end
local function g_OnLeaveUIState_serp(UILeft_ID)
if UILeft_ID == LoadingScreenLeft_ID then
-- modlog("g_OnLeaveUIState_serp")
system.start(Execute_SavegameLoadedEvent)
end
table.insert(event.OnLeaveUIState, g_OnLeaveUIState_serp)
end

if event.OnLeaveUIState["shared_LuaOnGameLoaded_Serp"] == nil then -- only add it once
event.OnLeaveUIState["shared_LuaOnGameLoaded_Serp"] = g_OnLeaveUIState_serp

-- The first time this script is called with help of SessionEnter, it will already be too late for the very first OnLeaveUIState,
-- because right now we can only execute lua with help of xml, while xml is not yet available when we first enter the main menu or are in the first loading screen
-- that means if g_OnLeaveUIState_serp was not yet added, Anno was just recently started, so the first SessionEnter for sure means a savegame was loaded.
-- after that, the lua event.OnLeaveUIState will continue to work outside of a savegame, so also in main menu, so checking for LoadingScreenLeft_ID is enough then, to catch another savegame load without restarting the whole game
-- modlog("register OnLeaveUIState")
system.start(Execute_SavegameLoadedEvent)

end


Expand Down
2 changes: 1 addition & 1 deletion shared_LuaCoopCounter/shared_LuaOnGameLoaded/modinfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Version": "1.0",
"Version": "1.01",
"ModID": "shared_LuaOnGameLoaded_Serp",
"IncompatibleIds": null,
"ModDependencies": null,
Expand Down
2 changes: 2 additions & 0 deletions shared_LuaCoopLeader/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.01:
- updated shared_LuaOnGameLoaded to 1.01
2 changes: 1 addition & 1 deletion shared_LuaCoopLeader/modinfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Version": "1.0",
"Version": "1.01",
"ModID": "shared_LuaCoopLeader_Serp",
"IncompatibleIds": null,
"ModDependencies": null,
Expand Down
2 changes: 2 additions & 0 deletions shared_LuaCoopLeader/shared_LuaOnGameLoaded/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.01:
- some lua code improvemts, thanks "nky/pnski"
Original file line number Diff line number Diff line change
Expand Up @@ -42,57 +42,43 @@ local LoadingScreenLeft_ID = 60
-- It also happens when we went from within a SP game to the main menu and then again back into the same game.


local function table_contains_value(tbl, x)
for _,v in pairs(tbl) do
if v == x then
return true
end
end
return false
end
local function modlog(t)
if type(t)~="string" then
t = tostring(t)
end
local file = io.open("logs/modlog.txt", "a")
io.output(file)
io.write(t,"\n")
io.close(file)
end

local function Execute_SavegameLoadedEvent()
-- modlog("Execute_SavegameLoadedEvent")
-- wait 1 second, to make sure other mods added their functions to g_saveloaded_events_serp already. And also on every call from g_OnLeaveUIState_serp use a delay (at least 1 second), because multiplayer needs this for the code to be executed already ingame (because LeaveUIState fires too fast there)
system.waitForGameTimeDelta(1000)
for id,fn in pairs(g_saveloaded_events_serp) do
if fn~=nil then
if fn~=nil and type(fn)=="function" then
local status, err = pcall(fn)
if status==false then -- error
print("Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." had an error: "..tostring(err))
pcall(modlog,"Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." had an error: "..tostring(err))
-- pcall(modlog,"Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." had an error: "..tostring(err))
end
else
print("Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." has no function: "..tostring(fn))
end
end
end



g_OnLeaveUIState_serp = g_OnLeaveUIState_serp
if not table_contains_value(event.OnLeaveUIState,g_OnLeaveUIState_serp) then -- only add it once
-- important to really define the g_OnLeaveUIState_serp function after the table_contains_value check, otherwise it will be a new object on every lua call!
function g_OnLeaveUIState_serp(UILeft_ID)
if UILeft_ID == LoadingScreenLeft_ID then
-- modlog("g_OnLeaveUIState_serp")
system.start(Execute_SavegameLoadedEvent)
end
local function g_OnLeaveUIState_serp(UILeft_ID)
if UILeft_ID == LoadingScreenLeft_ID then
-- modlog("g_OnLeaveUIState_serp")
system.start(Execute_SavegameLoadedEvent)
end
table.insert(event.OnLeaveUIState, g_OnLeaveUIState_serp)
end

if event.OnLeaveUIState["shared_LuaOnGameLoaded_Serp"] == nil then -- only add it once
event.OnLeaveUIState["shared_LuaOnGameLoaded_Serp"] = g_OnLeaveUIState_serp

-- The first time this script is called with help of SessionEnter, it will already be too late for the very first OnLeaveUIState,
-- because right now we can only execute lua with help of xml, while xml is not yet available when we first enter the main menu or are in the first loading screen
-- that means if g_OnLeaveUIState_serp was not yet added, Anno was just recently started, so the first SessionEnter for sure means a savegame was loaded.
-- after that, the lua event.OnLeaveUIState will continue to work outside of a savegame, so also in main menu, so checking for LoadingScreenLeft_ID is enough then, to catch another savegame load without restarting the whole game
-- modlog("register OnLeaveUIState")
system.start(Execute_SavegameLoadedEvent)

end


Expand Down
2 changes: 1 addition & 1 deletion shared_LuaCoopLeader/shared_LuaOnGameLoaded/modinfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Version": "1.0",
"Version": "1.01",
"ModID": "shared_LuaOnGameLoaded_Serp",
"IncompatibleIds": null,
"ModDependencies": null,
Expand Down
2 changes: 2 additions & 0 deletions shared_LuaOnGameLoaded/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.01:
- some lua code improvemts, thanks "nky/pnski"
42 changes: 14 additions & 28 deletions shared_LuaOnGameLoaded/data/scripts_serp/event_savegameloaded.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,57 +42,43 @@ local LoadingScreenLeft_ID = 60
-- It also happens when we went from within a SP game to the main menu and then again back into the same game.


local function table_contains_value(tbl, x)
for _,v in pairs(tbl) do
if v == x then
return true
end
end
return false
end
local function modlog(t)
if type(t)~="string" then
t = tostring(t)
end
local file = io.open("logs/modlog.txt", "a")
io.output(file)
io.write(t,"\n")
io.close(file)
end

local function Execute_SavegameLoadedEvent()
-- modlog("Execute_SavegameLoadedEvent")
-- wait 1 second, to make sure other mods added their functions to g_saveloaded_events_serp already. And also on every call from g_OnLeaveUIState_serp use a delay (at least 1 second), because multiplayer needs this for the code to be executed already ingame (because LeaveUIState fires too fast there)
system.waitForGameTimeDelta(1000)
for id,fn in pairs(g_saveloaded_events_serp) do
if fn~=nil then
if fn~=nil and type(fn)=="function" then
local status, err = pcall(fn)
if status==false then -- error
print("Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." had an error: "..tostring(err))
pcall(modlog,"Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." had an error: "..tostring(err))
-- pcall(modlog,"Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." had an error: "..tostring(err))
end
else
print("Mod Lua Error SavegameLoadedEvent: Function from mod "..tostring(id).." has no function: "..tostring(fn))
end
end
end



g_OnLeaveUIState_serp = g_OnLeaveUIState_serp
if not table_contains_value(event.OnLeaveUIState,g_OnLeaveUIState_serp) then -- only add it once
-- important to really define the g_OnLeaveUIState_serp function after the table_contains_value check, otherwise it will be a new object on every lua call!
function g_OnLeaveUIState_serp(UILeft_ID)
if UILeft_ID == LoadingScreenLeft_ID then
-- modlog("g_OnLeaveUIState_serp")
system.start(Execute_SavegameLoadedEvent)
end
local function g_OnLeaveUIState_serp(UILeft_ID)
if UILeft_ID == LoadingScreenLeft_ID then
-- modlog("g_OnLeaveUIState_serp")
system.start(Execute_SavegameLoadedEvent)
end
table.insert(event.OnLeaveUIState, g_OnLeaveUIState_serp)
end

if event.OnLeaveUIState["shared_LuaOnGameLoaded_Serp"] == nil then -- only add it once
event.OnLeaveUIState["shared_LuaOnGameLoaded_Serp"] = g_OnLeaveUIState_serp

-- The first time this script is called with help of SessionEnter, it will already be too late for the very first OnLeaveUIState,
-- because right now we can only execute lua with help of xml, while xml is not yet available when we first enter the main menu or are in the first loading screen
-- that means if g_OnLeaveUIState_serp was not yet added, Anno was just recently started, so the first SessionEnter for sure means a savegame was loaded.
-- after that, the lua event.OnLeaveUIState will continue to work outside of a savegame, so also in main menu, so checking for LoadingScreenLeft_ID is enough then, to catch another savegame load without restarting the whole game
-- modlog("register OnLeaveUIState")
system.start(Execute_SavegameLoadedEvent)

end


Expand Down
2 changes: 1 addition & 1 deletion shared_LuaOnGameLoaded/modinfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Version": "1.0",
"Version": "1.01",
"ModID": "shared_LuaOnGameLoaded_Serp",
"IncompatibleIds": null,
"ModDependencies": null,
Expand Down
4 changes: 3 additions & 1 deletion shared_WhichPlayer_Condition/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
1.06:
- use lua code for humans instead of spawning helper stuff with xml. should be much better now.
1.07:
- remove the code for Mod1 to Mod20 and Human4 to Human7 Participants, because of the heavy dumy-spawn-code and they are only needed if modder add new Participants. Put this into another mod shared_WhichModPlayer instead.
- remove the code for Mod1 to Mod20 and Human4 to Human7 Participants, because of the heavy dumy-spawn-code and they are only needed if modder add new Participants. Put this into another mod shared_WhichModPlayer instead.
1.08:
- use AlwaysTrue once as condition for the lua code that checks for Human (instead of SessionLoaded, because this does not work well for enabling it on savegames)
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,8 @@
</Asset>
</ModOp>

<!-- executing it once per savegame per player is enough, so one time AlwaysTrue -->

<ModOp Type="addNextSibling" GUID="130248">
<Asset>
<Template>Trigger</Template>
Expand All @@ -1177,13 +1179,10 @@
</Standard>
<Trigger>
<TriggerCondition>
<Template>ConditionEvent</Template>
<IsBaseAutoCreateAsset>1</IsBaseAutoCreateAsset>
<Values>
<Condition />
<ConditionEvent>
<ConditionEvent>SessionLoaded</ConditionEvent>
</ConditionEvent>
<ConditionPropsNegatable />
<ConditionAlwaysTrue />
</Values>
</TriggerCondition>
<TriggerActions>
Expand All @@ -1207,7 +1206,20 @@
</Values>
</Asset>
</ModOp>


<!-- Unfortunately ConditionEvaluateTextSource does not work correclty, otherwise one could use this without lua script to check for the current Participant ID within xml... -->
<!-- ConditionEvaluateTextSource only works for commands returning boolean. Things that return numbers always result in the condition to be true (although it should work according to properties-toolone.xml so it is bugged) -->
<!-- tested this code: -->
<!-- <TriggerCondition> -->
<!-- <Template>ConditionEvaluateTextSource</Template> -->
<!-- <Values> -->
<!-- <Condition /> -->
<!-- <ConditionEvaluateTextSource> -->
<!-- <TextSourceString>[Participants GetCurrentParticipantID()]</TextSourceString> -->
<!-- <ComparisonType>Equals</ComparisonType> -->
<!-- <ComparisonValue>2</ComparisonValue> -->
<!-- </ConditionEvaluateTextSource> -->
<!-- <ConditionPropsNegatable /> -->
<!-- </Values> -->
<!-- </TriggerCondition> -->

</ModOps>
12 changes: 2 additions & 10 deletions shared_WhichPlayer_Condition/modinfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Version": "1.07",
"Version": "1.08",
"ModID": "WhichPlayer_Serp",
"DeprecateIds":null,
"IncompatibleIds": null,
Expand All @@ -9,16 +9,8 @@
"German": "Shared"
},
"ModName": {
"Chinese": "Which Player Condition",
"English": "Which Player Condition",
"French": "Which Player Condition",
"German": "Which Player Condition",
"Italian": "Which Player Condition",
"Korean": "Which Player Condition",
"Polish": "Which Player Condition",
"Russian": "Which Player Condition",
"Spanish": "Which Player Condition",
"Taiwanese": "Which Player Condition"
"German": "Which Player Condition"
},
"Description": {
"English": "For Modders: Condition to check if processing player is any AI or specific AI or specific Human. Does not support Mod1 to Mod20 or Human4 to Human7 Mod Participants. The code uses the AI-specific lighthouse as main condition, but it will also make sure no human players are hit by this, even if they somehow controll such a lighthouse! To check for which human, lightweight lua code is used.",
Expand Down

0 comments on commit 1b64fc8

Please sign in to comment.