I assume we can now create a new resource and then create a building that produces it?
Great addition!
adding his lua to one of my mods that was just waiting for this now, let you know in 10min or less.
I assume we can now create a new resource and then create a building that produces it?
Great addition!
Thanks! If I'm borrowing someone else code I always try and get the preferred method of crediting beforehand, that way it's less likely to displease anyone or cause other friction. I won't be editing the LUA at all since I haven't taken the time to really learn it yet so all your credit tags in there will stay as is as long as I'm using it and I'll add credit to each file that uses your LUA, which is my standard practice when using someone else work. I may also be adding a Thank you note to my mod's since I keep getting donated art and this code now.
include( "SaveUtils" ); MY_MOD_NAME = "b218b309-9df5-4af5-baf9-c297e593398a";
I assume we can now create a new resource and then create a building that produces it?
Great addition!
Positive, it works great with existing resources.
Negative, So far I am unable to get it to work with a new resource. I even ignored the custom resource i want and just duplicated everything in the XML about RESOURCE_IRON and then renamed IRON to BLOODIRON (on everything but the art tags) and nothing. No error gets generated in either database.log or lua.log. If I swap the <Building_ResourceChange> <ResourceType> to an existing one it supplies said resource just fine, but if I switch it back to a custom resource it fails.
Sigh, I'll work at it more tomorrow but if anyone wants to see the code for my resource here it is.
I've tried it and it works. Chances are yours works too, it's just not visible. Try also running the mod "AgS - Resource Info Panel" and the new resource will show up in the resource panel. Issues regarding visibility and map resource placement are discussed here:
http://forums.civfanatics.com/showthread.php?t=389782
Oh right I found that out this morning. You have to have a unit somewhere in your game that requires a resource for it to be considered strategic and visible at the top info panel. Unless of course you run some other mods that take care of this.
So the SaveUtils part of this mod. I may need some coffee, but what is the purpose of this exactly?
IE is it required to save the game period, or just an enhanced save mechanic for the mod? And is it required to get the building resource mechanic to work properly?
I will probably implement your mod into mine at some point, maybe in a few weeks, perhaps a month or so. Looks like it should make a pretty good addition for corporation mechanics among other things.
include( SaveUtils ); MY_MOD_NAME="???"
I'm more than willing to help. In order for SaveUtils to be truly useful, it has to be adopted. As BuildingResources demonstrates, SaveUtils makes things possible, so there is good reason to adopt it. But more than that, it makes all compliant mods compatible, so the more widely adopted, the easier things get for everyone.
The deserialize() function represents a total of about 30 hours worth of work, by the way. It changes that single save string back into a complex table. I don't mind saying it is one of the more difficult things I have programmed. That's why I put my real name on it.
So for combining files, each Lua file that saves or loads will need to have that same line at the top of the file.
This gives each file access to the save() and load() functions and lets it know what mod it is saving and loading data for. The name should be unique to your mod; I like to use the mod id shown in modbuddy.Code:include( SaveUtils ); MY_MOD_NAME="???"
Then just make sure the commands SetScriptData and GetScriptData only show up in the SaveUtils file. That it's job and its job only.
I'm happy to look at what ever you have.
include( "SaveUtils" ); MY_MOD_NAME = "Procylon's Call to Power Project"
So pretty much all I have to do is include your SaveUtils.lua in my mod, change the 1 line to something like this:
And then make sure it is the last update on my list, and it should work fine as long as no other lua in my mod change SetScriptData/GetScriptData?
So what is the best way to test it when I am ready to implement? Load my mod including a lua file, run a couple of turns, and then try and load it? And then do the same after I include the SaveUtils lua?
include( "SaveUtils" ); MY_MOD_NAME = "Procylon's Call to Power Project";
function inspect()
setCacheState( 0 ); --no cache.
for index,pPlayer in pairs( Players ) do
if pPlayer ~= nil and pPlayer:IsAlive() then
print(out(load( pPlayer )));
end
end
end
Events.ActivePlayerTurnStart.Add( inspect );
include( "SaveUtils" ); MY_MOD_NAME = "[COLOR="blue"]Player Save Inspector[/COLOR]";
function inspect()
setCacheState( 0 ); --no cache.
for index,pPlayer in pairs( Players ) do
if pPlayer ~= nil and pPlayer:IsAlive() then
print(out(load[COLOR="Blue"]( pPlayer, nil, false )[/COLOR]));
end
end
end
Events.ActivePlayerTurnStart.Add( inspect );