### Install TBCML from Source Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Install TBCML from source by cloning the repository and installing dependencies. This method is recommended for development. ```bash git clone https://codeberg.org/fieryhenry/tbcml.git cd tbcml pip install -r requirements_scripting.txt pip install -e . ``` -------------------------------- ### Initial Termux Setup Commands Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Run these commands in Termux to set up storage, change repositories, and upgrade packages. ```bash termux-setup-storage termux-change-repo pkg upgrade ``` -------------------------------- ### Install TBCML from PyPI Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Install TBCML using pip. For scripting features, install with the 'scripting' extra. ```bash pip install tbcml ``` ```bash pip install tbcml[scripting] ``` -------------------------------- ### Install Lief Library with Pip Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Installs the 'lief' library using pip, which may be necessary for scripting capabilities. This can take a long time to compile. ```bash pip install lief ``` -------------------------------- ### Basic TBCML Modding Example Source: https://github.com/fieryhenry/tbcml/blob/master/README.md A basic example demonstrating how to create a custom cat and mod with TBCML. This includes defining a custom cat form and adding it to a mod. ```python import tbcml class BasicCustomForm(tbcml.CatForm): """For better organization, these classes could be defined in another / separate files and then imported. See game_data/cat_base/cats.py for documetation of cats """ def __init__(self): super().__init__(form_type=tbcml.CatFormType.FIRST, name="Cool Cat") # you can either set properties in the constructor as shown above, or # like this: self.description = ["First line!", "Second Line!", "Third description line!"] # note that if you use .read() it will overwrite any previously defined # values, so you may not be able to put the values in the constructor # if you want to use .read() class BasicCustomCat(tbcml.Cat): def __init__(self): super().__init__(cat_id=0) first_form = BasicCustomForm() self.set_form(first_form) loader = tbcml.ModLoader( "en", "12.3.0" # these can be changed for the version you want ) loader.initialize_apk() apk = loader.get_apk() mod = tbcml.Mod( name="Test Mod", authors="fieryhenry", # can be a list of authors e.g ["person 1", "person 2"] short_description="Test Description", ) cat = BasicCustomCat() mod.add_modification(cat) mod.save("test.zip") # save the mod to a zip file (optional) apk.set_app_name("The Battle Cats Basic Mod") # package name should be different to base game if you want your modded app ``` -------------------------------- ### Initialize ModLoader and Apply Mod Source: https://github.com/fieryhenry/tbcml/blob/master/examples/examples.md This code initializes the ModLoader with specified language and version, prepares the APK, and applies a mod. It serves as a common setup for many tbcml operations. ```python import tbcml loader = tbcml.ModLoader("en", "13.1.1") # Change to your language and version loader.initialize_apk() ... # Apply mod loader.apply(mod) ``` -------------------------------- ### Install Core Packages in Termux Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Installs essential packages for TBCML development, including Python, Rust, Java, and build tools. ```bash pkg install python pkg install binutils pkg install rust pkg install openjdk-17 pkg install aapt pkg install apksigner pkg install git pkg install cmake ``` -------------------------------- ### Copy APK to Downloads Folder Source: https://github.com/fieryhenry/tbcml/blob/master/README.md A Python snippet to add to your script to automatically copy the final APK to your Android downloads folder for easy installation. ```python loader.copy_to_android_download_folder() ``` -------------------------------- ### Initialize and Update User Rank and Bonuses Source: https://github.com/fieryhenry/tbcml/blob/master/examples/apk/modded_user_info.html Sets up data structures for user rank bonuses and updates the UI to reflect the current user rank and earned bonuses. It dynamically generates table rows for bonuses and shows elements based on the user's rank. ```javascript var userRankBonusReceived = {}; var userRankBonusList = {}; function setUserRankBonus(bonusUserRank, received, description) { userRankBonusReceived[bonusUserRank] = received; userRankBonusList[bonusUserRank] = description; } function setUserRank(userRank) { var element = document.getElementById('rank'); element.innerHTML = userRank; var table = document.getElementById('user_rank_bonus_table'); for (var bonusUserRank in userRankBonusList) { var row = table.insertRow(-1); row.insertCell(-1).innerHTML = bonusUserRank + ((userRankBonusReceived[bonusUserRank] != undefined && userRankBonusReceived[bonusUserRank]) ? '' : ''); row.insertCell(-1).innerHTML = userRankBonusList[bonusUserRank]; if (bonusUserRank <= userRank) { var elements = document.getElementsByName('rank_' + bonusUserRank); for (var i = 0; i < elements.length; i++) { elements[i].style.display = ""; } } if (bonusUserRank > userRank) { break; } } } ``` -------------------------------- ### Configure Lief Library with patchelf Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Applies necessary patches to the 'lief' library using 'patchelf' to ensure it works correctly with Python on Termux. Adjust the Python version if necessary. ```bash pkg install patchelf patchelf --add-needed libpython3.11.so /data/data/com.termux/files/usr/lib/python3.11/site-packages/lief.cpython-311.so patchelf --add-needed libandroid.so /data/data/com.termux/files/usr/lib/python3.11/site-packages/lief.cpython-311.so ``` -------------------------------- ### Run Script on Windows Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Command to run a Python script on Windows using the py launcher. ```bash py script.py ``` -------------------------------- ### Initialize IPA Loader Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Initializes the TBCML loader for iOS IPA files. You must specify the path to the IPA file. ```python loader = tbcml.ModLoader("en", "12.3.0") # you need to specify the path to the ipa as it can't be downloaded loader.initialize_ipa(ipa="path/to/ipa") ipa = loader.get_ipa() # ... rest of the code is the same ``` -------------------------------- ### Initialize Loader Without Apktool Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Initializes the TBCML loader without using apktool. This method extracts and repacks the APK like a zip file but does not decode resources, limiting modifications to game data. ```python loader.initialize_apk(use_apktool=False) ``` -------------------------------- ### Initialize Loader with Specific Language Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Initializes the TBCML loader for a specific language. Supported languages include French, Italian, German, Spanish, and Thai. ```python loader.initialize_apk(lang="fr") ``` -------------------------------- ### Set Package Name and Apply Mod Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Sets the package name for the modded APK and applies the mod. Ensure apktool is supported for your architecture. ```python apk.set_package_name("jp.co.ponos.battlecats.basicmod") # set open_path to True if you want to open the containg folder of the modded apk loader.apply(mod, open_path=False) print(apk.final_pkg_path) ``` -------------------------------- ### Initialize Loader with Script Mods Disabled Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Initializes the TBCML loader with script modding disabled for security reasons. Set allowed_script_mods to False. ```python loader.initialize_apk(allowed_script_mods=False) ``` -------------------------------- ### Compile Mod for Specific Target Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Compiles modifications into raw game files for faster loading. Specify target country codes and game versions. ```python target = tbcml.CompilationTarget( target_country_codes="en", target_game_versions="12.3.0" ) mod.compile_modifications(loader.get_game_packs(), existing_target=target) ``` -------------------------------- ### Run Script on Other Systems Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Command to run a Python script on systems other than Windows, typically using python3. ```bash python3 script.py ``` -------------------------------- ### Define Cat and Form Modifications Source: https://github.com/fieryhenry/tbcml/blob/master/README.md Defines modifications for a cat and its form without using inheritance. This allows direct manipulation of cat properties like name and description. ```python ... cat = tbcml.Cat(cat_id=0) form = tbcml.CatForm(form_type=tbcml.CatFormType.FIRST, name="Cool Cat") form.description = ["First line!", "Second Line!", "Third description line!"] cat.set_form(form) mod.add_modification(cat) ... ``` -------------------------------- ### Control Element Visibility Source: https://github.com/fieryhenry/tbcml/blob/master/examples/apk/modded_user_info.html Controls the display style of elements based on a visibility flag. It finds elements by name and sets their display property. ```javascript function setVisible(name, visible) { if (visible) { var elements = document.getElementsByName(name); for (var i = 0; i < elements.length; i++) { elements[i].style.display = ""; } } } ``` -------------------------------- ### Update Cat Energy Display Source: https://github.com/fieryhenry/tbcml/blob/master/examples/apk/modded_user_info.html Updates the displayed current and maximum cat energy. This function is used to reflect changes in the player's energy reserves. ```javascript function setEnergy(currentEnergy, maxEnergy) { var element = document.getElementById('energy'); element.innerHTML = currentEnergy + '/' + maxEnergy; } ``` -------------------------------- ### Update Excavation Level Display Source: https://github.com/fieryhenry/tbcml/blob/master/examples/apk/modded_user_info.html Updates the displayed excavation level. If the level is greater than 0, it makes excavation level elements visible and sets their content. ```javascript function setExcavationLevel(level) { if (level > 0) { var elements = document.getElementsByName('excavation_level'); for (var i = 0; i < elements.length; i++) { elements[i].style.display = ""; } document.getElementById('excavation_level').innerHTML = level; } } ``` -------------------------------- ### Update Item Count Display Source: https://github.com/fieryhenry/tbcml/blob/master/examples/apk/modded_user_info.html Updates the displayed count for a specific item. This function targets an element by its item ID and updates its content. ```javascript function setItem(itemID, count) { var element = document.getElementById('item_' + itemID); if (element != undefined) { element.innerHTML = count; } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.