Music Man Posted August 13, 2021 Share Posted August 13, 2021 (edited) While I was trying to figure out modding in dst, I realized that there is no clear, not outdated, auxiliary information, except for a few articles. In addition, many advise to look at the files of the game itself, but now, there are simply no uncompiled files that would store all the functions in themselves (I do not know if they were at all or I am doing something wrong). At this stage I'm trying to make a smooth scale of the character by pressing a key using a loop, but this happens almost instantly. To my knowledge lua doesn't support any kind of timers or anything like that. After decompiling some dst files I found a mention of "SetDelayTime", but I have no idea if this function (if it's function) has anything to do with what I am trying to do. Experienced modders, please provide answers to two main questions. in which files of the game you can find functions in a more or less expanded form how do I set a pause after one iteration in a loop when I try to scale in or out on a character. My current code: bigSize = 2 playerIsBig = False local function MakeMeBig(player) for i=1, bigSize, 0.01 do player.Transform:SetScale(i,i,i) end end local function MakeMeSmall(player) for i=bigSize, 1, -0.01 do player.Transform:SetScale(i,i,i) end end AddModRPCHandler(modname, "MakeMeSmall", MakeMeSmall) AddModRPCHandler(modname, "MakeMeBig", MakeMeBig) local function SendChangeSizeRPC() if playerIsBig == true then SendModRPCToServer(MOD_RPC[modname]["MakeMeSmall"]) playerIsBig = false else SendModRPCToServer(MOD_RPC[modname]["MakeMeBig"]) playerIsBig = true end end GLOBAL.TheInput:AddKeyDownHandler(99, SendChangeSizeRPC) --c Edited August 13, 2021 by Music Man Link to comment Share on other sites More sharing options...
Monti18 Posted August 14, 2021 Share Posted August 14, 2021 (edited) The game files can be found in /Programs/SteamLibrary/common/Don't Starve Together/data/databundles/scripts.zip. Just extract those files and search through these to find the functions you want. You have a few files which contain some important functions that are used in a lot files, those are mostly in the main directory in scripts, for example mainfunctions.lua, entityscript.lua and so on... If you are looking for a specific function, just search in the folder for it or think of an ingame object that uses it perhaps and try to find it, at least that's my approach. Fortunaly, the devs implement the functions DoTaskInTime and DoPeriodicTask, with these you can implement what you want. local bigSize = 2 --better make them local to not clutter the game local playerIsBig = False local bigger = 1 local function MakeMeBig(player) if bigger >= bigSize then --if we reach the wanted size, we stop the function and change bigger back to inital value bigger = 1 return end bigger = bigger + 0.01 player.Transform:SetScale(bigger,bigger,bigger) player:DoTaskInTime(0,MakeMeBig) --by calling DoTaskInTime(0,fn), each frame the character will get 0.01 bigger. You can change the time to make it slower if you want end local smaller = bigSize local function MakeMeSmall(player) if smaller <= 1 then smaller = bigSize return end smaller = smaller - 0.01 player.Transform:SetScale(smaller,smaller,smaller) player:DoTaskInTime(0,MakeMeSmall) end Perhaps there is a better way to do it, but this is the only thing that comes to my mind. Edited August 14, 2021 by Monti18 smaller and bigger are not always exactly equal, so small changes there 1 1 Link to comment Share on other sites More sharing options...
Music Man Posted August 14, 2021 Author Share Posted August 14, 2021 Thanks. I actually found scripts where you wrote. I have now corrected my code by adding the DoTaskInTime function, but it gives the following error. I am very embarrassed to ask, but I still cannot fully figure out how to correctly work with variables in mods. Below is the function itself for convenience. Oh, out of habit I confused ":" and "." Started with Lua just yesterday Link to comment Share on other sites More sharing options...
Monti18 Posted August 14, 2021 Share Posted August 14, 2021 Could you post the code you are using? As I just tested it and for me it worked as intended It seems your DoTaskInTime is referring to the wrong entity, as it says in the log that self is a number value, but it should be an entity. You will get a feeling for the variables after some time 1 Link to comment Share on other sites More sharing options...
Music Man Posted August 14, 2021 Author Share Posted August 14, 2021 Yes, as I said, I confused the dot and colon sign Your code worked correctly from the very beginning, but I'm used to rewriting, not copying, so I was a little mistaken Link to comment Share on other sites More sharing options...
Monti18 Posted August 14, 2021 Share Posted August 14, 2021 Oh ok, then it's good to hear! I don't know if you already fixed it, but if not, I changed if bigger == bigSize then to if bigger >= bigSize then and the same for smaller, as otherwise you will grow to infinity 1 Link to comment Share on other sites More sharing options...
Music Man Posted August 14, 2021 Author Share Posted August 14, 2021 Yes, thanks, I fixed that already 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now