Dustt Posted March 14, 2017 Share Posted March 14, 2017 (edited) Hello there! I'm looking for somebody who could help me create a program code for a new feature for my character. What I want is for my character to have "grogginess" effect for every time he wakes up from sleep (Tent, bedroll etc.) It's the same as to when a mandrake is eaten raw or a pan flute being played but minus the area effect. And it would be great if the duration is changeable and not fixed, just in case if I want to buff/nerf him. I've looked at the codes for "mandrake_inactive", "panflute", "tent", and "grogginess" to see how the codes function and try to figure it out myself but unfortunately I'm too inept at LUA language to really understand what's going on. I've read some of the pinned guide on "Getting Started with Modding DST..." but still no luck. I've tried experimenting with pieces of codes from the database -- hoping that it would work. But of course it didn't work... ah... So if anyone know how to create such feature, please tell me! (and please try to explain it if u have the time! ) Here's some snip about what I was talking about: Quote Thanks in advance! Edited March 17, 2017 by Dustt solved Link to comment Share on other sites More sharing options...
Serpens Posted March 14, 2017 Share Posted March 14, 2017 (edited) Just use the grogginess component. I think every character has this by default, if you use the default character as a base. if player.components.grogginess then -- check if character really has the component player.components.grogginess:AddGrogginess(8, 0) end the function looks like this: Grogginess:AddGrogginess(grogginess, knockoutduration) so if you don't want the knockout, I think the second number should be 0 Edited March 14, 2017 by Serpens Link to comment Share on other sites More sharing options...
Dustt Posted March 14, 2017 Author Share Posted March 14, 2017 3 hours ago, Serpens said: Just use the grogginess component. I think every character has this by default, if you use the default character as a base. if player.components.grogginess then -- check if character really has the component player.components.grogginess:AddGrogginess(8, 0) end the function looks like this: Grogginess:AddGrogginess(grogginess, knockoutduration) so if you don't want the knockout, I think the second number should be 0 Hmm, it didn't seem to work. It says that a "(" was expected near the ":" in the function line and so I followed through that and it still doesn't work. I feel like I'm doing something wrong here . Link to comment Share on other sites More sharing options...
Serpens Posted March 14, 2017 Share Posted March 14, 2017 What is your code? The snippet I posted should contain no error. Link to comment Share on other sites More sharing options...
Dustt Posted March 15, 2017 Author Share Posted March 15, 2017 Sorry for the late reply! But here's what I wrote: local function Grogginess:AddGrogginess(grogginess, knockoutduration) if player.components.grogginess then player.components.grogginess:AddGrogginess(8, 0) end end Am I doing it wrong? Link to comment Share on other sites More sharing options...
. . . Posted March 15, 2017 Share Posted March 15, 2017 3 hours ago, Dustt said: Sorry for the late reply! But here's what I wrote: local function Grogginess:AddGrogginess(grogginess, knockoutduration) if player.components.grogginess then player.components.grogginess:AddGrogginess(8, 0) end end Am I doing it wrong? Isn't there a event for when a character wakes up from sleep? I think you'd put this code in that event, I don't think an entire local function's required for adding grogginess, I think . if inst.components.grogginess then -- check if character really has the component inst.components.grogginess:AddGrogginess(8, 0) end Link to comment Share on other sites More sharing options...
Fancy_Fox_Pers Posted March 15, 2017 Share Posted March 15, 2017 In frograin.lua at line 207 there is "inst:ListenForEvent("entitysleep", OnTargetSleep, target)" In saltlicker.lua at line 98 there is "self.inst:ListenForEvent("onwakeup", TryUnpause)" And in mandrake_inactive.lua you can find "PushEvent("yawn")" and "PushEvent("knockedout")" So maybe try one of those Link to comment Share on other sites More sharing options...
Serpens Posted March 15, 2017 Share Posted March 15, 2017 7 hours ago, Dustt said: Sorry for the late reply! But here's what I wrote: local function Grogginess:AddGrogginess(grogginess, knockoutduration) if player.components.grogginess then player.components.grogginess:AddGrogginess(8, 0) end end Am I doing it wrong? yes this is completly wrong, sorry With "Grogginess:AddGrogginess(grogginess, knockoutduration)" I wanted to show you how the function is defined and what the arguments are called. Only the code I put in code tags is needed. But of course you need to know where to put it. You said you want it everytime the player wakes up. Therefore you need to look for an event that is fired when waking up.Thibooms already mentioned that event. I never made a custom character so I'm not 100% sure if the code belongs in masterpostinit or not (please someone else tell us?^^) But the code should look like this: inst:ListenForEvent("onwakeup", function(inst,data) if inst and inst:HasTag("player") and inst.components.grogginess then inst.components.grogginess:AddGrogginess(8, 0) end end) Link to comment Share on other sites More sharing options...
. . . Posted March 16, 2017 Share Posted March 16, 2017 3 hours ago, Serpens said: I never made a custom character so I'm not 100% sure if the code belongs in masterpostinit or not (please someone else tell us?^^) Yup that's where it'd go ! Link to comment Share on other sites More sharing options...
Dustt Posted March 16, 2017 Author Share Posted March 16, 2017 Hmmm looks promising! I'm going to test it out and see if it works. I'll be writing my feedback once I'm done testing it out. Thanks for the help guys! Link to comment Share on other sites More sharing options...
Dustt Posted March 17, 2017 Author Share Posted March 17, 2017 (edited) I've tested the codes that you have suggested and well... It didn't crash but it didn't work in the game either. This made me want to spend some time to learn the data within the game. Okay so then, I've spent a few hours digging through the LUA Codes and testing codes after codes and I've discovered that grogginess will only work after the player is knocked out - which is unfortunate... This means that for me to able to get the effect that I want, I need to create a "stategraph" specifically for my character. So I did that and now it works!! Wooohoo! Thanks for the great help guys! I really appreciate it! PS- I might be wrong about the "knockout" thing. Edited March 17, 2017 by Dustt Forgot to add some stuff 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