Izeick Posted August 27, 2023 Share Posted August 27, 2023 (edited) Hi everyone. I spent two nights trying to solve a problem with my mod. I wanna create a bag that can be filled with money. I was able to write part of money taking out code, but filling is too hard for me. At the bottom I paste my current code. At the moment, when I try to fill the bag by one unit (500$ is 1 unit; 5000$ is max), it is immediately filled completely. Please help who understands [LUA] media/lua/server/moneybag.lua function Recipe.OnCreate.moneyin(items, result, player) for i=0, items:size()-1 do if items:get(i):getType() == "PERCOM.moneybag" then if items:get(i):getUsedDelta() == 0 then result:setUsedDelta(0.1) else result:setUsedDelta(items:get(i):getUsedDelta() + 0.1) end end end end [SCRIPT] media/scripts/PERCOM_recipes.txt module PERCOM { imports { Base } item moneybag { Weight = 1.1, Type = Drainable, UseWhileEquipped = FALSE, DisappearOnUse = FALSE, UseDelta = 0.1, DisplayName = Moneybag, Icon = Moneybag, WeightEmpty = 0.1, } recipe put500dollars { destroy moneybag, Money = 500, Result: moneybag, Time: 1, Category: Money, CanBeDoneFromFloor: TRUE, OnCreate: Recipe.OnCreate.moneyin, } recipe take500dollars { PERCOM.moneybag = 1, Result: Money = 500, Time: 1, Category: Money, CanBeDoneFromFloor: TRUE, } } Edited August 28, 2023 by Izeick Link to comment Share on other sites More sharing options...
Hugo Qwerty Posted August 27, 2023 Share Posted August 27, 2023 I think items:get(i):getType() will return "moneybag", not "PERCOM.moneybag". Try using getFullType() instead. Izeick 1 Link to comment Share on other sites More sharing options...
Izeick Posted August 27, 2023 Author Share Posted August 27, 2023 11 hours ago, Hugo Qwerty said: I think items:get(i):getType() will return "moneybag", not "PERCOM.moneybag". Try using getFullType() instead. Oh, yes, it fixed everything. Thank you very much Hugo Qwerty 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now