• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Need Help With Lua

  1. You have <RequiresFeature>1</RequiresFeature> in the improvement but no specification of the feature that is required so I am pretty sure you'll need to remove
    <RequiresFeature>1</RequiresFeature> in order for it to become buildable.
  2. TECH_CHEMISTRY is your prereq for the worker to build the improvement, so there really isn't any point in having
    Code:
    		<Row>
    			<ImprovementType>IMPROVEMENT_RESEARCH_STATION</ImprovementType>
    			<TechType>TECH_CHEMISTRY</TechType>
    			<YieldType>YIELD_SCIENCE</YieldType>
    			<Yield>1</Yield>
    		</Row>
    since this tech that enhances the improvement's yields is the same as the tech needed to "build" the improvement.
 
Other than those 2, is it ok? Also I changed the ART_DEF_IMPROVEMENT_RESEARCH_STATION to ART_DEF_IMPROVEMENT_BRAZILWOOD_CAMP (once I make art for the civ, I'll change it back.
 
It looks OK. But I never rely on "looks OK". I use error logging for errors showing up in the Database log, and then I use IGE to create the necessary conditions in a test-game to ensure that "it" is working as desired. I've had too many cases where code (XML, SQL, LUA) looked OK but was in fact utter rubbish.
 
So using this code, it worked, no errors in logs, however the pictures for building it change (initially it shows Fort icon, then changes to farm), and when you build it says "BUILD_RESEARCH_STATION" instead of "Research Station" in the improvements list.
Spoiler :
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
	<Improvements>
		<Row>
			<Type>IMPROVEMENT_RESEARCH_STATION</Type>
			<Description>TXT_KEY_IMPROVEMENT_RESEARCH_STATION</Description>
			<Civilopedia>TXT_KEY_CIV5_IMPROVEMENTS_RESEARCH_STATION_TEXT</Civilopedia>
			<Help>TXT_KEY_CIV5_IMPROVEMENTS_RESEARCH_STATION_HELP</Help>
			<ArtDefineTag>ART_DEF_IMPROVEMENT_BRAZILWOOD_CAMP</ArtDefineTag>
			<WorldSoundscapeAudioScript></WorldSoundscapeAudioScript>
			<ImprovementPillage></ImprovementPillage>
			<ImprovementUpgrade></ImprovementUpgrade>
			<SpecificCivRequired>1</SpecificCivRequired>
			<CivilizationType>CIVILIZATION_ANTARCTICA</CivilizationType>
			<HillsMakesValid>0</HillsMakesValid>
			<FreshWaterMakesValid>0</FreshWaterMakesValid>
			<RiverSideMakesValid>0</RiverSideMakesValid>
			<NoFreshWater>0</NoFreshWater>
			<RequiresFlatlands>0</RequiresFlatlands>
			<RequiresFlatlandsOrFreshWater>0</RequiresFlatlandsOrFreshWater>
			<RequiresFeature>0</RequiresFeature>
			<RequiresImprovement>0</RequiresImprovement>
			<RemovesResource>0</RemovesResource>
			<PromptWhenComplete>0</PromptWhenComplete>
			<Coastal>0</Coastal>
			<Water>0</Water>
			<DestroyedWhenPillaged>1</DestroyedWhenPillaged>
			<DisplacePillager>0</DisplacePillager>
			<BuildableOnResources>1</BuildableOnResources>
			<BarbarianCamp>0</BarbarianCamp>
			<Goody>0</Goody>
			<Permanent>0</Permanent>
			<OutsideBorders>0</OutsideBorders>
			<InAdjacentFriendly>0</InAdjacentFriendly>
			<IgnoreOwnership>0</IgnoreOwnership>
			<OnlyCityStateTerritory>0</OnlyCityStateTerritory>
			<GraphicalOnly>0</GraphicalOnly>
			<CreatedByGreatPerson>0</CreatedByGreatPerson>
			<NoTwoAdjacent>0</NoTwoAdjacent>
			<AdjacentLuxury>0</AdjacentLuxury>
			<AllowsWalkWater>0</AllowsWalkWater>
			<CultureAdjacentSameType>0</CultureAdjacentSameType>
			<TilesPerGoody>0</TilesPerGoody>
			<GoodyRange>0</GoodyRange>
			<FeatureGrowth>0</FeatureGrowth>
			<UpgradeTime>0</UpgradeTime>
			<RiverSideUpgradeMod>0</RiverSideUpgradeMod>
			<CoastalLandUpgradeMod>0</CoastalLandUpgradeMod>
			<HillsUpgradeMod>0</HillsUpgradeMod>
			<FreshWaterUpgradeMod>0</FreshWaterUpgradeMod>
			<DefenseModifier>0</DefenseModifier>
			<NearbyEnemyDamage>0</NearbyEnemyDamage>
			<PillageGold>10</PillageGold>
			<ResourceExtractionMod>0</ResourceExtractionMod>
			<LuxuryCopiesSiphonedFromMinor>0</LuxuryCopiesSiphonedFromMinor>
			<GoldMaintenance>0</GoldMaintenance>
			<CultureBombRadius>0</CultureBombRadius>
			<RequiresXAdjacentLand>-1</RequiresXAdjacentLand>
			<PortraitIndex>1</PortraitIndex>
			<IconAtlas>TERRAIN_IMPROVEMENT_ICON_ATLAS_EXP2</IconAtlas>
		</Row>
	</Improvements>

	<!-- Trait_ImprovementYieldChanges -->
	<!-- Policy_ImprovementYieldChanges -->
	<!-- Policy_ImprovementCultureChanges -->
	<!-- Belief_ImprovementYieldChanges -->
	<!-- Improvement_Flavors -->
	<Improvement_Yields>
		<Row>
			<ImprovementType>IMPROVEMENT_RESEARCH_STATION</ImprovementType>
			<YieldType>YIELD_FOOD</YieldType>
			<Yield>1</Yield>
		</Row>
		<Row>
			<ImprovementType>IMPROVEMENT_RESEARCH_STATION</ImprovementType>
			<YieldType>YIELD_SCIENCE</YieldType>
			<Yield>2</Yield>
		</Row>
	</Improvement_Yields>
	<!-- Improvement_YieldPerEra -->
	<!-- Improvement_AdjacentCityYields -->
	<!-- Improvement_CoastalLandYields -->
	<!-- Improvement_FreshWaterYields -->
	<!-- Improvement_HillsYields -->
	<!-- Improvement_AdjacentMountainYieldChanges -->
	<!-- Improvement_PrereqNatureYields -->
	<!-- Improvement_RiverSideYields -->
	<Improvement_ValidTerrains>
		<Row>
			<ImprovementType>IMPROVEMENT_RESEARCH_STATION</ImprovementType>
			<TerrainType>TERRAIN_SNOW</TerrainType>
		</Row>
	</Improvement_ValidTerrains>
	<!-- Improvement_ValidTerrains -->
	<!-- Improvement_ValidImprovements -->
	<!-- Improvement_ResourceTypes -->
	<!-- Improvement_ResourceType_Yields -->
	<!-- Improvement_RouteYieldChanges -->
	<Improvement_TechYieldChanges>
		<Row>
			<ImprovementType>IMPROVEMENT_RESEARCH_STATION</ImprovementType>
			<TechType>TECH_PENICILLIN</TechType>
			<YieldType>YIELD_SCIENCE</YieldType>
			<Yield>1</Yield>
		</Row>
		<Row>
			<ImprovementType>IMPROVEMENT_RESEARCH_STATION</ImprovementType>
			<TechType>TECH_SCIENTIFIC_THEORY</TechType>
			<YieldType>YIELD_SCIENCE</YieldType>
			<Yield>1</Yield>
		</Row>
		<Row>
			<ImprovementType>IMPROVEMENT_RESEARCH_STATION</ImprovementType>
			<TechType>TECH_BIOLOGY</TechType>
			<YieldType>YIELD_SCIENCE</YieldType>
			<Yield>1</Yield>
		</Row>
		<Row>
			<ImprovementType>IMPROVEMENT_RESEARCH_STATION</ImprovementType>
			<TechType>TECH_REFRIGERATION</TechType>
			<YieldType>YIELD_SCIENCE</YieldType>
			<Yield>1</Yield>
		</Row>
	</Improvement_TechYieldChanges>
	<!-- Improvement_TechNoFreshWaterYieldChanges -->
	<!-- Improvement_TechFreshWaterYieldChanges -->

	<Builds>
		<Row>
			<Type>BUILD_RESEARCH_STATION</Type>
			<PrereqTech>TECH_CHEMISTRY</PrereqTech>
			<Time>600</Time>
			<ImprovementType>IMPROVEMENT_RESEARCH_STATION</ImprovementType>
			<Recommendation>TXT_KEY_BUILD_RESEARCH_STATION_REC</Recommendation>
			<EntityEvent>ENTITY_EVENT_BUILD</EntityEvent>
			<HotKey>KB_F</HotKey>
			<OrderPriority>1</OrderPriority>
			<CtrlDown>1</CtrlDown>
			<IconIndex>30</IconIndex>
			<IconAtlas>UNIT_ACTION_ATLAS</IconAtlas>
		</Row>
	</Builds>
	<BuildFeatures>
	</BuildFeatures>
	<Unit_Builds>
		<Row>
			<UnitType>UNIT_WORKER</UnitType>
			<BuildType>BUILD_RESEARCH_STATION</BuildType>
		</Row>
	</Unit_Builds>
	
	<Language_en_US>
		<Row Tag="TXT_KEY_IMPROVEMENT_RESEARCH_STATION">
			<Text>Research Station</Text>
		</Row>
		<Row Tag="TXT_KEY_CIV5_IMPROVEMENTS_RESEARCH_STATION_TEXT">
			<Text>
				<!-- Add Civilopedia text here -->
			</Text>
		</Row>
		<Row Tag="TXT_KEY_CIV5_IMPROVEMENTS_RESEARCH_STATION_HELP">
			<Text>A Research Station can be built only on Snow.  It gives +1 [ICON_FOOD] Food and +2 [ICON_RESEARCH] Science and the Science amount increases by 1 after researching Chemistry, Scientific Theory, and Biology.</Text>
		</Row>
	</Language_en_US>
</GameData>
 
I'm not sure what changed, but with exact code posted there, it stopped working, and improvement won't show at all.
 

Attachments

Nevermind, got it to work, but how do I do the Tourism ability? I understand I create a decoy building, but how exactly do I code this? Can somebody please just copy + paste code to do this?
 
Is there a way to change Science value without using a building? If so, I could do it using the GetBaseTourism() function, then adding the value to the research output.
 
Is there a way to change Science value without using a building? If so, I could do it using the GetBaseTourism() function, then adding the value to the research output.
Your problem is that there is no City:ChangeScience() or City:SetScience() or Player:ChangeScience() or Player:SetScience() method available in the game's API. Nor are there any for Teams. Nor are there any done as either "SetResearch()" or "ChangeResearch()". Hence the advice to use a dummy building.

The link in my sig called "Dummy Buildings, and Building-Class Structure Issues with Certain Building Effects" takes you to a thread where I also have an example or two of how to create a dummy building in xml, and then how to place the dummy building into cities via an lua script. Here
 
You were very close in your OP, which is why we kept trying to explain how to fish rather than giving you a fish.

Spoiler lua script :
Code:
local civilizationID = GameInfoTypes["CIVILIZATION_ANTARCTICA"]
local iScienceTransmutationBuilding = GameInfoTypes["BUILDING_SOMETHING_OR_OTHER"]

function Antarctica_TourismIntoScience(playerID)
	local player = Players[playerID]
	if player:GetCivilizationType() == civilizationID) then 
		for city in player:Cities() do
			city:SetNumRealBuilding(iScienceTransmutationBuilding, city:GetBaseTourism())
		end
	end
