Jump to content

(help) Custom TAB or RECIPE avaliable only during the night


Recommended Posts

Hello everyone.

After fight a lot to start to understand how to MOD things in DST, I reached a point where I wasn't able to fix by myself.

My character is a star gazer and he can craft a custom item called "star chart" who work similar to item "map scroll". This item is always available in "Cartography" tab since you have the ingredients to craft it. So the issue is:
 

Since he is only able to create "star charts" when he can see the stars, he only could make this item during the night phase of the game and in the "forest world". Not inside "caves".

So, there is a way to make the recipe be available to craft only during the night phase? And the is a way to add a speech like "I can't draw what I can't see" when the character tries to create this item during  the day, dusk or in the caves?
 

Here is what my star_chart.lua looks like now (it's a bit dirty >_<):

Spoiler

local assets =
{
    Asset("ANIM", "anim/star_chart.zip"),

    Asset("ATLAS", "images/inventoryimages/star_chart.xml"),
    Asset("IMAGE", "images/inventoryimages/star_chart.tex"),
}

local function OnBuilt(inst, builder)
    inst.components.maprecorder:RecordMap(builder)
end

local function OnTeach(inst, learner)
    learner:PushEvent("learnmap", { map = inst })
end

local function OnDataChanged(inst)
    local maprecorder = inst.components.maprecorder

    inst.components.inspectable:SetDescription(
        maprecorder:HasData() and
        subfmt(STRINGS.MAPRECORDER.MAPDESC, {
            author = maprecorder.mapauthor or STRINGS.MAPRECORDER.UNKNOWN_AUTHOR,
            day = maprecorder.mapday ~= nil and tostring(maprecorder.mapday) or STRINGS.MAPRECORDER.UNKNOWN_DAY,
            location = maprecorder.maplocation ~= nil and STRINGS.MAPRECORDER.LOCATION[string.upper(maprecorder.maplocation)] or STRINGS.MAPRECORDER.LOCATION.DEFAULT,
        }) or
        nil
    )

--    if maprecorder.maplocation == "cave" then
--        inst.AnimState:SetBuild("star_chart")
--        inst.components.inventoryitem:ChangeImageName("mapscroll_cave")
--    else
--        inst.AnimState:SetBuild("star_chart")
--        inst.components.inventoryitem:ChangeImageName()
--    end
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("star_chart")
    inst.AnimState:SetBuild(TheWorld.worldprefab == "cave" and "mapscroll_cave" or "star_chart")
    inst.AnimState:PlayAnimation("idle")

    MakeInventoryFloatable(inst, "med", nil, 0.85)

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("inspectable")
    inst:AddComponent("maprecorder")
    inst.components.maprecorder:SetOnTeachFn(OnTeach)
    inst.components.maprecorder:SetOnDataChangedFn(OnDataChanged)

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "star_chart"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/star_chart.xml"
    --if TheWorld.worldprefab == "cave" then
   -- inst.components.inventoryitem:ChangeImageName("mapscroll_cave")
    --end

    inst:AddComponent("fuel")
    inst.components.fuel.fuelvalue = TUNING.SMALL_FUEL

    MakeSmallBurnable(inst, TUNING.SMALL_BURNTIME)
    MakeSmallPropagator(inst)

    MakeHauntableLaunch(inst)

    inst.OnBuiltFn = OnBuilt

    return inst
end

return Prefab("star_chart", fn, assets)

 



And here is my modmain.lua (equally dirty):

Spoiler

-- fav_pencil name and description

GLOBAL.STRINGS.NAMES.FAV_PENCIL = "Favorite Pencil"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FAV_PENCIL = "The Good'n old friend of a artist."
GLOBAL.STRINGS.RECIPE_DESC.FAV_PENCIL = "Almost a Fabre Castle!"

-- star_chart name and description

GLOBAL.STRINGS.NAMES.STAR_CHART = "Star Chart"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.STAR_CHART = "The Stars can show us the way."
GLOBAL.STRINGS.RECIPE_DESC.STAR_CHART = "You are never lost looking the sky."

-- fav_pencil config

--Craft

local fav_pencil_recipe = 
AddRecipe("fav_pencil", {Ingredient("twigs", 3), Ingredient("charcoal", 3), Ingredient("razor", 1)}, GLOBAL.RECIPETABS.TOOLS, GLOBAL.TECH.SCIENCE_ONE,
nil, 
nil, 
nil, 
nil, 
"artist",
"images/inventoryimages/fav_pencil.xml")

local star_chart_recipe =
AddRecipe("star_chart", {Ingredient("fav_pencil", 1, "images/inventoryimages/fav_pencil.xml"), Ingredient("waxpaper", 1)}, GLOBAL.RECIPETABS.CARTOGRAPHY, GLOBAL.TECH.CARTPGRAPHY_ONE,
nil, 
nil, 
nil, 
nil, 
"artist",
"images/inventoryimages/star_chart.xml")

--function() return
--end


PrefabFiles = {
	"wachs",
	"wachs_none",
    "fav_pencil",
    "star_chart",
}

Assets = {
    Asset( "IMAGE", "images/saveslot_portraits/wachs.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/wachs.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/wachs.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wachs.xml" ),
	
    Asset( "IMAGE", "images/selectscreen_portraits/wachs_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wachs_silho.xml" ),

    Asset( "IMAGE", "bigportraits/wachs.tex" ),
    Asset( "ATLAS", "bigportraits/wachs.xml" ),
	
	Asset( "IMAGE", "images/map_icons/wachs.tex" ),
	Asset( "ATLAS", "images/map_icons/wachs.xml" ),
	
	Asset( "IMAGE", "images/avatars/avatar_wachs.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_wachs.xml" ),
	
	Asset( "IMAGE", "images/avatars/avatar_ghost_wachs.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_ghost_wachs.xml" ),
	
	Asset( "IMAGE", "images/avatars/self_inspect_wachs.tex" ),
    Asset( "ATLAS", "images/avatars/self_inspect_wachs.xml" ),
	
	Asset( "IMAGE", "images/names_wachs.tex" ),
    Asset( "ATLAS", "images/names_wachs.xml" ),
	
	Asset( "IMAGE", "images/names_gold_wachs.tex" ),
    Asset( "ATLAS", "images/names_gold_wachs.xml" ),
	
    Asset( "IMAGE", "bigportraits/wachs_none.tex" ),
    Asset( "ATLAS", "bigportraits/wachs_none.xml" ),

    Asset( "IMAGE", "images/inventoryimages/fav_pencil.tex"),
    Asset( "ATLAS", "images/inventoryimages/fav_pencil.xml"),

    Asset( "IMAGE", "images/inventoryimages/star_chart.tex"),
    Asset( "ATLAS", "images/inventoryimages/star_chart.xml"),
}

AddMinimapAtlas("images/map_icons/wachs.xml")

local TECH = GLOBAL.TECH
local RECIPETABS = GLOBAL.RECIPETABS
local Ingredient = GLOBAL.Ingredient
local ACTIONS = GLOBAL.ACTIONS
local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS

-- The character select screen lines
STRINGS.CHARACTER_TITLES.wachs = "The Star Gazer"
STRINGS.CHARACTER_NAMES.wachs = "Wachs"
STRINGS.CHARACTER_DESCRIPTIONS.wachs = "*Is a Night Owl.\n*Enjoy the cool night breeze.\n*Loves to draw."
STRINGS.CHARACTER_QUOTES.wachs = "\"There is nothing like the stars. Wonderful!\""

-- Custom speech strings
STRINGS.CHARACTERS.WACHS = require "speech_wachs"

-- The character's name as appears in-game 
STRINGS.NAMES.WACHS = "Wachs"

-- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL.
AddModCharacter("wachs", "MALE")

 

Thanks since now! =)

