Giving great works with lua

Mewr11

Warlord
Joined
Dec 13, 2014
Messages
118
Location
Within 5 parsecs of beta centauri
Is it possible to use lua to give a great work to a player? I'm using Sukritact's E&D, and know it's possible to give a building with a filled great work slot, but would rather not give more slots, just another great work.

EDIT: Would giving the player the building and then destroying it work, or would that destroy the great work inside?
 
Is it possible to use lua to give a great work to a player? I'm using Sukritact's E&D, and know it's possible to give a building with a filled great work slot, but would rather not give more slots, just another great work.

EDIT: Would giving the player the building and then destroying it work, or would that destroy the great work inside?
See FramedArchitect's lua here. I looked quickly through it and he has code for moving a great work from a palace to another 'temporary' building, but it seems a bit complicated. He is using at least one method from here but I have no experience with trying to use the other methods he is using.
 
Depending on exactly what you wanted to do, I'd think the easiest thing would be to simply spawn a Great Writer/Artist/Musician and push the mission to create the appropriate Great Work. When I updated my Forest of Magic civ for Events and Decisions, I created an Event where you could get a free Great Work of Writing:

Code:
	--=========================================================
	-- Outcome 1
	--=========================================================
	Event_FOMPreciousThing.Outcomes[1] = {}
	Event_FOMPreciousThing.Outcomes[1].Name = "TXT_KEY_EVENT_FOM_PRECIOUS_THING_OUTCOME_1"
	Event_FOMPreciousThing.Outcomes[1].Desc = "TXT_KEY_EVENT_FOM_PRECIOUS_THING_OUTCOME_1_DESC"
	Event_FOMPreciousThing.Outcomes[1].CanFunc = (
		function(pPlayer)	
			local iGoldCost = math.ceil(100 * iMod)
			Event_FOMPreciousThing.Outcomes[1].Desc = Locale.ConvertTextKey("TXT_KEY_EVENT_FOM_PRECIOUS_THING_OUTCOME_1_DESC", iGoldCost)
			if not pPlayer:HasAvailableGreatWorkSlot(GameInfoTypes["GREAT_WORK_SLOT_LITERATURE"]) then return false end
			if pPlayer:GetGold() < iGoldCost then return false end
			return true
		end
		)
	Event_FOMPreciousThing.Outcomes[1].DoFunc = (
		function(pPlayer) 
		local iGoldCost = math.ceil(100 * iMod)
			pPlayer:ChangeGold(-iGoldCost) 
			pPlayer:InitUnit(GameInfoTypes["UNIT_WRITER"], pPlayer:GetCapitalCity():GetX(), pPlayer:GetCapitalCity():GetY()):PushMission(GameInfoTypes["MISSION_CREATE_GREAT_WORK"])
			
			JFD_SendNotification(pPlayer:GetID(), "NOTIFICATION_GENERIC", Locale.ConvertTextKey("TXT_KEY_EVENT_FOM_PRECIOUS_THING_OUTCOME_1_NOTIFICATION"), Locale.ConvertTextKey("TXT_KEY_EVENT_FOM_PRECIOUS_THING"))
		end)
 
I assumed he was wanting to give a specific Great Work, which can be done through a building but not so far as I know directly through lua great people creation. I wanted to allow for lua to specify which great work would be attached to a great person back when whoward was still active on the forum and he said there was no way through lua to specify the Great Work: you just get potluck based on the Great Person originally spawned by InitUnit().

I had previously run smuck into the fact that the Great Person from within the UnitType is random, and even if you try to 'rename' them, the original Great Work assigned remains.

I think there was a dll somewhere on the forum to force Great People correct to their Era, with their correct Great Work, but can't remember who/where that was.
 
Yeah, I wasn't sure if it was the case that he wanted a specific Great Work or not. But if he was just wanting a free random Great Work, I figured I'd at least give him the code I used. :3
 
Back
Top Bottom