Jump to content

Recommended Posts

I tried to create mod that allow u to change character (same way as useing moonrock idol) when you eat specific food. Some ideas how to do this? 

I am trying to recreate this mod but with diffrent food 

https://steamcommunity.com/sharedfiles/filedetails/?id=2744621519

  • Like 1
On 11/8/2024 at 6:31 PM, LeafyFly said:

I know how to do that but it is a little complex. May you depend my mod directly.

https://steamcommunity.com/sharedfiles/filedetails/?id=3362148629

Sorry but i cant find folder with your mod files :c

For now i have something like this but it didnt work 

local function OnEat(inst, food)
		if food.prefab == "mandrake" then
		TheWorld.components.world_reroll_data:Reroll(player)
		end
end

 

3 hours ago, PonyOfApocalips said:

Sorry but i cant find folder with your mod files :c

For now i have something like this but it didnt work 

local function OnEat(inst, food)
		if food.prefab == "mandrake" then
		TheWorld.components.world_reroll_data:Reroll(player)
		end
end

 

Try replacing `player` with `inst`.

6 hours ago, PonyOfApocalips said:

For now i have something like this but it didnt work 

local function OnEat(inst, food)
		if food.prefab == "mandrake" then
		TheWorld.components.world_reroll_data:Reroll(player)
		end
end

 

Put this in your modmain.lua.

local mandrake_oneaten = function(inst, data)
    local eater = data and data.eater
    if eater and eater.userid and eater:HasTag("player") then
        GLOBAL.TheWorld.components.world_reroll_data:Reroll(eater)
    end
end

AddPrefabPostInit("mandrake", function(inst)
    if GLOBAL.TheWorld.ismastersim then
        inst:ListenForEvent("oneaten", mandrake_oneaten)
    end
end)

 

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