Edited by Joy Machs
updated the star_chart.lua
Link to comment
Share on other sites

10 hours ago, Joy Machs said:

Hello everyone.

After fight a lot to start to understand how to MOD things in DST, I reached a point where I wasn't able to fix by myself.

My character is a star gazer and he can craft a custom item called "star chart" who work similar to item "map scroll". This item is always available in "Cartography" tab since you have the ingredients to craft it. So the issue is:
 

Since he is only able to create "star charts" when he can see the stars, he only could make this item during the night phase of the game and in the "forest world". Not inside "caves".

So, there is a way to make the recipe be available to craft only during the night phase? And the is a way to add a speech like "I can't draw what I can't see" when the character tries to create this item during  the day, dusk or in the caves?
 

Here is what my star_chart.lua looks like now (it's a bit dirty >_<):

  Reveal hidden contents


local assets =
{
    Asset("ANIM", "anim/star_chart.zip"),

    Asset("ATLAS", "images/inventoryimages/star_chart.xml"),
    Asset("IMAGE", "images/inventoryimages/star_chart.tex"),
}

local function OnBuilt(inst, builder)
    inst.components.maprecorder:RecordMap(builder)
end

local function OnTeach(inst, learner)
    learner:PushEvent("learnmap", { map = inst })
end

local function OnDataChanged(inst)
    local maprecorder = inst.components.maprecorder

    inst.components.inspectable:SetDescription(
        maprecorder:HasData() and
        subfmt(STRINGS.MAPRECORDER.MAPDESC, {
            author = maprecorder.mapauthor or STRINGS.MAPRECORDER.UNKNOWN_AUTHOR,
            day = maprecorder.mapday ~= nil and tostring(maprecorder.mapday) or STRINGS.MAPRECORDER.UNKNOWN_DAY,
            location = maprecorder.maplocation ~= nil and STRINGS.MAPRECORDER.LOCATION[string.upper(maprecorder.maplocation)] or STRINGS.MAPRECORDER.LOCATION.DEFAULT,
        }) or
        nil
    )

--    if maprecorder.maplocation == "cave" then
--        inst.AnimState:SetBuild("star_chart")
--        inst.components.inventoryitem:ChangeImageName("mapscroll_cave")
--    else
--        inst.AnimState:SetBuild("star_chart")
--        inst.components.inventoryitem:ChangeImageName()
--    end
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("star_chart")
    inst.AnimState:SetBuild(TheWorld.worldprefab == "cave" and "mapscroll_cave" or "star_chart")
    inst.AnimState:PlayAnimation("idle")

    MakeInventoryFloatable(inst, "med", nil, 0.85)

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("inspectable")
    inst:AddComponent("maprecorder")
    inst.components.maprecorder:SetOnTeachFn(OnTeach)
    inst.components.maprecorder:SetOnDataChangedFn(OnDataChanged)

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "star_chart"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/star_chart.xml"
    --if TheWorld.worldprefab == "cave" then
   -- inst.components.inventoryitem:ChangeImageName("mapscroll_cave")
    --end

    inst:AddComponent("fuel")
    inst.components.fuel.fuelvalue = TUNING.SMALL_FUEL

    MakeSmallBurnable(inst, TUNING.SMALL_BURNTIME)
    MakeSmallPropagator(inst)

    MakeHauntableLaunch(inst)

    inst.OnBuiltFn = OnBuilt

    return inst
end

return Prefab("star_chart", fn, assets)

 



And here is my modmain.lua (equally dirty):

  Reveal hidden contents


-- fav_pencil name and description

GLOBAL.STRINGS.NAMES.FAV_PENCIL = "Favorite Pencil"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FAV_PENCIL = "The Good'n old friend of a artist."
GLOBAL.STRINGS.RECIPE_DESC.FAV_PENCIL = "Almost a Fabre Castle!"

-- star_chart name and description

GLOBAL.STRINGS.NAMES.STAR_CHART = "Star Chart"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.STAR_CHART = "The Stars can show us the way."
GLOBAL.STRINGS.RECIPE_DESC.STAR_CHART = "You are never lost looking the sky."

-- fav_pencil config

--Craft

local fav_pencil_recipe = 
AddRecipe("fav_pencil", {Ingredient("twigs", 3), Ingredient("charcoal", 3), Ingredient("razor", 1)}, GLOBAL.RECIPETABS.TOOLS, GLOBAL.TECH.SCIENCE_ONE,
nil, 
nil, 
nil, 
nil, 
"artist",
"images/inventoryimages/fav_pencil.xml")

local star_chart_recipe =
AddRecipe("star_chart", {Ingredient("fav_pencil", 1, "images/inventoryimages/fav_pencil.xml"), Ingredient("waxpaper", 1)}, GLOBAL.RECIPETABS.CARTOGRAPHY, GLOBAL.TECH.CARTPGRAPHY_ONE,
nil, 
nil, 
nil, 
nil, 
"artist",
"images/inventoryimages/star_chart.xml")

--function() return
--end


PrefabFiles = {
	"wachs",
	"wachs_none",
    "fav_pencil",
    "star_chart",
}

Assets = {
    Asset( "IMAGE", "images/saveslot_portraits/wachs.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/wachs.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/wachs.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wachs.xml" ),
	
    Asset( "IMAGE", "images/selectscreen_portraits/wachs_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wachs_silho.xml" ),

    Asset( "IMAGE", "bigportraits/wachs.tex" ),
    Asset( "ATLAS", "bigportraits/wachs.xml" ),
	
	Asset( "IMAGE", "images/map_icons/wachs.tex" ),
	Asset( "ATLAS", "images/map_icons/wachs.xml" ),
	
	Asset( "IMAGE", "images/avatars/avatar_wachs.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_wachs.xml" ),
	
	Asset( "IMAGE", "images/avatars/avatar_ghost_wachs.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_ghost_wachs.xml" ),
	
	Asset( "IMAGE", "images/avatars/self_inspect_wachs.tex" ),
    Asset( "ATLAS", "images/avatars/self_inspect_wachs.xml" ),
	
	Asset( "IMAGE", "images/names_wachs.tex" ),
    Asset( "ATLAS", "images/names_wachs.xml" ),
	
	Asset( "IMAGE", "images/names_gold_wachs.tex" ),
    Asset( "ATLAS", "images/names_gold_wachs.xml" ),
	
    Asset( "IMAGE", "bigportraits/wachs_none.tex" ),
    Asset( "ATLAS", "bigportraits/wachs_none.xml" ),

    Asset( "IMAGE", "images/inventoryimages/fav_pencil.tex"),
    Asset( "ATLAS", "images/inventoryimages/fav_pencil.xml"),

    Asset( "IMAGE", "images/inventoryimages/star_chart.tex"),
    Asset( "ATLAS", "images/inventoryimages/star_chart.xml"),
}

AddMinimapAtlas("images/map_icons/wachs.xml")

local TECH = GLOBAL.TECH
local RECIPETABS = GLOBAL.RECIPETABS
local Ingredient = GLOBAL.Ingredient
local ACTIONS = GLOBAL.ACTIONS
local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS

-- The character select screen lines
STRINGS.CHARACTER_TITLES.wachs = "The Star Gazer"
STRINGS.CHARACTER_NAMES.wachs = "Wachs"
STRINGS.CHARACTER_DESCRIPTIONS.wachs = "*Is a Night Owl.\n*Enjoy the cool night breeze.\n*Loves to draw."
STRINGS.CHARACTER_QUOTES.wachs = "\"There is nothing like the stars. Wonderful!\""

-- Custom speech strings
STRINGS.CHARACTERS.WACHS = require "speech_wachs"

-- The character's name as appears in-game 
STRINGS.NAMES.WACHS = "Wachs"

-- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL.
AddModCharacter("wachs", "MALE")

 

Thanks since now! =)

I've got an idea what you could try doing.
 

local tinkeringtab = AddRecipeTab("Tinkering", 10, "images/tinkering_tab.xml", "tinkering_tab.tex", "tinkeringtab")
local wagstaffnormalgoggles_recipe = AddRecipe("wagstaffnormalgoggles", {Ingredient("goldnugget", 1), Ingredient("pigskin", 1)}, tinkeringtab, TECH.NONE, nil, nil, nil, nil)

You need to create a new crafting tab similar to how I did, and the last bit of it "tinkeringtab" is the tag needed to access that tab, So only characters with the tinkeringtab tag can access  it, So what you could do is watch the world states using inst:WatchWorldState I believe, and once it becomes night you add the tag, and once night is over you remove the tag. Thus removing access to the recipe during day and dusk but letting you accces it during night.

Link to comment
Share on other sites

Thanks for your suggestions, I was able to make some progress. Here we go:

My character LUA  has a local function to determinate his speed depending the time of the day: day/dusk/night:
 

-- Speed values
local day_speed = 0.9
local dusk_speed = 1
local night_speed = 1.2

local function onphase(inst, phase)
	local speed = 1
	
	if phase == "day" then speed = day_speed
	elseif phase == "dusk" then speed = dusk_speed
	else speed = night_speed
	end
	
	inst.components.locomotor:SetExternalSpeedMultiplier( inst, "Acceleration", speed )

end

 

So I thought I could use the same function, but now using tags. I changed the tag of the star chart recipe to "chartman" and write this local function using it:
 

--cartographer
local function onphase(inst, phase)

    if phase == "night" then inst:AddTag("chartman")
    elseif TheWorld.worldprefab == "cave" then inst:RemoveTag("chartman")
    else inst:RemoveTag("chartman")
    end

 

The result was great! No crashes and when my character spawned in the world, the "Cartography" tab wasn't there. When the night came, as I made the first item to create the star chart, the "cartography tab" appear, making the recipe available. (images below)

Spoiler

5d04075fb0cec_Capturadetelade2019-06-1416-54-51.thumb.png.ce388a7808794c964756129738e5eea0.png5d040777a9f39_Capturadetelade2019-06-1417-00-19.thumb.png.ca648b170d9e3404b5498e648e15f5d0.png

But now I hit my face in another issue:

Case 1 - IF I don't craft the item, when the day comes, the cartography tab disappear in the moment I move any item in my inventory.

Case 2 - IF I craft the item, when the day comes, the cartography tab stay there and the recipe disappear. (image below)

Spoiler

5d0407931933b_Capturadetelade2019-06-1417-08-31.thumb.png.0d7813bddae75e2b55f8a114cb335da8.png5d0407b3513b1_Capturadetelade2019-06-1417-09-51.thumb.png.65be11101cfaa24a976b78611f764769.png

