. . . Posted August 29, 2016 Share Posted August 29, 2016 (edited) 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 !!!!!!!!!!! Edited August 29, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/69862-solved-how-to-say-when-characters-inside-cave-for-event/ Share on other sites More sharing options...
Lumina Posted August 29, 2016 Share Posted August 29, 2016 there is a tag "cave" if i'm not wrong. Link to comment https://forums.kleientertainment.com/forums/topic/69862-solved-how-to-say-when-characters-inside-cave-for-event/#findComment-808371 Share on other sites More sharing options...
. . . Posted August 29, 2016 Author Share Posted August 29, 2016 8 minutes ago, Lumina said: there is a tag "cave" if i'm not wrong. I think you mean "cavedweller" & that's only for entities that live in cave I think. Link to comment https://forums.kleientertainment.com/forums/topic/69862-solved-how-to-say-when-characters-inside-cave-for-event/#findComment-808372 Share on other sites More sharing options...
Lumina Posted August 29, 2016 Share Posted August 29, 2016 No, i mean a tag "cave" Here is an example of code i found : local _iscave = inst:HasTag("cave") (in component/ambientlighting.lua) So i guess you could use it to check if cave or not. Link to comment https://forums.kleientertainment.com/forums/topic/69862-solved-how-to-say-when-characters-inside-cave-for-event/#findComment-808378 Share on other sites More sharing options...
. . . Posted August 29, 2016 Author Share Posted August 29, 2016 (edited) 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 August 29, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/69862-solved-how-to-say-when-characters-inside-cave-for-event/#findComment-808387 Share on other sites More sharing options...
Serpens Posted August 29, 2016 Share Posted August 29, 2016 (edited) 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 August 29, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/69862-solved-how-to-say-when-characters-inside-cave-for-event/#findComment-808408 Share on other sites More sharing options...
. . . Posted August 29, 2016 Author Share Posted August 29, 2016 (edited) @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 ? Edited August 29, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/69862-solved-how-to-say-when-characters-inside-cave-for-event/#findComment-808410 Share on other sites More sharing options...
Serpens Posted August 29, 2016 Share Posted August 29, 2016 (edited) 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 August 29, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/69862-solved-how-to-say-when-characters-inside-cave-for-event/#findComment-808411 Share on other sites More sharing options...
. . . Posted August 29, 2016 Author Share Posted August 29, 2016 (edited) 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 !!!!!!! GetWorld():IsCave() Edited August 29, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/69862-solved-how-to-say-when-characters-inside-cave-for-event/#findComment-808412 Share on other sites More sharing options...
Sukaiba Posted September 7, 2024 Share Posted September 7, 2024 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? Link to comment https://forums.kleientertainment.com/forums/topic/69862-solved-how-to-say-when-characters-inside-cave-for-event/#findComment-1746444 Share on other sites More sharing options...
Serpens Posted September 8, 2024 Share Posted September 8, 2024 (edited) 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 (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 September 8, 2024 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/69862-solved-how-to-say-when-characters-inside-cave-for-event/#findComment-1746523 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