How can I instantly trigger a event? (Events and Decisions)

Divine Yuri

Never Closes Chrome
Joined
Oct 28, 2014
Messages
89
Location
Brrrr, USA
Making a Civilization that has a secondary Trait if you are using Events and Decisions. This trait involves something I call "Scavenge" which is a event chain that fires up by destroying a Barbarian encampment, and has a risk vs reward situation where you can choose to take more things from the encampment before you burn it down but risk losing your unit and re-spawning the encampment.

I already have the encampment part working with the normal trait, but I can't seem to find a way to trigger the event right away. Maybe I'm missing something just can't seem to find anything with the keyword "Trigger" except in Sukritact's post that mentions you can trigger a event with a decision, but can't seem to find any information about that, only scheduling events which isn't what I want to do. Unless that will allow you to trigger it right away. :confused:

I guess my biggest thing is how are events handled? Is it connected to PlayerDoTurn? Feel like I've spent hours trying to find it myself. So I thought it was probably for the best if I just ask at this point :lol:.
 
... and re-spawning the encampment.

Note, that there is no Lua API to "spawn" (in the way that the game core understands "spawn") a barb encampment and if you use pPlot:SetImprovementType (GameInfoTypes.IMPROVEMENT_BARBARIAN_CAMP) (or whatever the correct type name is) it will only place the camp on the map and NOT add it to the list of camps that auto-magically spawn new Barbie units (unless you're using a modded DLL)
 
You can invoke LuaEvents.PushRandomEventPopup(Players[0], tEvents.Event_), where Event_ is the name of the event, e.g. 'Event_JFD_PS_Piety_BookBurning'.

Thank you. This is exactly what I needed. :D

Note, that there is no Lua API to "spawn" (in the way that the game core understands "spawn") a barb encampment and if you use pPlot:SetImprovementType (GameInfoTypes.IMPROVEMENT_BARBARIAN_CAMP) (or whatever the correct type name is) it will only place the camp on the map and NOT add it to the list of camps that auto-magically spawn new Barbie units (unless you're using a modded DLL)

Hmm, might limit it to destroying your unit then. Haven't tested spawning a barbarian encampment so I didn't know. Ohh well it was more for theme in my mind than any game play reasons.
 
You can invoke LuaEvents.PushRandomEventPopup(Players[0], tEvents.Event_), where Event_ is the name of the event, e.g. 'Event_JFD_PS_Piety_BookBurning'.

I know it's necro, but it's better than making a new page.

How would I invoke this in a function then? Would I need to set the function's page VFS to true, or what?
 
I know it's necro, but it's better than making a new page.

How would I invoke this in a function then? Would I need to set the function's page VFS to true, or what?

I found when trying the method it didn't work by itself in another lua file, but I got around it by making a new LuaEvent in the event file itself:
Code:
function Event_HighYouthTurnout_Test(pPlayer)
	 LuaEvents.PushRandomEventPopup(pPlayer, tEvents.Event_HighYouthTurnout)
end

LuaEvents.Event_HighYouthTurnout.Add(Event_HighYouthTurnout_Test)
The reason just using the push doesn't work is because within other files tEvents doesn't exist. So you need to push the event where it was made.

I also found that if the event .CanFunc returns false it won't trigger the event.
 
Back
Top Bottom