In Case 1, as I could see, it seems like the local function only actives the cartography tab when I move some item in my inventory in any sense (moving any item to another space, craft something, picking something...) and the same happens when the day comes. The cartography tab only disappear when I move some item.

In Case 2, my intention is to make the cartography tab disappear, similar to when we get away from the Cartographer Desk. I don't know if has to do with "learn" the recipe and I need to forget it to make the tab disappear of if the is a way to make the tab hide even with the recipe learned.

My gosh... I'm becoming bald with all this issues. XD

EDIT: Just in case someone wants to try my mod, I made it available in workshop. Here goes the link:
Wachs - The star gazer in DST Workshop

Edited by Joy Machs
post a link of my mod
Link to comment
Share on other sites

I am new to lua and modding, so I wouldn't know the code to make it work. But in your first case, it sounds like what you need is for the tab to be unlocked by default. So that it's not reliant on whether you have the crafting materials needed to make anything. While also keeping it linked to the time of day. So all I can really suggest is also looking at what makes the regular tabs unlocked by default. Then try to find a way to link that to the time of day.

As for your second case, I suggest looking at the code for the Ancient Pseudoscience Station. Since crafted items from it are not remembered; in case you want to go that route. I have no idea if it would be possible to simply hide the tab though, probably is.

I imagine the reason the recipe is disappearing is because the night time requirement is linked to it. But not linked to the tab disappearing. So either find a way to make the tab disappear too. Or keep the recipe from being remembered.

Link to comment
Share on other sites

11 hours ago, eternalLocket said:

I suggest looking at the code for the Ancient Pseudoscience Station.

