0 of 0

File information

Last updated

Original upload

Created by

Kingpin RBD

Uploaded by

Kingpin26

Virus scan

Safe to use

Tags for this mod

About this mod

A dependency for most of my mods.

Requirements
Permissions and credits
Changelogs
Donations
A dependency for most of my mods. I'm basically just releasing this to avoid having to include separate copies with all my mods. I'm only including code I wrote that ended up getting repurposed across multiple mods & that I foresee a need for in the future. At present, that includes code for easy item tracking. Basically, it gives multiple methods for creating item references which come auto-generated with useful properties/values allowing me to save a lot of time & codespace.

For example, if you know the ID for an item for an item:
Spoiler:  
Show

import KingCode.ItemTracking.*

public class SomeClass {

public let owner: ref<GameObject>;
public let targetID: ItemID;
public let targetRef: DetailedItemRef;

public Initialize() {
this.SomeFunc();
}

public func SomeFunc() {
this.owner = GetOwnerRefSomehow();
this.targetID = GetTargetIDSomehow();
this.targetRef = ItemInfoHelper.CreateItemRef(this.targetID, this.owner);
}

//Get target item's type
public func GetItemType() -> gamedataItemType {
return this.targetRef.itemType;
}

//Get target item's equip area
public func GetItemType() -> SEquipArea {
return this.targetRef.equipArea;
}

//Get target item's equip slot
public func GetItemType() -> SEquipSlot {
return this.targetRef.equipSlot;
}

//Get target item's data
public func GetItemType() -> wref<gameItemData> {
return this.targetRef.itemData;
}

}

DetailedItemRef(s) provide quick access to all of the following useful item details: owner, itemID, itemRecord, itemData, itemName, itemType, itemCategory, inventoryItemData, equipArea, equipAreaType, equipAreaIndex, equipAreaSize, equipSlot, slotID, slotIndex, & playerData.

DetailedItemRef(s) can be obtained using a variety of functions:

To obtain an array of DetailedItemRef(s) from a given equip area: ItemInfoHelper.GetEquipAreaItemInfo(gamedataEquipmentArea, GameObject).

To obtain a DetailedItemRef the active item in a given equip area: ItemInfoHelper.GetActiveItemInfo(gamedataEquipmentArea, GameObject).

To obtain a DetailedItemRef for a given item in a given equip area: ItemInfoHelper.GetItemInAreaInfo(ItemID, gamedataEquipmentArea, GameObject).

To obtain a DetailedItemRef for the active item in a given slot: ItemInfoHelper.GetItemInAreaInfo(TweakDBID, GameObject).

With an array of DetailedItemRef(s), you can find specific items by various means including by: ID, type, tag, index, slotID, TweakDBID, & name. Example:
Spoiler:  
Show

//Get access to all equipped cyberarms
let equippedArms: array<DetailedItemRef> = ItemInfoHelper.GetEquipAreaItemInfo(gamedataEquipmentArea.ArmsCW, someOwnerObject);

//Get Mantis Blades if they exist
let itemRef: DetailedItemRef = DetailedItemRef.FindItemByType(equippedArms, gamedataItemType.Cyb_MantisBlades);

//Check if the returned ref is for a valid item
if DetailedItemRef.IsValidItem(itemRef) {
return true;
}

It's that easy once you get the hang of using it. This is a modder's tool though so even if it's required for my mods don't feel pressure to use it for anything else. I only made it for personal use.


Update: Versions 1.2.0+ now include built-in localization & translation support. This new feature builds off of Codeware to make script-based localization even easier. I noticed that people don't really make use of it. I'm guessing the learning curve is a bit high & people are already used to using Archive-XL. Well, hopefully this can encourage more people to use it. It should make it much easier for people who simply want to help translate your mods. Having an updated Translation Template is all they need to worry about. No need to build & release updated archive files. Simply install KingCode, edit the optional template file per the instructions in the file, then put it somewhere in your mod's folder structure like 'r6/scripts/YourMod/translations' & you're done.

Basically, if you want someone to be able to translate your mod, upload your edited template file as an optional file. It can then be easily edited to a new language. Every mod can even have multiple translation files though only one per language. KingCode will sift through them for the one that matches the user's in-game language & update records as soon as their character shows up in game.

Note: It works fine alongside Tweak-XL. The code will update any UIData records you make in a "yaml tweak" in-game if the secondaryKey values line up correctly. For example: If you set a secondaryKey of "MyKey1" for an entry in the template, it will overwrite any UIData record with a localizedDescription value set to "LocKey#MyKey1" which is the way to use secondaryKeys in Tweak-XL. Keep that in mind. Alternatively, if your records aren't tied to the new secondaryKeys through yaml you can set them up through script via a "scriptable tweak" using TweakDB like so:

TweakDBManager.SetFlat(t"YourUIDataRecord.localizedDescription", ModTranslationEnv.GetTranslator().GetText("MyKey1"));
TweakDBManager.UpdateRecord(t"YourUIDataRecord");

Or

TweakDBManager.SetFlat(t"YourUIDataRecord.localizedDescription", "LocKey#MyKey1"));
TweakDBManager.UpdateRecord(t"YourUIDataRecord");

How you create & edit records is up to you. To define and/or translate in-game text though, you can use a Translation Template. Refer to my 'GorillaGrip' mod for an example of how the Translation Template should look filled out(English.reds) & instructions for translating it pinned on the 'Posts' tab. The feature as still very beta so try it out & let me know what happens. I'll work out the bugs over time. Thanks to psiberx for Codeware Localization which this wouldn't work without. Note: Current Codeware/Redscript/CET limitations prevent altering display name values in this way. Until a fix is applied you should stick to using ArchiveXL if your find yourself also needing to change a character's or item's display name.
  翻译: