User Tools

Site Tools


modding:best_practices

In progress — if I don't finish this within a day or two, smack me in IRC — need to take break — StarWeaver

Naming

Consistant naming practices help people work on or with your code. This includes yourself, after you've not looked at your own code for a while.

Pick a short, perhaps 3-5 character 'tag' for yourself for general use. If you're working on a particuarly massive project (think dockscreen framework or weapons extended), consider using giving the project it's own tag. Use this tag in all of your global names to avoid naming clashes.

In the examples on the wiki, 'wki' will be used as an example tag unless the code comes from a pre-existing source. [clunky… rewrite -wvr].

Unids

George's code uses short type-type prefixes reminiscent of one of the standard c/c++ variable styles. This is particuarly helpful when you have several different entities relating to the same concept; e.g. a ship that's also an item and has an overlay and a dockscreen named after it can share most of a name easily.

Using the unique modder tag on your unids makes it a little clearer where the types are coming from and lets other modders reference your unids with the same names you do, by just copying their entity definitions from the top of your file, and with no fear of name collisions.

The one exception is the unid for the extesnsion itself. You could make an appropriate name for each file if you like, but it's conventional otherwise to just use UNIDExtension for it. It's (typically?) only used in exactly one place per extension.

[todo: add table with each type, prefix george uses for it, and examples -wvr]

Global Variables and Functions

The global variable and function namespace (functions are stored as variables in tlisp) is a messy, large, and rather disorganized space (just check the output of sysGlobals to see it). It contains

  • All the builtin functions (list, objGetName)
  • All of the system global variables (gPlayerShip)
  • All the event variables (gScreen, aHitPos) which are left around without being cleared even when the event they were set for is over.
  • All of George's tlisp functions,

George's Function Prefixes

Universal functions, list adapted from head of Code.xml:

  • int - Internal functions (may change from version to version)
  • math - General math functions
  • obj - General object functions
  • scr - General functions relating to dock screens
  • str - General string functions
  • sys - General functions relating to star systems

Faction / entity specific functions

todo - move this to a list of george's acronyms and stuff

  • arc - (Iocrym) archive from Heretic
  • bam - Battle Arena Maximus
  • chr - Charon pirates
  • com - Commonwealth
  • csc - Commonwealth Star Carrier (from the fleet)
  • dom - Domina
  • flt - Commonwealth Fleet
  • her - Heretic
  • hua - Huari
  • kor - Korolov Shipping
  • mil - Commonwealth Militia
  • mrad - MRAD probe from Heretic
  • mne - Commonwealth Mining (any idea what the acronym stands for? -wvr)
  • neu - Neurohack device from Heretic
  • srv - Service? (used once in code.xml)
  • stk - St. Katherine's System
  • sun - Sung Slavers
  • ter - Teratons

todo - temporary - need it's own page