So, based on this hint, I could make a small progress. Thanks!

First, I searched for the altar_prototyper.lua, but then I thought: "he said the crafted itens aren't remembered"... So I decided to search the recipes of the Ancient Tab. A thing ancient recipes had in common is a "unlock = true" in their recipes scripts. So I did the same with my star char:

----------
local star_chart_recipe =
AddRecipe("star_chart", {Ingredient("fav_pencil", 1, "images/inventoryimages/fav_pencil.xml"), Ingredient("waxpaper", 1)}, GLOBAL.RECIPETABS.CARTOGRAPHY,
GLOBAL.TECH.CARTPGRAPHY_ONE,
nil,
nil,
true, (this nil was related to the item be remembered(I don't know if I can use this term) or not.)
nil,
"chartman",
"images/inventoryimages/star_chart.xml")
----------

Now, the only thing I need is to make the cartography tab appear automatically when the night falls and disappear when the sun rises.

 

11 hours ago, eternalLocket said:

But in your first case, it sounds like what you need is for the tab to be unlocked by default. So that it's not reliant on whether you have the crafting materials needed to make anything. While also keeping it linked to the time of day.

Yes. I took a look in the science machine and cartographer desk to try to understand how they become available through "proximity", but I couldn't realize how to do it relating with the world time.

A workaround would be: make the function inspect the inventory (something like read the itens or refresh the inventory) when the night falls and inspect again when the sun rises... but I don't know if it would work and how I can do it.

Link to comment
Share on other sites

21 hours ago, Joy Machs said:

Now, the only thing I need is to make the cartography tab appear automatically when the night falls and disappear when the sun rises.

Just like people told you above. Make a periodic task with inst:DoPeriodicTask() and check TheWorld.state.isday 

Add tag "hide", check If night and has tag "hide" then remove tag "hide" add tag "show" and put your code, otherwise (not night and has tag "show") remove tag "show" and add tag "hide". And then start periodic task with that function. Something like that...

Probably you don't need to inspect your inventory. If you aren't sure how to try to look for game's scripts.

Edited by TheZotikRus
Link to comment
Share on other sites

6 hours ago, TheZotikRus said:

Just like people told you above. Make a periodic task with inst:DoPeriodicTask() and check TheWorld.state.isday 

Add tag "hide", check If night and has tag "hide" then remove tag "hide" add tag "show" and put your code, otherwise (not night and has tag "show") remove tag "show" and add tag "hide". And then start periodic task with that function. Something like that...

I'm afraid I'm not able to script your idea. I can understand what you said, but I wouldn't know how to put it to work or how to write the lines. My knowledge about LUA was obtained searching others mods and its very poor to be honest.

I confess I looked in others prefrabs like "pigman", "fireflies", "glommer_flower" and other one who has something related with "time" and "night phase", but I wasn't able to recognize any line who could help me out.

Right now, everything I tested leads me to the same result: The cartography tab only appear it I interact with a item in my inventory. The same happens when it has to disappear. It's the last thing I have to do to make my mod complete and that's why I'm asking for help! XD

I'm very grateful for the tips so far, but seems like I can't break this wall alone. =/

Link to comment
Share on other sites

This is not mine idea, I saw it somewhere. I believe it should look like that

Spoiler

inst:AddTag("hide")
local function CheckDayTime(inst)
	if TheWorld.state.isnight and inst:HasTag("hide")
		--SHOW YOUR CARTOGRATHY TAB SOMEHOW
		inst:RemoveTag("hide")
		inst:AddTag("show")
	end
	
	if TheWorld.state.isday and inst:HasTag("show")
		--HIDE YOUR CARTOGRATHY TAB SOMEHOW
		inst:RemoveTag("show")
		inst:AddTag("hide")
	end
end

inst:DoPeriodicTask(0.0, function(inst) CheckDayTime(inst) end)

 

So it should constantly check day state and hide or show your tab. You only need to put your part from altar prototyper or something like that.

Link to comment
Share on other sites

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
 Share

×
  • Create New...