• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

The Best @ Depressed #1

Recruit
16 Badges
Mar 22, 2018
6
0
  • Europa Universalis IV
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Call to arms event
  • Tyranny: Archon Edition
  • Surviving Mars
  • Surviving Mars: Digital Deluxe Edition
  • Shadowrun Returns
  • Shadowrun: Dragonfall
  • Shadowrun: Hong Kong
  • Surviving Mars: First Colony Edition
  • Surviving Mars: First Colony Edition
  • Age of Wonders: Planetfall
  • Age of Wonders: Planetfall Deluxe edition
  • Age of Wonders: Planetfall Premium edition
  • Age of Wonders: Planetfall Season pass
  • Age of Wonders: Planetfall - Revelations
Hey everyone,

So I need to lock a building template that I've created from being seen/used by players. Catch is, I want it locked from everybody unless specifically unlocked by my commander profile - so I need to do it through a Code item.

Now I have been doing my best to learn from the documentation, but the sad truth is that I have no coding knowledge, and am picking this all up as I go.
SO!
The deets:
-- ---
-- ---
What I need: A specific building to be locked from gameplay until called upon.

What I've got: A mess of code possibilities that I Have no idea how to stick together. Disclaimer - even ignoring the inappropriate format, "GameApply" might not actually be a thing (or relevant). It's a guess. Though, technically, it's all a guess:

function GameApply(self, city) LockBuilding("Test")
end

Does this look... remotely accurate? That "Test" building needs to be locked away, so I can unlock it later. If anyone has any tips, I would be eternally grateful!
 
Here from my mod:
http://steamcommunity.com/sharedfiles/filedetails/?id=1339570684

I locked some power Buildings and replaced them with custom models.

-- Lock or Unlock buildings on game start / game load
function OnMsg.GameTimeStart()
LockBuilding("AtomicBattery")
LockBuilding("Battery_WaterFuelCell")
LockBuilding("SolarPanelBig")
if IsTechResearched("AtomicAccumulator") == nil then
LockBuilding("AA70")

else
UnlockBuilding("AA70")


end

end

function OnMsg.LoadGame()
LockBuilding("AtomicBattery")
LockBuilding("Battery_WaterFuelCell")
LockBuilding("SolarPanelBig")
if IsTechResearched("AtomicAccumulator") == nil then
LockBuilding("AA70")
else
UnlockBuilding("AA70")
end

end

-- Unlock buildings when tech is researched
function OnMsg.TechResearched(tech_id,city,first_time)

if tech_id == "AtomicAccumulator" then
UnlockBuilding("AA70")
LockBuilding("AtomicBattery")
end

end
 
Oh that is so perfect. It looks *incredibly* promising. Thank you so much--I've been obsessing over this for *days*.

It also gives me a bit of insight into what calls on what, which'll help me when playing with code in the future.

Thanks again, spannbeton. I wasn't banking on an answer. I totally appreciate it!