Lua-king for help

but I need it to check continously for the player

And I want a pony.

It doesn't matter how badly you think you need it, a LOT of things we want just aren't possible with the current tools. We don't have any events that can trap the completion of a building, and that's been something a lot of people have wanted for a long time. While we have an event that can trap completion of an improvement, it only works for improvements visible to the active player (you), which makes all sorts of functions impossible. And my own mod, as you may have noticed from my .sig, is semi-permanently crippled because Firaxis broke the only two combat-related events we ever had access to, and even those events weren't very good in the first place.

So you might just have to forget about having the information always be up-to-date, unless you're ready to put in all sorts of recursion breaks to ensure it doesn't get stuck in an infinite loop. Or, you could try using something like the popup event; do you REALLY need it constantly updating, or is it just enough to ensure that it updates when the player opens the city window, and at the start of each turn since the AI never does that?
 
And I want a pony.

My apologies, then, since I seem to be annoying you. :(

.. do you REALLY need it constantly updating, or is it just enough to ensure that it updates when the player opens the city window, and at the start of each turn since the AI never does that?

This is what I was just saying, yes - I need the information presented in the cityView to be up-to-date when the player views it, and I need the yields to be up-to-date when they are to be used. I guess that if those two things cannot be done I might as well give up here and not mod anymore at all, since I seem to suck so badly at it.
 
Now, if I could find a good list of events (that is clear enough to be read and understood) that could cover any such change - city founding, capture and destruction; worked tiles changed; building added; production changes; specialist changes; tech changes; policy changes; changes to any tile within the city's workable radius etc... - then I could use that instead. But unless I have that, I might as well use this one, since it does do most of what I need it to do.
You won't be able to find a better list than the ones on the 2kgames wiki afaik. However, finding such events is pretty easy:
* An event that triggers whenever a plot's yield change? Look at the lua file managing the yield overlay.
* Events for city destruction and foundation? Look at the lua file managing the city banners.
* Tech changes? At the beginning of a new turn.
* Policy changes? Can't you just look at the policy popup and use the event triggered when the popup closes?
* Etc...

Now, the problem is that most of those are UI events and they may be affected by optimizations as Spatz mentioned (with the example he provided regarding SpecificCityInfoDirty: it may not be triggered for the AI cities - you need to test - and even if is, it may stop to be in a future patch).

Alternatively you could perform a routine check once every 5 frames (ContextPtr:SetUpdate) but it's dirty as hell and it may impact performances (test on big maps with a quite old computer if possible).
 
My apologies, then, since I seem to be annoying you. :(

You're not annoying me. Firaxis, on the other hand, is annoying me. My exasperation in that last post was due to the fact that in patch 674 they tweaked two serial events to the point where tons of stuff broke in my own mods, because they made their changes without considering the effects it'd have on those of us who use their tools for our own mods. A series of mods that I've spent almost two years developing is now in the trash because of their minor tweak to those events.

The problem isn't that you want what you want. The problem is that we haven't been given the tools to do what we want; what we've been given are the functions THEY needed to create the game, and almost nothing else. As a result, a lot of what we want just isn't possible with the tools we've been given, because those tools are constructed with a lot of limitations or quirks aimed purely at the core game's use of them.

If they'd done their jobs right, they'd have released a robust set of events and functions from the start, instead of the extremely specialized (usually UI-oriented) tools we were given. For instance, every Get command should have had a corresponding Set command, even if nothing in the core game needed that Set, because it'd make things far, far easier for us modders. And they should never have depended on so many locked metatables (YieldTypes and TerrainTypes, for instance) instead of just accessing the GameInfo structures like a rational person would.
At the very least, once something was released to us it should never be altered again; they ran into problems a year ago when they deleted the ScriptData access functions people were using for various mods, and now we're seeing it again with the CombatSim events. It's just bad programming practices. (Once upon a time I was a software engineer, so this isn't just the rantings of a gamer.)

Bottom line: You just might have to make do with an inefficient design that only updates the city numbers when certain triggers occur (like the window opening/closing), instead of insisting on an always-updated readout. You want something that will constantly update a certain UI window, such that it's immediately correct whenever anything changes; unfortunately, I don't think you can do that without a tremendous overhead cost because the current functions just aren't built for that. This means that you just might need to accept a certain inefficiency in the design; maybe the numbers only update on specific actions, instead of any time any thing changes. That sort of thing.
In my own mod I ran into something similar with my custom "Mandala" window; I couldn't guarantee that the information in the window would be up-to-date, because I have no way of identifying the popup trigger for a nonstandard popup type. In the end I added a half-dozen triggers for the update function (end of turn, city founded, god added, major event occurred, clicked any button in my custom UI window, and so on) and accepted the fact that it wouldn't always be exactly up-to-date when the window is first opened.
 
You're not annoying me. Firaxis, on the other hand, is annoying me. My exasperation in that last post was due to the fact that in patch 674 they tweaked two serial events to the point where tons of stuff broke in my own mods, because they made their changes without considering the effects it'd have on those of us who use their tools for our own mods. A series of mods that I've spent almost two years developing is now in the trash because of their minor tweak to those events.

I definately share your frustration with Firaxis there, Spatzimaus.

I suppose I will have to make due with a sub-par version, despite how frustrating that will be in the long-term. I will have to consider the alternatives, I think.

In the meantime - I have been trying to make the hiding of buildings to work, but I can't seem to figure out how to do it. I decided to go with a seperate tag, rather than any NoLimit building with no cost (since it might conflict with some of the stuff that I, and the rest of the team I'm working with, have been discussing).

Here's what I have done (using this post as a base):

I've added a bHidden tag to the BuildingClasses table, and set it to true for the Palace, to use for testing.
Code:
ALTER TABLE BuildingClasses ADD COLUMN bHidden BOOLEAN DEFAULT false;
UPDATE BuildingClasses SET bHidden = 'true' WHERE Type = 'BUILDINGCLASS_PALACE';
And in CityView.lua, I've added this, encapsulating most of the function:
Code:
	local bHidden = GameInfo.BuildingClasses[building.BuildingClass].bHidden;
	if ( pCity:IsHasBuilding(buildingID) and not bHidden ) then
	end
The problem is that it doesn't show any building at all, regardless of whether bHidden is true or not for that particular building.

From use of prints, I have been able to determine that the tag is applied properly, and that the variable is populated with the right value. So my guess is that the placement of the if-statement is wrong.

So I guess my question is what, specifically, in the AddBuildingButton function should be contained in that if-statement, and what shouldn't be?
 
I decided to go with a seperate tag, rather than any NoLimit building with no cost (since it might conflict with some of the stuff that I, and the rest of the team I'm working with, have been discussing).

You're planning on having NoLimit buildings with cost=-1 (not buildable), but that you still want to be visible in the city screen? Note that the UI doesn't have any indicator of how many copies of a building there are, it'll just show one icon if you have any non-zero number of that building in the city, so it's not going to be really useful information. Of course, if you want to mod the UI to show how many copies of a building are in the city, then it'd be a significant improvement.

Yes, adding a new flag solves this; my main reason to not do that was that I structured my mods as a 4-mod set, with the Base mod providing all of the functionality the others used for their content. Doing an SQL schema addition wouldn't work for me, since I can't ensure the Base mod would load before the other mods try to set that new variable. The NoLimit/negative-cost method, on the other hand, doesn't suffer from that sort of dependency issue. In your case this isn't a problem, so go ahead and create a new variable.

So I guess my question is what, specifically, in the AddBuildingButton function should be contained in that if-statement, and what shouldn't be?

When I get home I can hopefully answer this; my Internet was out at home last night, and this isn't the sort of thing I can answer from work. But I should be able to point you to the exact spots to do this once I have the code in front of me.
 
You're planning on having NoLimit buildings with cost=-1 (not buildable), but that you still want to be visible in the city screen? Note that the UI doesn't have any indicator of how many copies of a building there are, it'll just show one icon if you have any non-zero number of that building in the city, so it's not going to be really useful information. Of course, if you want to mod the UI to show how many copies of a building are in the city, then it'd be a significant improvement.

Yes, adding a new flag solves this; my main reason to not do that was that I structured my mods as a 4-mod set, with the Base mod providing all of the functionality the others used for their content. Doing an SQL schema addition wouldn't work for me, since I can't ensure the Base mod would load before the other mods try to set that new variable. The NoLimit/negative-cost method, on the other hand, doesn't suffer from that sort of dependency issue. In your case this isn't a problem, so go ahead and create a new variable.
Well, the possibility of using visible, unbuildable and stacking buildings is definately there - it's a big project, and we've had similar things in the works before, with Rise from Erebus (never finalized, mind you, but still there).

Basically, I want to keep my options open.
When I get home I can hopefully answer this; my Internet was out at home last night, and this isn't the sort of thing I can answer from work. But I should be able to point you to the exact spots to do this once I have the code in front of me.

Great - thanks again for all the help.
 
So it turns out that it wasn't poor placement of the it-statement that was causing issues - it was keyword-inconsistency between the different languages that was the problem.

A tip for anyone else wanting to make bools - don't use true/false in the SQL or Lua; use 1/0 instead. Using true, True or TRUE in SQL makes it not register as true in Lua; it just seems to become a string or something. Very frustrating.
 
Back
Top Bottom