Search the Community
Showing results for tags 'components'.
Found 2 results
I know it seems like I live in this forum begging for help right now, but I'm really enjoying learning new things! I'm working on craftable stone/marble graves, and I want to be able to 'engrave' them like you can the signposts in game. I thought it would be fun to be able to mark spots, or to make graveyards for player deaths, or your faithful companions (beefalo graveyard, anyone?) I thought applying this to an item would be as simple as adding the 'writeable' component into the prefab, but it doesn't work. I've also tried making a standalone copy of "writeable" (etc) for my prefab to call on but that doesn't work. I've looked at 'Domestication Plus' since that uses the writeable component somehow, but I can't work out how they've done it. The file attached contains some edits of the files in Domestication Plus. Any hints/help would be appreciated! justjasper Craftable Gravestones (DST).rar
I'm currently having a problem with my code within the modmain of a custom character I was creating and I was able to isolate it down to this line here: if v.components.age:GetAgeInDays() % daysRequired = 0 then What I'm trying to accomplish is a simple RNG item giver to a specific character, but only when their time alive in the world fully divides (nothing in the decimal places) into the required day count (determined by the config data of 'gem_generation'). However, when it comes to running the code below, I always receive the same results from the game. For the line I isolated above, it always crashes saying that "then is expected near =" for said line. I'd appreciate any assistance in finding out the issue as well as how to solve it. The full code: if GetModConfigData('gem_generation') > 0 then local function GiveGems() for i,v in ipairs(AllPlayers) do local daysRequired = tonumber(GetModConfigData('gem_generation')) local playerAge = tonumber(v.components.age:GetAgeInDays()) -- If the player is example, has more than 0 health (isn't dead) and the age of the player meets the generation requirements if (v:HasTag("example")) and (v.components.health.currenthealth > 0) and (playerAge > 1) and not v:HasTag("playerghost") then if v.components.age:GetAgeInDays() % daysRequired = 0 then --Gives the player a random gem local RNG = math.random(1,36) if RNG < 7 then v.components.inventory:GiveItem("redgem") elseif RNG >= 7 and RNG < 13 then v.components.inventory:GiveItem("orangegem") elseif RNG >= 13 and RNG < 19 then v.components.inventory:GiveItem("yellowgem") elseif RNG >= 19 and RNG < 25 then v.components.inventory:GiveItem("greengem") elseif RNG >= 25 and RNG < 31 then v.components.inventory:GiveItem("bluegem") else v.components.inventory:GiveItem("purplegem") end end end end end -- Runs GiveGems local function OnDayComplete(inst,day) GiveGems() end -- Runs GiveGems at the start of a new day AddWorldPostInit(function(w) w:WatchWorldState("cycles", OnDayComplete) end) end