How do you check the inventory through lua? [Solved]
I am making a block that when you punch it, something is removed from your inventory and something else is added. But I always get a "attempt to index global 'player' (a nil value)" bug.
My code:
My code:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
if player:get_inventory():contains_item("main", "cyro:cmatter") then
player:get_inventory():remove_item("main", "cyro:cmatter") do
player:get_inventory():add_item("main", :cyro:kyro_matter")