lemmy101
Emperor
- Joined
- Apr 10, 2006
- Messages
- 1,064
that's what the barcacheck = 1 is for
Fair dos, it was just a general warning about using dirty events not your code. ;D
that's what the barcacheck = 1 is for
Yes, why not? If they wouldn't want us to edit it, they'd have set permissions to employee instead of user and employee.
something like this
Code:local barcaplayerid = 63; local barcacheck = 0; local MECH = 23; local ALPSCOORDS = { somespot = { x = 1, y = 1 }, thisspot = { x = 2, y = 2 }, thatspot = { x = 3, y = 3 }, }; function HANNIBAL () if ( barcacheck == 1 ) then return; end if ( Game.GetGameTurn() == 30 ) then for k,v in pairs( ALPSCOORDS ) do Players[ barcaplayerid ] :InitUnit( MECH, ALPSCOORDS[k].x, ALPSCOORDS[k].y ); end barcacheck = 1; else return; end end Events.SpecificCityInfoDirty.Add ( HANNIBAL );
it's not that complicated if you look that over. if this then do that
like xml editing except you can do stuff depending on what the xml value is equal to
function My_Function()
if (Game.GetGameTurn()==1) then
.
.
My Code here
.
.
end
end
Events.ActivePlayerTurnStart.Add( My_Function )
the code calculates some global variables (at game start) that will be passed later to another lua script that will be run every turn.
local i = 0
i = Players[Game.GetActivePlayer()]:GetID()
print(i)
Yeah a lot of the edits up there have been done by non-firaxis peeps. Mostly Frankenstein but I've added some stuff on there and no-one's taken issue with it yet.t'is what wikis are all about after all.
I mean I want global variables used by separate lua files. if declared at the script root (loaded at InGameUIAddin) of one lua file, then the variables will not be passed to other lua files.
I know there is a share_data utility released in the forums, but I want to pass simple variables which shouldn't be vary complicated.
Include( "SaveUtils" ); MY_MOD_NAME = "MyMod";
local myVariable = nil;
local myDefault = {};
function shareData()
myVariable = share( "myVariable", myVariable or myDefault );
end
Events.LoadScreenClose.Add( shareData );
local tbl = {};
LuaEvents.GetMyVariable( tbl );
local myVariable = tbl[1];
local myVariable = 0;
function onGetMyVariable( tbl )
table.insert( tbl, myVariable );
end
LuaEvents.GetMyVariable.Add( onGetMyVariable );
source code more than likely, unless there's some yet to be known method to define event triggers in lua, which would be really cool, but that's a pipe dreamIt's a very good question. I assume you can attach a function to the Events object, but how would the underlying code know when to execute it?
Added GameEvents system for overriding Gameplay DLL specific functionality. (Added 12/3)