(arcQuestionHandler qIndex) Heretic.xml
(bamComputeArmorLevel theObj) BattleArena.xml
(bamComputeOpponentList baseObj arenaSkill arenaRep) BattleArena.xml
(bamComputePrize playerSkill playerRep opponentSkill prizeBonus) BattleArena.xml
(bamComputeReputation baseObj) BattleArena.xml
(bamComputeShieldLevel theObj) BattleArena.xml
(bamComputeSkill battleResults) BattleArena.xml
(bamComputeWeaponLevel theObj) BattleArena.xml
(bamCreateGladiator baseObj shipClass) BattleArena.xml
(bamCreateGladiatorBySkill baseObj arenaSkill) BattleArena.xml
(bamCreateMeleeOpponents sourceObj shipCount targetPlayerChance classFunc) BattleArena.xml
(bamDoorsClose arenaObj) BattleArena.xml
(bamDoorsOpen arenaObj) BattleArena.xml
(chrCancelRaiderOrders frigateObj) CharonPirates.xml
(chrComputeAmbushPos fromObj toObj) CharonPirates.xml
(chrCreateRaider frigateObj pos) CharonPirates.xml
(chrDeployFrigateRaid transportObj originObj destObj cargoValue) CharonPirates.xml
(chrDeployKronosaurus ) CharonPirates.xml
(chrGetPrimaryStronghold sourceObj) CharonPirates.xml
(chrOrderRaiders frigateObj order orderTarget orderData) CharonPirates.xml
(chrRaidTransport transportObj originObj destObj cargoValue) CharonPirates.xml
(comSealedContainerHack ) Commonwealth.xml
(comTrafficControl homeObj maxTraffic) Commonwealth.xml
(cscSquadronCreateShip theCSC theClass) CommonwealthFleet.xml
(cscSquadronDeployShip theCSC theClass) CommonwealthFleet.xml
(domGainXP xpGain) Domina.xml
(domGetLevel xp) Domina.xml
(domGetTimeRequired levelReq) Domina.xml
(domInitRelationship ) Domina.xml
(domInvokePower levelReq) Domina.xml
(domShowPower levelReq) Domina.xml
(fltOrderCheckPosition theCSC) CommonwealthFleet.xml
(herAttackInProgress theStation) Heretic.xml
(herStatus statusField) Heretic.xml
(herStatusClear statusField) Heretic.xml
(herStatusSet statusField theValue) Heretic.xml
(huaCheckExperience xp) Huari.xml
(huaHuariDestroyed theObj theDestroyer) Huari.xml
(huaIsGateToHuaramarca nodeID gateID nodesChecked) Huari.xml
(huaSungDestroyed theObj theDestroyer) Huari.xml
(intAmmoBoxOpen theContents) Code.xml
(intArmorEnhanceStatus result) Code.xml
(intArmorRepairAll theShip repairTech alwaysRepair) Code.xml
(intAsteroidOnMining miningDifficulty) Mining.xml
(intAutoInstall theSource theItem) Code.xml
(intBarricadeUse barricadeClass) Code.xml
(intBlackMarketBuyPrice thisItem) BlackMarket.xml
(intBlackMarketOnDestroy cost) BlackMarket.xml
(intBlackMarketPromotion) BlackMarket.xml
(intBlackMarketSellPrice thisItem) BlackMarket.xml
(intBushidoArmorEnhancement) CorporateHierarchy.xml
(intBushidoShieldEnhancement) CorporateHierarchy.xml
(intBushidoWeaponEnhancement) CorporateHierarchy.xml
(intBuyItems itemCount itemCost) Code.xml
(intCalcExplosionType theObj) Code.xml
(intCommonwealthCrime severity description) Commonwealth.xml
(intCommonwealthOnDestroy) Commonwealth.xml
(intCommonwealthOnInit prevScreen) Compatibility10.xml
(intComputeBuyPrice thisItem) Code.xml
(intComputeRandomEncounterCourse theObj theTarget) Code.xml
(intComputeRandomEncounterPos theTarget) Code.xml
(intComputeRandomEncounterPosEx ) Code.xml
(intComputeSellPrice thisItem) Code.xml
(intConsumeItem theObj theItem) Teratons.xml
(intContainerGetExplosionType theObj) Code.xml
(intContainerOnDamage theObj damageHP) Code.xml
(intCorporateCrime severity description) CorporateHierarchy.xml
(intCorporateGenerateEnhancement theItem) CorporateHierarchy.xml
(intCorporateOnDestroy) CorporateHierarchy.xml
(intCorporateOnInit prevScreen) Compatibility10.xml
(intDestroyItems theObj) Code.xml
(intEnhanceWeaponUse newMods damageType successText) UsefulItems.xml
(intFieldCrystalInstall enhancementType theLifetime) UsefulItems.xml
(intFieldCrystalUse newMods successText) UsefulItems.xml
(intFleetCreateWingmen aStation aCount theClass) CommonwealthFleet.xml
(intFleetCrime severity description) CommonwealthFleet.xml
(intFleetDisperseWingmen aStation aCount) CommonwealthFleet.xml
(intFleetPromotion) CommonwealthFleet.xml
(intGetGateToSystem theSource destSystem) Code.xml
(intGetGlobalAchievements ) Code.xml
(intHPEnhancement1) CorporateHierarchy.xml
(intHPEnhancement2) CorporateHierarchy.xml
(intHPEnhancement3) CorporateHierarchy.xml
(intInstallAfterPurchase theItem theInstallCriteria theInstallMargin itemCost) Compatibility10.xml
(intInstallDevicePrep thisItem costToInstall isItemInCargo buyAndInstall varCanInstall varCost varDesc) Compatibility10.xml
(intIsGateToSystem nodeID gateID destSystem nodesChecked) Code.xml
(intItemEnhanceStatus result successText itemName) Code.xml
(intJettisonItem theObj theItem) Code.xml
(intLootAllItems theSource theDest criteria) Code.xml
(intMakayevArmorEnhancement) CorporateHierarchy.xml
(intMakayevWeaponEnhancement) CorporateHierarchy.xml
(intMissionAchievementString missionsCompleted missionsFailed) Code.xml
(intMissionRewardPayment theReward) PlayerShip.xml
(intRandomMessage source staticVar altVar) Code.xml
(intRasiermesserArmorEnhancement) Rasiermesser.xml
(intRasiermesserWeaponEnhancement) Rasiermesser.xml
(intRingerBuyMargin thisItem) Compatibility10.xml
(intRingerCrime severity description) Ringers.xml
(intRingerInstallDevicePrep thisItem costToInstall isItemInCargo) Compatibility10.xml
(intRingerOnDestroy) Ringers.xml
(intRingerOnInit prevScreen) Compatibility10.xml
(intRingerSellMargin thisItem) Compatibility10.xml
(intRoundDown value multiple) Code.xml
(intRoundUp value multiple) Code.xml
(intSellItems itemCount itemCost) Code.xml
(intSetCompatibleFuel fuelList) Compatibility10.xml
(intSetCompatibleFuelEx fuelList) Code.xml
(intTaikonBuyMargin thisItem) Compatibility10.xml
(intTeratonBuyMargin thisItem) Compatibility10.xml
(intTeratonGetLevelCurve value theItem) Teratons.xml
(intTeratonGetValue value theItem) Teratons.xml
(intTeratonMugging destination) Teratons.xml
(intTeratonSellMargin thisItem) Compatibility10.xml
(intZoanthropeOnObjDestroyed) DwargRaiders.xml
(intZoanthropeOnOrderChanged) DwargRaiders.xml
(korComputePlayerLevel ) KorolovShipping.xml
(korEmptyFreighter freighterObj) KorolovShipping.xml
(korEscortRecord shipClass) KorolovShipping.xml
(korFillFreighter freighterObj pricePerContainer) KorolovShipping.xml
(korFrigateDestroyed ) KorolovShipping.xml
(korInitialize ) KorolovShipping.xml
(korMissionFailure transObj) KorolovShipping.xml
(korMissionStrongholdSuccess missionXP destroyedByPlayer) KorolovShipping.xml
(korMissionSuccess transObj missionXP) KorolovShipping.xml
(korMsgWelcome playerLevel) KorolovShipping.xml
(korOnShipDestroyed ) KorolovShipping.xml
(mathProbTableLookup probTable) Code.xml
(milCanEnterCC ) CommonwealthMilitia.xml
(milInit ) CommonwealthMilitia.xml
(milMissionSuccess ) CommonwealthMilitia.xml
(milShowPromotionScreen returnScreen) CommonwealthMilitia.xml
(mneAllTargetsDestroyed sourceObj excludeObj) CommonwealthMining.xml
(mradDisplay probeObj anomalyPos displayField) Heretic.xml
(neuConsumeCharge ) Code.xml
(neuGetCharges ) Code.xml
(objAddItemByValue theObj theItem theValue theCurrency) Code.xml
(objGetFitCount theObj theItem) Code.xml
(objTranslateX theObj theMessage theDefault) Code.xml
(sacrificeEffect theObj) Transcendence.xml
(scrShowBuyScreen itemsToSell returnScreen installOptions) Code.xml
(scrShowSellScreen itemsToBuy returnScreen screenOptions) Code.xml
(srvFindRepairArmor theSource maxDist minLevel) Code.xml
(stkDistanceToStK nodeID nodesChecked) StKatharines.xml
(stkFreshFoodPrice theItem) StKatharines.xml
(stkFreshFoodStatus theItem) StKatharines.xml
(stkFreshFoodUpdate theSource theItem) StKatharines.xml
(strMassString mass) Code.xml
(strNumber theValue) Code.xml
(sunAttackTarget theCarrier theShip theTarget) SungSlavers.xml
(sunOrderWing theCarrier theOrder theTarget) SungSlavers.xml
(sysGetRandomOreType ) Code.xml
(terCreateDefender theNest) Teratons.xml
(useRepairArmor theItem theSegment) UsefulItems.xml
(intInstallDevicePrepEx fixme -wvr) Code.xml
modding/best_practices.txt · Last modified: 2014/12/27 04:40 (external edit)