Announcement

Collapse
No announcement yet.

dir() python introspection

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • dir() python introspection

    dir is a python builtin to introspect the objects namespace.

    Start Civ4, enter a game, enter python console SHIFT ` on US keyboards i think... or Shift-~ (on german keyboard layout it is SHIFT+ö)

    you then are in a python console. to see the Civ python namespace normally it would suffice to just type 'dir()'. That should print out the list of objects... after some thinking: it is

    Code:
      print dir()
    you can also dir() any object... for example. The reason why you need to explicitely print it in Civ4 probably is that the sys output got redirected.

    Code:
    >>a = 1
    >>dir(a)
    ['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delat
    tr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__getat
    tribute__', '__getnewargs__', '__hash__', '__hex__', '__init__', '__int__', '__i
    nvert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__',
    '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__'
    , '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloo
    rdiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshif
    t__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__st
    r__', '__sub__', '__truediv__', '__xor__']
    anyway...

    Calling dir form the Civ4 python console gives me

    Code:
      ['ActionSubTypes', 'ActivationTypes', 'ActivityTypes', 'AnimationCategoryTypes', ...] <- a LOT more
    since this is not nice to read just import something that prints pretty like umm for example prettyprint (pprint)

    Code:
    >>import pprint
    >>pprint.pprint(dir())
    ['ActionSubTypes',
     'ActivationTypes',
     'ActivityTypes',
     'AnimationCategoryTypes',
     'AnimationPathTypes',
     'AnimationTypes',
     'Archipelago',
     'AreaAITypes',
     'ArtStyleTypes',
     'AttitudeTypes',
     'AutomateTypes',
     'Balanced',
     'BonusClassTypes',
     'BonusTypes',
     'BuildTypes',
     'BuildingClassTypes',
     'BuildingTypes',
     'ButtonPopupTypes',
     'ButtonStyles',
     'CalendarTypes',
     'CameraFlyingCB',
     'CameraLookAtTypes',
     'CameraMovementSpeeds',
     'CardinalDirectionTypes',
     'CheckBoxStates',
     'CitySizeTypes',
     'CityTabTypes',
     'CivicOptionTypes',
     'CivicTypes',
     'CivilizationTypes',
     'CivilopediaPageTypes',
     'ClimateTypes',
     'ColorTypes',
     'CombatDetails',
     'CommandTypes',
     'CommerceTypes',
     'ConceptTypes',
     'ContactTypes',
     'Continents',
     'ControlTypes',
     'CultureLevelTypes',
     'CursorTypes',
     'CustomMapOptionTypes',
     'Custom_Continents',
     'CutTreesCB',
     'CvActionInfo',
     'CvAppInterface',
     'CvArtInfoAsset',
     'CvArtInfoBonus',
     'CvArtInfoBuilding',
     'CvArtInfoCivilization',
     'CvArtInfoFeature',
     'CvArtInfoImprovement',
     'CvArtInfoInterface',
     'CvArtInfoLeaderhead',
     'CvArtInfoMisc',
     'CvArtInfoMovie',
     'CvArtInfoScalableAsset',
     'CvArtInfoTerrain',
     'CvArtInfoUnit',
     'CvAssetInfoBase',
     'CvAutomateInfo',
     'CvBonusClassInfo',
     'CvBonusInfo',
     'CvBuildInfo',
     'CvBuildingClassInfo',
     'CvBuildingInfo',
     'CvCivicInfo',
     'CvCivicOptionInfo',
     'CvCivilizationInfo',
     'CvClimateInfo',
     'CvColorInfo',
     'CvCommandInfo',
     'CvCommerceInfo',
     'CvControlInfo',
     'CvCultureLevelInfo',
     'CvDiplomacyInfo',
     'CvDiplomacyTextInfo',
     'CvEffectInfo',
     'CvEmphasizeInfo',
     'CvEraInfo',
     'CvEventInterface',
     'CvFeatureInfo',
     'CvForceControlInfo',
     'CvGameInterface',
     'CvGameOptionInfo',
     'CvGameSpeedInfo',
     'CvGameText',
     'CvGoodyInfo',
     'CvGraphicOptionInfo',
     'CvHandicapInfo',
     'CvHurryInfo',
     'CvImprovementBonusInfo',
     'CvImprovementInfo',
     'CvInfoBase',
     'CvLeaderHeadInfo',
     'CvMPOptionInfo',
     'CvMapScriptInterface',
     'CvMissionInfo',
     'CvPlayerColorInfo',
     'CvPlayerOptionInfo',
     'CvProcessInfo',
     'CvProjectInfo',
     'CvPromotionInfo',
     'CvQuestInfo',
     'CvReligionInfo',
     'CvRouteInfo',
     'CvRouteModelInfo',
     'CvScalableInfo',
     'CvSeaLevelInfo',
     'CvSpecialBuildingInfo',
     'CvSpecialUnitInfo',
     'CvSpecialistInfo',
     'CvTechInfo',
     'CvTerrainInfo',
     'CvTraitInfo',
     'CvTranslator',
     'CvTurnTimerInfo',
     'CvTutorialInfo',
     'CvTutorialMessage',
     'CvUnitClassInfo',
     'CvUnitInfo',
     'CvUpkeepInfo',
     'CvVictoryInfo',
     'CvVoteInfo',
     'CvWBInterface',
     'CvWorldInfo',
     'CvYieldInfo',
     'CyArea',
     'CyArtFileMgr',
     'CyAudioGame',
     'CyCamera',
     'CyCity',
     'CyDeal',
     'CyDiplomacy',
     'CyEngine',
     'CyFractal',
     'CyGFlyoutMenu',
     'CyGInterfaceScreen',
     'CyGTabCtrl',
     'CyGame',
     'CyGameTextMgr',
     'CyGlobalContext',
     'CyGlobeLayer',
     'CyGlobeLayerManager',
     'CyHallOfFameInfo',
     'CyInterface',
     'CyInterfaceScreen',
     'CyMap',
     'CyMapGenerator',
     'CyMessageControl',
     'CyPitboss',
     'CyPlayer',
     'CyPlot',
     'CyPopup',
     'CyPopupInfo',
     'CyPopupReturn',
     'CyPythonMgr',
     'CyRandom',
     'CyReplayInfo',
     'CySelectionGroup',
     'CySign',
     'CyStatistics',
     'CyTeam',
     'CyTranslator',
     'CyUnit',
     'CyUnitEntity',
     'CyUnitSubEntity',
     'CyUserProfile',
     'CyVariableSystem',
     'DLLProfilerCB',
     'DenialTypes',
     'DiploCommentTypes',
     'DiploEventTypes',
     'DiplomacyPowerTypes',
     'Direct3DQueryCB',
     'DirectionTypes',
     'DisableTextureCB',
     'DisplayCutTreesCB',
     'DisplayCutTreesProfileCB',
     'DisplayQuadTreeCB',
     'DomainTypes',
     'DumpGeoStatsCB',
     'EmphasizeTypes',
     'EndTurnButtonStates',
     'EngineDirtyBits',
     'EntityEventTypes',
     'EraTypes',
     'EventContextTypes',
     'EventMessage',
     'FOWInfo',
     'FOWVis',
     'FeatTypes',
     'FeatureTypes',
     'FlavorTypes',
     'FogOfWarModeTypes',
     'FogofWarCB',
     'FontSymbols',
     'FontTypes',
     'ForceControlTypes',
     'FreezeCamera',
     'FullScreenCB',
     'GameMessageTypes',
     'GameOptionTypes',
     'GameResetUnitsCB',
     'GameSpeedTypes',
     'GameStateTypes',
     'GameToggleDiplomacyLoggingCB',
     'GameTurnInfo',
     'GamebryoCB',
     'GenericButtonSizes',
     'GlobeViewCB',
     'GoodyTypes',
     'GraphicOptionTypes',
     'Great_Plains',
     'GridModeCB',
     'HandicapTypes',
     'HealthBarTypes',
     'HideAllCB',
     'HideBarsCB',
     'HideBeamsCB',
     'HideBonusesCB',
     'HideBuildingsCB',
     'HideCityBillboardsCB',
     'HideCultureCB',
     'HideCursorCB',
     'HideDecalsCB',
     'HideEffectsCB',
     'HideEntitiesCB',
     'HideFeaturesCB',
     'HideFlagsCB',
     'HideGenericBuildingsCB',
     'HideRoutesCB',
     'HideSubUnitsCB',
     'HideSymbolsCB',
     'HideTerrainCB',
     'HideUnitEntitiesCB',
     'HideWaterCB',
     'HideWavesCB',
     'Highlands',
     'HitTestTypes',
     'Hub',
     'HurryTypes',
     'IDInfo',
     'Ice_Age',
     'ImprovementTypes',
     'InfoBarTypes',
     'Inland_Sea',
     'InputTypes',
     'InterfaceDirtyBits',
     'InterfaceModeTypes',
     'InterfaceVisibility',
     'InvisibleTypes',
     'Islands',
     'Lakes',
     'LeaderHeadTypes',
     'LeaderheadAction',
     'LockQuadTreeVisCB',
     'Maze',
     'MemoryTypes',
     'MinimapModeTypes',
     'Mirror',
     'MissionAITypes',
     'MissionData',
     'MissionTypes',
     'MonthTypes',
     'MouseFlags',
     'MultiplayerOptionTypes',
     'MusicCB',
     'NiColorA',
     'NiMatrix3',
     'NiPoint2',
     'NiPoint3',
     'NiTextOut',
     'NotifyCode',
     'Oasis',
     'OrderData',
     'OrderTypes',
     'PBGameSetupData',
     'PBPlayerAdminData',
     'PBPlayerSetupData',
     'PFEnableCB',
     'PFUpdateCB',
     'POINT',
     'PanelStyles',
     'Pangaea',
     'PauseEngineCB',
     'PlayerColorTypes',
     'PlayerOptionTypes',
     'PlayerTypes',
     'PlotLandscapeLayers',
     'PlotStyles',
     'PlotTypes',
     'PopupStates',
     'ProbabilityTypes',
     'ProcessTypes',
     'ProfilerCB',
     'ProfilerResetMinMaxCB',
     'ProfilerTurnLockOnCB',
     'ProjectTypes',
     'PromotionTypes',
     'RSEnableCB',
     'RedrawGlobeViewCB',
     'RedrawMinimapCB',
     'ReligionTypes',
     'ReplayMessageTypes',
     'Ring',
     'RiverTypes',
     'RouteTypes',
     'SeaLevelTypes',
     'SeasonTypes',
     'ShaderDescCB',
     'ShowEntityBoundingSpheresCB',
     'ShowOnlyAlphaSortingCB',
     'ShowTerrainBoundingSpheresCB',
     'SlowMotionCB',
     'SpecialBuildingTypes',
     'SpecialistTypes',
     'SunLightDebugCB',
     'SymbolTypes',
     'TabGroupTypes',
     'TableStyles',
     'TaskTypes',
     'TeamTypes',
     'Team_Battleground',
     'TechTypes',
     'Terra',
     'TerrainCameraCB',
     'TerrainNormalsCB',
     'TerrainScreenCapCB',
     'TerrainTypes',
     'TestDebugText',
     'Tilted_Axis',
     'ToggleDecLandLODCB',
     'ToggleIncLandLODCB',
     'ToolTipAlignTypes',
     'TradeData',
     'TradeableItems',
     'TraitTypes',
     'TurnTimerTypes',
     'UnitAITypes',
     'UnitClassTypes',
     'UnitDebugMenuCB',
     'UnitLightDebugCB',
     'UnitTypes',
     'UpdateCultureCB',
     'UpkeepTypes',
     'VictoryTypes',
     'VoteTypes',
     'WarPlanTypes',
     'Wheel',
     'WidgetAnim',
     'WidgetTypes',
     'WireframeCB',
     'WorldBuilderPopupTypes',
     'WorldSizeTypes',
     'WriteFogWarTextureCB',
     'XYCoords',
     'YieldTypes',
     'ZoomLevelTypes',
     '__builtins__',
     '__doc__',
     '__name__',
     'addImportModule',
     'addWBPlayerControlTabs',
     'atWar',
     'callUpdater',
     'cardinalDirectionToDirection',
     'directionXY',
     'directionXYFromPlot',
     'dxWrap',
     'dyWrap',
     'f',
     'false',
     'finalImprovementUpgrade',
     'gc',
     'getAlarmHour',
     'getAlarmHourLeft',
     'getAlarmMin',
     'getAlarmMinLeft',
     'getChtLvl',
     'getClockText',
     'getCyDefinesVarSystem',
     'getEra',
     'getExeLinkDate',
     'getLandPlotsAsset',
     'getLandPlotsScore',
     'getModulePathName',
     'getOppositeCardinalDirection',
     'getPopulationAsset',
     'getPopulationPower',
     'getPopulationScore',
     'getSyncRandomSeed',
     'getTechScore',
     'getWBSaveExtension',
     'getWBSaveFolder',
     'getWBToolEditTabCtrl',
     'getWBToolNormalMapTabCtrl',
     'getWBToolNormalPlayerTabCtrl',
     'getWonderScore',
     'imp',
     'initWBToolEditCtrl',
     'initWBToolEditCtrlTab',
     'initWBToolPlayerControl',
     'isAlarmOn',
     'isLimitedProject',
     'isLimitedUnitClass',
     'isLimitedWonderClass',
     'isMouseOverGameSurface',
     'isNationalUnitClass',
     'isNationalWonderClass',
     'isPotentialEnemy',
     'isPromotionValid',
     'isTeamProject',
     'isTeamUnitClass',
     'isTeamWonderClass',
     'isTechRequiredForBuilding',
     'isTechRequiredForProject',
     'isTechRequiredForUnit',
     'isWorldProject',
     'isWorldUnitClass',
     'isWorldWonderClass',
     'loadImportModule',
     'myDbgOutput',
     'myErrOutput',
     'myImportHandler',
     'plotCardinalDirection',
     'plotCity',
     'plotCityXY',
     'plotCityXYFromCity',
     'plotDirection',
     'plotDistance',
     'plotXY',
     'pprint',
     'refreshWBEditCtrlReligionButtons',
     'setAlarmHour',
     'setAlarmMin',
     'setFocusToCVG',
     'setHeights',
     'setWBInitialCtrlTabPlacement',
     'shuffleList',
     'splotCardinalDirection',
     'splotXY',
     'stepDistance',
     'sys',
     'toggleAlarm',
     'true',
     'updateGameProgressBar']
    Well, lets see what we can do with that info spam...

    Code:
    >> pprint.pprint(dir(TerrainTypes))
    ['NO_TERRAIN',
     '__abs__',
     '__add__',
     '__and__',
     '__class__',
     '__cmp__',
     '__coerce__',
     '__delattr__',
     '__div__',
     '__divmod__',
     '__doc__',
     '__float__',
     '__floordiv__',
     '__getattribute__',
     '__getnewargs__',
     '__hash__',
     '__hex__',
     '__init__',
     '__int__',
     '__invert__',
     '__long__',
     '__lshift__',
     '__mod__',
     '__module__',
     '__mul__',
     '__neg__',
     '__new__',
     '__nonzero__',
     '__oct__',
     '__or__',
     '__pos__',
     '__pow__',
     '__radd__',
     '__rand__',
     '__rdiv__',
     '__rdivmod__',
     '__reduce__',
     '__reduce_ex__',
     '__repr__',
     '__rfloordiv__',
     '__rlshift__',
     '__rmod__',
     '__rmul__',
     '__ror__',
     '__rpow__',
     '__rrshift__',
     '__rshift__',
     '__rsub__',
     '__rtruediv__',
     '__rxor__',
     '__setattr__',
     '__slots__',
     '__str__',
     '__sub__',
     '__truediv__',
     '__xor__',
     'name',
     'values']
    and so on... happy exploring
    Last edited by Lafferty; November 6, 2005, 17:08.

  • #2
    Do you need to set any flags to be able to open the console?

    SHIFT + ~ does nothing for me

    Comment


    • #3
      yeah...

      Since i modified so many things in my .ini i can only give you a wild guess

      Code:
      CheatCode = chipotle

      Comment


      • #4
        Originally posted by Lafferty
        yeah...

        Since i modified so many things in my .ini i can only give you a wild guess

        Code:
        CheatCode = chipotle
        nice, that did it!

        Comment

        Working...
        X