YakumoYukari

  • Content count

    109
  • Joined

  • Last visited

Community Reputation

148 Excellent

1 Follower

About YakumoYukari

  • Rank
    Member

Recent Profile Visitors

486 profile views
  1. I'll say there are three popular ways to override prefabs(or components if you want). I've been seen some mod files that modify existing files, and all these ways have their properties. If you enough understand with these options, all three methods are legit. The first one is to use post init functions in the mod environment. It is written in modutil.lua, InsertPostInitFunction I have explained this in the last post(Mod Load Order Priority). Because of the post init functions run in the order listed in postinit table, It is the best-easy, and I think you will probably use this one. For prefabs, there are AddPrefabPostInitAny, AddPlayerPostInit, AddPrefabPostInit. AddPrefabPostInitAny and AddPlayerPostInit are used when you need to override multiple prefabs at once. But you need to think about some performance issues as its comment. And if you want pigmans overridden, do something like this. AddPrefabPostInit("pigman", function(inst) -- do something with inst end) And for the pigman prefab specifically, your PIF will run after the local function, normal. However, you can't override local function in there, like if you're trying to tweak some lines in SetNormalPig which you can't access in PIF scope, you need to re-define the whole local function that works correctly(or copy-paste it then tweaks) or use another method. The second one is to override the existing file, that the way you don't want to do though. If a mod file is at the directory where the original file and the name are the exact same, you can override the whole file. It removes the information of the original file which means the game update will no longer affect that file. So if you don't update your mod frequently, it might cause the crash more easily and soon your mod will be deprecated. But this can be useful when you do a huge scale mod project(that may have unique dependency) or when you need to patch a lot of things. Since prefab files are easily bound to local functions, this can be better than you may concern. But not for components, as it avoids using local functions. Lastly, you can use UpvalueHacker made by Rezecib. This is a tool to access the local variable using Lua's debug functions. It is very powerful but also the toughest to use. Because you need to get a reference by going through the function
  2. Mod Load Order Priority

    Your assumption of the load order is correct. Higher priority loads earlier. Every mod is zero priority given by default. If same, it will load in lexicographical order. And, yes. It affects modutil functions. It would be helpful if you look at the code in modutil. Especially InsertPostInitFunctions. Every PostInit functions are inserted by table.insert() into an environment table, named postinitfns. It is executed in runtime, including the main loads(for the client mods mostly), worldgen and the world loading. Since every element in the game environment(prefabs, stategraphs, actions...) is being variable and separated, it has its own time to appear. And if any post functions exist on that element, the function runs, in the load order. And I do believe that all workshop mods are written in lua which doesn't compile. But executes everything in runtime, line by line. The only matter on the load priority is, how to use it. If you made a prefab post init function that overrides everything about inst, for example, will lose most load order data applied previously. In this case, you need to set your mod priority to the lowest, -2147483648 and rename your mod name start with.. something beyond the 'z' in lexicographical order of the lua sorting algorithm in order to fully apply your code. To avoid this, you can always think about the other mods and use various skills like chain-function. It is always the best to make your mod not to inflict with mods made by other people. Also, you can freely assume the data range of the integer of Lua 5.2 is the int32's.
  3. I think "peacock" is not implemented yet. (might be that's an alternative version of gobbler. But there's no data about it.) So I think just simply change local perd = SpawnPrefab("peacock") local spawnpos = Vector3(inst.Transform:GetWorldPosition() ) spawnpos = spawnpos + TheCamera:GetDownVec() perd.Transform:SetPosition(spawnpos:Get() ) perd.sg:GoToState("appear") perd.components.homeseeker:SetHome(inst) shake(inst) to local perd = SpawnPrefab("perd") -- is the only tweak. local spawnpos = Vector3(inst.Transform:GetWorldPosition() ) spawnpos = spawnpos + TheCamera:GetDownVec() perd.Transform:SetPosition(spawnpos:Get() ) perd.sg:GoToState("appear") perd.components.homeseeker:SetHome(inst) shake(inst) is better for SW playing.