Eremus007 Posted June 17, 2016 Share Posted June 17, 2016 Hello, here I have a part of the scripting of a dwarventonic edible prefab that makes the drinker/eater see in the dark. (There are other codes that make this work in the modmain) The problem is that I would like to make this also work when the character is in the caves. Right now it only works at night and switches off automatically. Spoiler inst:DoPeriodicTask(1, function() --dwarventonic if inst.dwarventonicresttime then if inst.dwarventonicresttime > 0 then inst.dwarventonicresttime = inst.dwarventonicresttime - 1 if TheWorld.state.isnight then inst.light:SetFalloff(0.75) inst.light:SetIntensity(.6) inst.light:SetRadius(10) inst.light:SetColour(169/255, 231/255, 245/255) inst.light:Enable(true) inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" ) else inst.light:Enable(false) end elseif inst.dwarventonicresttime == 0 then inst.components.sanity.dapperness = inst.components.sanity.dapperness + TUNING.DAPPERNESS_MED_LARGE inst.components.sanity:DoDelta(TUNING.BREW_SANITY/2) inst.light:Enable(false) inst.dwarventonicresttime= inst.dwarventonicresttime - 1 end end I would like to do something like this, but I don't know how to say that in LUA: Spoiler inst:DoPeriodicTask(1, function() --dwarventonic if inst.dwarventonicresttime then if inst.dwarventonicresttime > 0 then inst.dwarventonicresttime = inst.dwarventonicresttime - 1 if TheWorld.state.isnight or character is in cave dimension then inst.light:SetFalloff(0.75) inst.light:SetIntensity(.6) inst.light:SetRadius(10) inst.light:SetColour(169/255, 231/255, 245/255) inst.light:Enable(true) inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" ) else inst.light:Enable(false) end elseif inst.dwarventonicresttime == 0 then inst.components.sanity.dapperness = inst.components.sanity.dapperness + TUNING.DAPPERNESS_MED_LARGE inst.components.sanity:DoDelta(TUNING.BREW_SANITY/2) inst.light:Enable(false) inst.dwarventonicresttime= inst.dwarventonicresttime - 1 end end I hope someone can give me the right condition Link to comment Share on other sites More sharing options...
Aquaterion Posted June 17, 2016 Share Posted June 17, 2016 TheWorld.state.iscavenight should be it (scripts/components/worldstate.lua) Link to comment Share on other sites More sharing options...
Eremus007 Posted June 17, 2016 Author Share Posted June 17, 2016 10 minutes ago, Aquaterion said: TheWorld.state.iscavenight should be it (scripts/components/worldstate.lua) Oké Thanks Link to comment Share on other sites More sharing options...
Eremus007 Posted June 17, 2016 Author Share Posted June 17, 2016 48 minutes ago, Aquaterion said: TheWorld.state.iscavenight should be it (scripts/components/worldstate.lua) I tried them all, but they don't work... unfortunately. Is there any other way to check if they are in a cave that you happen to know off? Link to comment Share on other sites More sharing options...
DarkXero Posted June 17, 2016 Share Posted June 17, 2016 18 minutes ago, Eremus007 said: Is there any other way to check if they are in a cave that you happen to know off? TheWorld:HasTag("cave") Link to comment Share on other sites More sharing options...
Eremus007 Posted June 17, 2016 Author Share Posted June 17, 2016 (edited) It still doesn't work Why does the light emitter not work in caves? I appreciate all your help though Edited June 17, 2016 by Eremus007 Link to comment Share on other sites More sharing options...
DarkXero Posted June 17, 2016 Share Posted June 17, 2016 9 minutes ago, Eremus007 said: Why does the light emitter not work in caves? Put inst.Light:EnableClientModulation(true) before inst.entity:SetPristine() Link to comment Share on other sites More sharing options...
Eremus007 Posted June 17, 2016 Author Share Posted June 17, 2016 (edited) inst.entity:SetPristine() This is only in item prefab files. The code I am referencing above is from my character.LUA. And a character doesn't have a SetPristine Sooooo... Any Other ideas? Edited June 17, 2016 by Eremus007 Link to comment Share on other sites More sharing options...
DarkXero Posted June 17, 2016 Share Posted June 17, 2016 (edited) 12 minutes ago, Eremus007 said: The code I am referencing above is from my character.LUA. And a character doesn't have a SetPristine Put it in your common_postinit. Other characters can eat the tonic too? If the answer is yes then you need to re-think how you give the light to other characters. Because changes to inst.Light don't propagate unless the line I mentioned is enabled. Therefore, in servers with caves, you wouldn't be able to see the light. Edited June 17, 2016 by DarkXero Link to comment Share on other sites More sharing options...
Eremus007 Posted June 17, 2016 Author Share Posted June 17, 2016 1 hour ago, DarkXero said: Put it in your common_postinit. Other characters can eat the tonic too? If the answer is yes then you need to re-think how you give the light to other characters. Because changes to inst.Light don't propagate unless the line I mentioned is enabled. Therefore, in servers with caves, you wouldn't be able to see the light. it only works for one character Link to comment Share on other sites More sharing options...
DarkXero Posted June 17, 2016 Share Posted June 17, 2016 3 minutes ago, Eremus007 said: it only works for one character Then putting that line in common_postinit should do it. Link to comment Share on other sites More sharing options...
Eremus007 Posted June 17, 2016 Author Share Posted June 17, 2016 It still doesn't work T_T Link to comment Share on other sites More sharing options...
DarkXero Posted June 17, 2016 Share Posted June 17, 2016 Post your whole thing. Link to comment Share on other sites More sharing options...
Eremus007 Posted June 17, 2016 Author Share Posted June 17, 2016 13 minutes ago, DarkXero said: Then putting that line in common_postinit should do it. Is there any way to make it work on all characters that have the tag "Dwarf" by putting something in the Dwarvenale prefab file or perhaps the modmain? While still making sure the dwarventonic resttime isn't provoked. (Shall I include a copy of both the modmain, character.Lua and dwarventonic.LUA? Hope you can help me. modinfo.lua modmain.lua dwarvenale.lua dwarventonic.lua skyminer.lua Link to comment Share on other sites More sharing options...
DarkXero Posted June 18, 2016 Share Posted June 18, 2016 5 hours ago, Eremus007 said: (Shall I include a copy of both the modmain, character.Lua and dwarventonic.LUA? What you should always do is zip your mod into a folder, so people don't have to replace all assets just to test functionality. I didn't test this, but I hope it works. I changed some stuff in the tonic and ale and skyminer files. Tonic prefab file now comes with the light it uses to light up the way. There's a component that handles ale and tonic times and effects. Many characters can enjoy the ale and the tonic as long as they have inst:AddComponent("dwarfbrewdrinker"). Also, try removing some tags, because you have one per recipe, and you could just have "dwarf" for all of the recipes instead. DwarfStuff.zip Link to comment Share on other sites More sharing options...
Eremus007 Posted June 18, 2016 Author Share Posted June 18, 2016 12 hours ago, DarkXero said: What you should always do is zip your mod into a folder, so people don't have to replace all assets just to test functionality. I didn't test this, but I hope it works. I changed some stuff in the tonic and ale and skyminer files. Tonic prefab file now comes with the light it uses to light up the way. There's a component that handles ale and tonic times and effects. Many characters can enjoy the ale and the tonic as long as they have inst:AddComponent("dwarfbrewdrinker"). Also, try removing some tags, because you have one per recipe, and you could just have "dwarf" for all of the recipes instead. DwarfStuff.zip Uhm.... It makes my game unhostable. When I drink the brew as Athor, the server just fades and disconnects. This time I have included the whole mod (with your changes). Can you test this out for me? Skyminer Character mod Update 13.zip Link to comment Share on other sites More sharing options...
DarkXero Posted June 19, 2016 Share Posted June 19, 2016 8 hours ago, Eremus007 said: Uhm.... It makes my game unhostable. When I drink the brew as Athor, the server just fades and disconnects. There were missing TUNING values for the durations of the brew effects. I included them in modmain. Skyminer Character mod (14).zip Link to comment Share on other sites More sharing options...
Eremus007 Posted June 19, 2016 Author Share Posted June 19, 2016 8 hours ago, DarkXero said: There were missing TUNING values for the durations of the brew effects. I included them in modmain. Skyminer Character mod (14).zip Ok, thanks. I''ll try that Link to comment Share on other sites More sharing options...
Eremus007 Posted June 19, 2016 Author Share Posted June 19, 2016 15 hours ago, DarkXero said: There were missing TUNING values for the durations of the brew effects. I included them in modmain. Skyminer Character mod (14).zip WORKS LIKE A CHARM NOW! You're the best DarkXero! Thank you so much! Link to comment Share on other sites More sharing options...
Eremus007 Posted June 20, 2016 Author Share Posted June 20, 2016 On 19-6-2016 at 11:46 AM, Eremus007 said: On 19-6-2016 at 3:14 AM, DarkXero said: There were missing TUNING values for the durations of the brew effects. I included them in modmain. Skyminer Character mod (14).zip Hi DarkXero, I have been improving the mod and the Brews, and I would like to add a widget/badge for the resttimes. So like, when you drink the ale/tonic the correspondating badge will appear and show you how much time you have left. I copied the scripts and tex from the Moisture Widget and modified them to my liking. But I really don't understand what I was doing or what most of the lines in those scripts mean. Could you help me with this one more time? P.S. The mod given here is still untested and unchecked. Skyminer Character mod (15).zip 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