BE lua events // find methods of an instance.

mjjepper

Chieftain
Joined
Jan 16, 2012
Messages
29
As the Title specifies, what are all the Beyond Earth Lua events? Specifically, is there a way to trigger when an orbital unit is launched and when it is removed or destroyed? I have been using the CIV5 infos successfully for many things, but obviously orbital units break new ground.


Also, I have been wondering the following for a while: How do we get all of the methods/properties of an instance.

Code:
function OnUnitCreated( playerID, unitID, hexVec, unitType, cultureType, civID, primaryColor, secondaryColor, fogState, selected, military, notInvisible )
	pPlayer = Players[playerID];
	local pUnit = pPlayer:GetUnitByID(unitID);
	if (pUnit:IsOrbitalUnit()) then
		print( "  Unit Created: " .. tostring( playerID ) .. " " .. tostring( unitID ) .. " " .. fogState );
		print( "  Unit Name: " .. pUnit:GetName());
	end
end
Events.SerialEventUnitCreated.Add( OnUnitCreated );

Given the above code as an example, how can I iterate through all of pUnit's methods and print them to firetuner?
 
Without the source code, it's hard to say we have any definitive list of event listeners available to modders at this time. I'm not sure if this would work or not, but you could try something like this to print members of any given class:
Code:
 for index, var in ipairs(pUnit) do

print(tostring(index))

end

I used pUnit in my example as that's what you specifically asked about. Additionally, I believe printing the indexes as strings is going to be the best approach as that's what I believe is most likely to get you a method (ex.: IsOrbitalUnit()). It's also likely to return some number of tables as well depending on what class you try to do this with.

Outside of this, your best bet is to use a search feature capable of reading from multiple files (such as the one built into Notepad++). You'll at least be able to see every method the devs use somewhere in the Lua scripts (though I'm pretty confident there will be some unused ones exposed to Lua in the source code that we can't see right now).
 
Unfortunately, that won't work, as pUnit is not a table but a C++ object masquerading as a table, so you can't use pairs (nor ipairs) to iterate over it
 
As the Title specifies, what are all the Beyond Earth Lua events? Specifically, is there a way to trigger when an orbital unit is launched and when it is removed or destroyed? I have been using the CIV5 infos successfully for many things, but obviously orbital units break new ground.

Look in D:\Games\Steam\SteamApps\common\Sid Meier's Civilization Beyond Earth\assets\Gameplay\Lua for various new GameEvents.

OrbitalUnitLaunched(playerType, unitType, plotX, plotY) is the one you're looking for specifically.
 
All GameEvents used in the core Lua files

Code:
AlienNestDestroyed
BuildFinished
BuildingProcessed
CityCaptureComplete
CityCreated
CityIntrigueLevelChanged
CityWillBeKilled
CovertAgentArrivedInCity
CovertAgentCompletedOperation
CovertAgentRecruited
EarthlingSettlement
GoodyExplored
HostilitySet
LandmarkAction
OrbitalUnitLaunched
OutpostFounded
OutpostKilled
PlayerCityFounded
PlayerDiscoveredUnitType
PlayerDoTurn
PlayerKilled
PlayerOpinionChanged
ProjectProcessed
RequestStationSpawnChoice
StationDestroyed
StationKilled
StationTradeRouteCreated
StationWithdrawn
TeamsDeclaredWar
TeamTechResearched
TradeRouteCreated
UnitKilled
UnitSetXY

And all Events
Code:
AdvisorDisplayHide
AdvisorDisplayShow
AudioDebugChangeMusic
AudioPlay2DSound
BlurStateChange
CameraStartPitchingDown
CameraStartPitchingUp
CameraStartRotatingCCW
CameraStartRotatingCW
CameraStopPitchingDown
CameraStopPitchingUp
CameraStopRotatingCCW
CameraStopRotatingCW
ClearHexHighlightStyle
CombatPreviewUnitChanged
DisplayMovementIndicator
EndGameShow
EventOpenOptionsScreen
ExitToMainMenu
FrontEndPopup
GameplayFX
GenericWorldAnchor
GoToPediaHomePage
ImprovementSelection
ImprovementSiteFlagSelected
InitCityRangeStrike
LoadScreenClose
LocalMachineAppUpdate
MinimapClickedEvent
NotificationAdded
NotificationRemoved
OpenInfoCorner
OpenPlayerDealScreenEvent
ParticleEffectReloadRequested
ParticleEffectStatsRequested
PlayerChoseToLoadGame
PreGameDirty
RemoveAllArrowsEvent
RequestYieldDisplay
SearchForPediaEntry
SequenceGameInitComplete
SerialEventCameraIn
SerialEventCameraOut
SerialEventCameraStartMovingBack
SerialEventCameraStartMovingForward
SerialEventCameraStartMovingLeft
SerialEventCameraStartMovingRight
SerialEventCameraStopMovingBack
SerialEventCameraStopMovingForward
SerialEventCameraStopMovingLeft
SerialEventCameraStopMovingRight
SerialEventDawnOfManHide
SerialEventDawnOfManShow
SerialEventExitCityScreen
SerialEventGameMessagePopup
SerialEventGameMessagePopupProcessed
SerialEventGameMessagePopupShown
SerialEventHexGridOff
SerialEventHexGridOn
SerialEventHexHighlight
SerialEventImprovementCreated
SerialEventMouseOverHex
SerialEventSetOrbitalView
SerialEventStartGame
SerialEventToggleTechWeb
SerialEventUnitCreated
SerialEventUnitFlagSelected
SerialEventUnitInfoDirty
SerialEventUnitUpgradeScreenDirty
SetCovertOpsView
ShowMovementRange
SpawnArrowEvent
SpecificCityInfoDirty
SystemUpdateUI
UnitSelectionChanged
UserRequestClose
WorldMouseOver
 
I had attempted ipairs before posting this request for help. But man am I glad I asked. Thank you all! This is what I needed!
 
Top Bottom