Clopen

  • Content count

    52
  • Joined

  • Last visited

 Content Type 

Profiles

Forums

Downloads

Klei Bug Tracker

Game Updates

Hot Lava Bug Reporter

Posts posted by Clopen


  1. I have made a simple mod in which I added map icons to existing prefabs.
    These icons appear, but they hide the player icon on the map.

    After looking around, I found that MiniMapEntity has a function called SetPriority which seems to control the Z ordering of layers.
    I've tried setting it to various numbers, to no effect.
    What's more, I used the in-game console, placed my mouse cursor over an instance of one of these prefabs and then executed the command:

    TheInput:GetWorldEntityUnderMouse().MiniMapEntity:SetPriority(1)

    Nothing changed.
    I tried various values, of course.
    If I did the same on an instance of some other random prefab (specifically one of the pig houses in Hamlet), changing the priority value like this did put its icon over or under the player's icon, but it didn't work on the ones I changed.
    In case it matters, the prefabs I changed were of the pig merchants (this mod is for showing icons for the merchants so it would be easier to find the ones you want to trade with).

    Any idea what I'm doing wrong here and how I can make the icons appear under the player icon?

    This is the entirety of my short modmain.lua file:

    Assets =
    {
    }
    
    local TRADERS = {
    	"pigman_collector",
    	"pigman_banker",
    	"pigman_beautician",
    	"pigman_mechanic",
    	"pigman_professor",
    	"pigman_hunter",
    	"pigman_mayor",
    	"pigman_florist",
    	"pigman_storeowner",
    	"pigman_farmer",
    	"pigman_miner",
    	"pigman_erudite",
    	"pigman_hatmaker",
    	"pigman_queen",
    	"pigman_usher",
    }
    
    for i, trader in ipairs(TRADERS) do
    	table.insert(Assets, Asset("IMAGE", "minimap/" .. trader .. "_icon.tex"))
    	table.insert(Assets, Asset("ATLAS", "minimap/" .. trader .. "_icon.xml"))
    	AddMinimapAtlas("minimap/" .. trader .. "_icon.xml")
    	
    	AddPrefabPostInit(trader, function(inst)
    		local minimap = inst.MiniMapEntity or inst.entity:AddMiniMapEntity()
    		minimap:SetIcon(trader .. "_icon.tex")
    		minimap:SetPriority(1)
    	end)
    end

    Thanks in advance.


  2. On 7/31/2019 at 12:32 AM, PeterA said:

    Hmm, has anyone else seen this? Can you post your KLEI USER ID as seen on the accounts page? I'd like to look at your account logs to see if i can figure out why.
     

    I'm really sorry, I haven't looked here in a long time so I didn't see this.

    I can't find the user ID you mentioned.
    If you direct me to where it is I'd be happy to provide it.


  3. On 2/8/2019 at 8:07 AM, Topaz_Chaz said:

    Hey, would someone be willing to help me? I'm modding for DST, but it crashes as it loads the world. I have no idea what to do. I'm stuck. Here's the client_log file. Thanks!

    client_log.txt

    "[00:04:46]: [string "scripts/util.lua"]:550: Could not find an asset matching images/avatars/avatar_phelps.tex in any of the search paths."

    You're missing that file.
    Check that you have an image called "avatar_phelps.png" in images\avatars and make sure you let the autocompiler run its course.
    You should be able to see it say that it's processing that file, I think.

    As a general tip, whenever you encounter a crash, search the log file for the first time the word "error" appears and look around there.
    The line I just copied appears one line above the first time "error" shows in the file.


  4. I made a small utility script for renaming characters easily.

    It conserves case, so it should take care of both "esctemplate" and "ESCTEMPLATE" replacements at once.
    It also changes filenames accordingly.

    You can find it here, and a post I wrote with more details on how to use it here.

    The script itself is written in Python, so it should work on Mac systems too (untested), but there's a batch file I added to facilitate using it more easily, and that won't work on Macs (at least, not without conversion or some program to run batch files on Mac, if such a thing exists).
    Still, the batch file is very simple, and the explanations I wrote should make it clear how to use the script without relying on the batch file, so it should still be of use.

    If someone wants to write a Mac equivalent of the batch file I'll gladly add it to the archive for download.

    Hopes this helps someone. =)


  5. I usually use Dragon Wolf Leo's wonderful Extended Sample Character Template as a basis to a new character I make, or sometimes a character of my own that I'd already made, and I got tired of the search & replace and file renaming process, so I wrote a small utility to do it for me.

    It searches and replaces one string with another while preserving case, so if you rename esctemplate to SuperDude then everywhere you have esctemplate it will be changed to superdude and everywhere you have ESCTEMPLATE it will be changed to SUPERDUDE.

    It also renames all the files it finds accordingly, so esctemplate.lua will be renamed to superdude.lua and folders named esctemplate will be renamed to superdude.

    The tool is called CaseReplace and was written in Python 3 so you need to install that if you want to use it.

    IMPORTANT NOTE

    This tool performs a simple search & replace operation. It doesn't know that you only want to change text when it's referring to a character name.
    Therefore the name you replace needs to be unique and only appear as the name of that character!
    If your character is named "e" and you run this tool to replace "e" with "a" you'll most certainly break your mod and nothing will work.
    Also, this tool has no undo option (replacing "a" with "e" again won't undo it), so it's highly recommended you back your files up before using it.
    I have tested it but not rigorously, so it's best to make a backup before running this.
    I will not be held responsible for the loss of your work or data as a result of using this tool.

    How to Use It

    First install Python 3.
    I used Python 3.6.6 but I think any version of Python 3 should work, or at least any that are after 3.6.6.

    Next, extract the contents of the ZIP file in the download link at the end of this post to your mod folder.

    You'll see two files: CaseReplace and RenameDSCharacter.

    Normally using RenameDSCharacter will be enough.
    Just double-click it, enter the current name of the character and then the new name you want to give it, and it'll do everything for you.

    That's it.

     

    Advanced Usage

    In case the normal way is not enough - for example if you want it to skip PNG files or something - you can use the CaseReplace script directly.
    If you run CaseReplace with the '--help' option you will see something like this:

    C:\MyModFolder>python CaseReplace.py --help
    usage: CaseReplace.py [-h] [-f FIND] [-r REPLACE] [-m MIXED] [-n] [-v] [-b]
                          [-p [PATH [PATH ...]]] [-x [EXCLUDE [EXCLUDE ...]]]
                          [--version]
    
    CaseReplace script, by Tomer Godinger, May 2019.
    Search and replace utility that preserves case.
    
    optional arguments:
      -h, --help            show this help message and exit
      -f FIND               the string to find
      -r REPLACE            the string to replace with
      -m MIXED              what to use for mixed-case findings
      -n                    also rename files and directories
      -v                    verbose mode
      -b                    stop in case of an error
      -p [PATH [PATH ...]]  files to search in
      -x [EXCLUDE [EXCLUDE ...]]
                            files NOT to search in
      --version             show version
    
    Example usage:
        CaseReplace.py -f SomeString -r NewString C:\*.txt
            Will replace all occurrences of "SomeString" with "NewString" in all files that end with '.txt' under C:\.
            Case is preserved, so SOMESTRING will become NEWSTRING and somestring will become newstring.
            Mixed-case will be replaced with the casing used in the replace argument.
    

    I'm hoping that's self-explanatory, but I'll write a bit more anyway.
    Let's assume I want to rename esctemplate with SuperDude.

    When you run it you must provide:

    • The string to search for: -f esctemplate
    • The string to replace it with: -r SuperDude
    • At least one of these two (both is also fine):
      • Which files to look in - for example, to search only in Lua scripts: -p **/*.lua
      • Which files NOT to look in - for example, to skip ZIP files: -x **/*.zip

    If you only provide the -x option, the script will process every file except the ones who fit the -x pattern.

    This script uses the Python glob module, which uses Unix style pathname pattern expansion, so if you have trouble getting it to work only on the files you want then you may want to look into that.

    You also may provide:

    • What to replace mixed-case findings with, for example: -m SUPERDude
      If at any point the search term is found where it isn't all lower-case and it isn't all upper-case (e.g. "EscTemplate"), it will be replaced with what you provide here.
      If you do not provide it, the way you wrote the find name (with -f) will be used, so if you ran the batch file and wrote "SuperDude" then "EscTemplate" will be changed to "SuperDuide", as will "ESCtemplATE", "esctEmplate" and "ESCTEMPLATe".
    • Whether or not to rename files: -n
      If this option is provided, any file and directory in the search criteria (i.e. that fits the "-p" pattern (if given) and doesn't fit the "-x" pattern (if given)) will also have its name changed in the exact same manner (preserves case, though that has very little meaning on Windows).
    • A request to halt the process if an error occurs: -b
    • A request for the script to tell you what it's doing as it does it: -v
      This will show you which files are changed, how many replacements were made in them, which files were renamed, etc.

    Examples

    • python CaseReplace.py -f ThisDude -r ThatDude -p **/*.scml
      Replaces "ThisDude" with "ThatDude" with case preservation in every SCML (Spriter) file without changing any names.
       
    • python CaseReplace.py -f wilson -r SpongeBob -n -p **/*.lua
      Replaces "wilson" with "spongebob" with case preservation in every Lua script file while also changing the names of the files (e.g. "SGwilson" will become "SGspongebob").
       
    • python CaseReplace.py -f superman -r clarkkent -m "Clark Kent" -n -p **/*.lua -x **metropolis**
      Replaces "superman" with "clarkkent" in all Lua script files that don't have the word "metropolis" in their name or path (so everything under a "metropolis" folder will also be skipped).
      This one will also change "Superman" to "Clark Kent" (with a space).
      Not something you usually want to do, but it can be useful, for example, if you only have "Superman" in mixed-case inside descriptions and speech lines, and there you would want to replace it with "Clark Kent" and not "clarkkent" or "ClarkKent".

     

    Where to Get It

     

    You're most welcome to ask any questions if you have them, and also tell me if you encounter a bug or have a suggestion.

    Happy modding! =D