end
GameEvents.PlayerDoTurn.Add(Antarctica_TourismIntoScience)

You will have to create the dummy building that gives +1 science for every copy of the building, and you will have to change BUILDING_SOMETHING_OR_OTHER to the correct XML designation that you use for the dummy building. If you don't know how to make a building give +1 Science per turn, Top of This Post
 
Should I separate it into 2 mods - one adding a decoy building to the game that no civilizations can get using XML, and the other added to the civilization that allows the civ to get the buildings automatically. In other words, if I put it into 1 mod, how do I make the building a building type globally defined and not just a building only available to 1 civ that replaces a building that doesn't exist.
 
Should I separate it into 2 mods - one adding a decoy building to the game that no civilizations can get using XML, and the other added to the civilization that allows the civ to get the buildings automatically. In other words, if I put it into 1 mod, how do I make the building a building type globally defined and not just a building only available to 1 civ that replaces a building that doesn't exist.
  1. You handle the building as shown in the link on Dummy Buildings, etc., that I referenced you to earlier.
  2. You put everything into the same mod. Other than the fact that no one can normally construct the building, the game treats the dummy building no differently than any other, and you don't treat it any differently within ModBuddy and within your XML than you would for any 'normal' building.
  3. But since you are adding the building to cities via lua, you don't state that it is a unique to your civilization under table <Civilization_BuildingClassOverrides>.
  4. When you structure the dummy building and its building-class as shown in the link I referred to earlier no one will be able to construct the building because <Cost> is set to "-1". So the only way the building becomes available is through the lua script, and the lua script handles which civilization(s) can get the building in their cities.
 
Dummy building is working (shows up and works fine using In Game Editor) but my Tourism isn't turning into Science. I'm not sure if it's the building not giving Science, or if it's the building just not showing up for each point of Tourism.
 

Attachments

Change the code in the lua file to this
Code:
local civilizationID = GameInfoTypes["CIVILIZATION_ANTARCTICA"]
local iScienceTransmutationBuilding = GameInfoTypes["BUILDING_SCIENCE_DUMMY"]

function Antarctica_TourismIntoScience(playerID)
	local player = Players[playerID]
	if player:GetCivilizationType() == civilizationID then 
		for city in player:Cities() do
			city:SetNumRealBuilding(iScienceTransmutationBuilding, city:GetBaseTourism())
		end
	end
end
GameEvents.PlayerDoTurn.Add(Antarctica_TourismIntoScience)

print("Antarctica_TourismIntoScience loaded to the end")
There was a small syntax error in the previous code (an extra ')' ). Runs fine now.
 
Back
Top Bottom