Jump to content

Recommended Posts

Hello, I need help :(...

So, my character has some command that makes birds spawn faster for a while which's this

        if inst.whistle_cooldown == nil then
        inst.whistle_cooldown = true
        local birdspawner = TheWorld.components.birdspawner
        birdspawner:SetMaxBirds(TUNING.BIRD_SPAWN_MAX_FEATHERHAT)
        birdspawner:SetSpawnTimes(TUNING.BIRD_SPAWN_DELAY_FEATHERHAT)
        inst:DoTaskInTime(90, function() inst.whistle_cooldown = nil end)
        inst:DoTaskInTime(30, function(inst)
        local birdspawner = TheWorld.components.birdspawner
        birdspawner:SetSpawnTimes(TUNING.BIRD_SPAWN_DELAY)
        birdspawner:SetMaxBirds(TUNING.BIRD_SPAWN_MAX)
        end)
        end
        end

now the problem is that if you do this command inside caves obviously birds can't spawn in caves so it crashes the game :(... So, is there a way I can say like for example 

if inst.iscave then
return
end

is there some code like "inst.iscave" or something because I don't know what to do, please help me because i'm so dumb :(......

I appreciate help so much, thank you so, so much for reading my dumb problem & have a gorgeous day/night :D!!!!!!!!!!!

Edited by SuperDavid

I just used

if inst.whistle_cooldown == nil and not inst.iscave then

and got this crash

[00:02:48]: [string "../mods/Adam DST Mod/scripts/stategraphs/SG..."]:3348: attempt to index local 'birdspawner' (a nil value)

dangit :(... :) welp

 

PS. I tried this to & still same crash

if TheWorld.state.iscave then
		return
		end

*cries*

Edited by SuperDavid

the "world" has the tag "cave".
But you can also check
GLOBAL.GetWorld():IsCave()

 

edit:
I'm not 100% sure, if this also works for client, so you should check if this works with caves enabled.
I'm not sure, because for items there is a Tag "INLIMBO" and a function IsInLimbo(). The function can only be called from the host, not from clients. The Tag can be checked from both.
 

Edited by Serpens

@Serpens

I did this

if inst.whistle_cooldown == nil then
		if GLOBAL.GetWorld():IsCave() then
		return
		end
        inst.whistle_cooldown = true
        local birdspawner = TheWorld.components.birdspawner
        birdspawner:SetMaxBirds(TUNING.BIRD_SPAWN_MAX_FEATHERHAT)
        birdspawner:SetSpawnTimes(TUNING.BIRD_SPAWN_DELAY_FEATHERHAT)
        inst:DoTaskInTime(90, function() inst.whistle_cooldown = nil end) -- Cooldown = 1.30.0.
        inst:DoTaskInTime(30, function(inst)
        local birdspawner = TheWorld.components.birdspawner
        birdspawner:SetSpawnTimes(TUNING.BIRD_SPAWN_DELAY)
        birdspawner:SetMaxBirds(TUNING.BIRD_SPAWN_MAX)
        end)
        end
        end,

and got crash " [00:00:26]: [string "../mods/Adam DST Mod/scripts/stategraphs/SG..."]:3346: variable 'GLOBAL' is not declared "

What did I do wrong :shock:?

Edited by SuperDavid

I assumed that your code is in modmain ;)
If in modmain, you need to add GLOBAL to most commands. But if your are not, just delete the "GLOBAL."

I'm sure you can also make
TheWorld:IsCave()   --(-> probably only for host)
TheWorld:HasTag("cave")  --(should always work)

Edited by Serpens

My code's in SGwilson so I just change it to?

Thank you @Serpens  

TheWorld:HasTag("cave")

worked perfectly for me she odn't crash the game anymore, thank you so much man 

:D!!!!!!!

GetWorld():IsCave()
Edited by SuperDavid
On 8/29/2016 at 5:13 PM, Serpens said:

the "world" has the tag "cave".
But you can also check
GLOBAL.GetWorld():IsCave()

 

edit:
I'm not 100% sure, if this also works for client, so you should check if this works with caves enabled.
I'm not sure, because for items there is a Tag "INLIMBO" and a function IsInLimbo(). The function can only be called from the host, not from clients. The Tag can be checked from both.
 

Necro ass but by curiosity, are there other such tags, such as lunar/hermit island tags?

16 hours ago, Sukaiba said:

Necro ass but by curiosity, are there other such tags, such as lunar/hermit island tags?

you summoned me by quoting :D (time is running, can't believe this thread is ~8 years old :D)

All the lua code is accessable, so the best way is to use a program (eg. notepad++) that can search all lua files and search for ":AddTag(" , then you will see what tags are added to what.
Not sure what you want to achieve with a "hermit island"-tag (if there is one, which I doubt), do you want to check if the world has a hermit island? Or do you want to know if the player is currently on that island? For both of it I currently don't know a solution, but I'm out of DST modding since years (only updating a few mods on steam, if it is easily done)

edit:

 

Edited by Serpens

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