Cunning fox

  • Content Count

    395
  • Joined

  • Last visited

 Content Type 

Profiles

Forums

Downloads

Klei Bug Tracker

Game Updates

Hot Lava Bug Reporter

Posts posted by Cunning fox


  1. 7 hours ago, Garamonde said:

    Yes, I used this font code and my mod crashes the game upon world regen, which is a big problem because me and a friend I play with regenerate our worlds all the time. I reeeally hope someone comes up with a cleaner solution! Also, inserting that "hacky" code (and changing all the names to my character of course) gained this crash upon trying to create a new world:

    image.png.1953cb8c0f816e98610e303803b0d828.png

    @Cunning fox

    Add _G = GLOBAL 

    7 hours ago, Garamonde said:

    Yes, I used this font code and my mod crashes the game upon world regen, which is a big problem because me and a friend I play with regenerate our worlds all the time. I reeeally hope someone comes up with a cleaner solution! Also, inserting that "hacky" code (and changing all the names to my character of course) gained this crash upon trying to create a new world:

    image.png.1953cb8c0f816e98610e303803b0d828.png

    @Cunning fox

    The code I used changes mods's env to a global one, so you shouldn't use it if you're not experienced enough. Solution without changing env is:
     

    local _G = GLOBAL
    local TheSim = _G.TheSim
    
    _G.TALKINGFONT_WAYNE = "talkingfont_wayne"
    
    AddSimPostInit(function()
    	TheSim:UnloadFont(_G.TALKINGFONT_WAYNE)
    	TheSim:UnloadPrefabs({"wayne_fonts"})
    
    	local Assets = {
    		Asset("FONT", _G.resolvefilepath("fonts/talkingfont_wayne.zip")),
    	}
    	local FontsPrefab = _G.Prefab("wayne_fonts", function() return _G.CreateEntity() end, Assets)
    	_G.RegisterPrefabs(FontsPrefab)
    	TheSim:LoadPrefabs({"wayne_fonts"})
    	TheSim:LoadFont(_G.resolvefilepath("fonts/talkingfont_wayne.zip"), _G.TALKINGFONT_WAYNE)
    end)

     

    • Like 1
    • Thanks 1

  2. 2 minutes ago, TheSkylarr said:

    What exactly does resolvefilepath() do? I've seen it thrown around, along with softresolvefilepath(), and I'm clueless.

    Resolves relative file path into absolute path
    This is used if you add asset that is not from the game, so you need to tell the engine where it is stored
    Example: resolvefilepath("anim/poop.zip") will return "../../mods/workshop-00000/anim/poop.zip"


  3. The loading solution will crash if you leave the server/reload the current game, because the font needs to be loaded before mod assets are loaded 
    My solution:

    local env = env
    _G.setfenv(1, _G)
    
    TALKINGFONT_WAYNE = "talkingfont_wayne"
    
    env.AddSimPostInit(function()
    	TheSim:UnloadFont(TALKINGFONT_WAYNE)
    	TheSim:UnloadPrefabs({"wayne_fonts"})
    
    	local Assets = {
    		Asset("FONT", resolvefilepath("fonts/talkingfont_wayne.zip")),
    	}
    	local FontsPrefab = Prefab("wayne_fonts", function() return CreateEntity() end, Assets)
    	RegisterPrefabs(FontsPrefab)
    	TheSim:LoadPrefabs({"wayne_fonts"})
    	TheSim:LoadFont(resolvefilepath("fonts/talkingfont_wayne.zip"), TALKINGFONT_WAYNE)
    end)

    It's pretty hacky, so maybe there's other way to resolve reload crash? I've tried to add loading/unloading new font to global functions LoadFonts/UnloadFonts (see mainfunctions.lua), but then the font never even gets loaded.
    Maybe @zarklord_klei knows a better way of doing it? :spidercowers:

    • Like 1

  4. On 11/18/2020 at 2:09 AM, Baguettes said:

    @Cunning fox How do I know the names of the textures? I'm not a programmer, but I'm somehow into changing textures of my favorite games.
    And are there ways to locate original textures in the game files? I need them as a base.
    Thanks in advance!

    I have a script on python that splits all textures for me, but you can use this:

     

    • Thanks 1

  5. For some reason when I call ClientRPC, I always get 

    [00:13:35]: Invalid RPC namespace: 	1	table: 0x40915618

    My RPC:
     

    AddClientModRPCHandler("HG", "TEAM_MSG", function(...)
        printwrap("", {...})
    end)

    How I call it
     

    SendModRPCToClient(GetClientModRPC("HG", "TEAM_MSG"), nil)

    Edit: Zarklord found a bug and this should be fixed in the next patch.


  6. 6 minutes ago, zarklord_klei said:

    as long as you can get their userid, it should!

    Why Klei haven't hired you sooner?? I made a while system that dynamically spawns classified prefabs only to send data to a certain player in lobby. This would make it SO MUCH easier

    • Like 2
    • Thanks 1