Jump to content

Recommended Posts

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 :)

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?

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 by Eremus007
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 by DarkXero
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

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

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

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

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

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!

  1. 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...