Jump to content

Modify Item


Estremer

Recommended Posts

I have been trying to modify a vanilla item.

 

My intention is that when the item is destroyed it will give another item in the inventory, just like the water bottle does.

 

In order to do that I know that I have to add the ReplaceOnDeplete attribute but the ways that I have been trying have not worked.
I just have lua left to try it with, although I have already tried this lines of code.

 

function UpgradePropaneTank()
	ScriptManager().instance:getItem("Base.PropaneTank"):setReplaceOnDeplete("EmptyTank");
end

Events.OnGameBoot.Add(UpgradePropaneTank);

I have used OnLoad and OnGameStart

Link to comment
Share on other sites

2 hours ago, Asilar said:

Did you checked if your function is ever started ?

With a print("UpgradePropaneTank function entered") for example.


Also, did you tried setReplaceOnDeplete'"Base.EmptyTank") ?

 

This is the line that I find in the console (function: UpgradePropaneTank -- file: PropaneTank.lua line # 2). 

I suppose it indicates that if you call the function.

 

I also tried the setReplaceOnDeplete ("Base.EmptyTank") although the EmptyTank item is created by me

so I tried with its corresponding module "EmptyTank.EmptyTank".

 

To shorten I have also used:

- FindItem() instead of getItem()

- setReplaceOnDeplete("Base.EmptyTank")

- setReplaceOnDeplete("EmptyTank.EmptyTank")

- ReplaceOnDeplete = "EmptyTank" => (I know enough about programming to know that this is not the correct way, but I was already desperate xp)

 

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
×
×
  • Create New...