K4stic Posted January 8, 2013 Share Posted January 8, 2013 says error: attempt to perform arithmetic on a nil value setElementData ( source, "cans", tonumber(getElementData(source, "cans") or 0) + cans, false ) Link to comment
Castillo Posted January 8, 2013 Share Posted January 8, 2013 local currentCans = tonumber ( getElementData ( source, "cans" ) ) or 0 setElementData ( source, "cans", currentCans + cans, false ) Link to comment
K4stic Posted January 8, 2013 Author Share Posted January 8, 2013 thx it's work i will say you if i find bug because i have fix with help of community and some my self that 5-6 time's and still bugget after 1 day Link to comment
50p Posted January 8, 2013 Share Posted January 8, 2013 says error: attempt to perform arithmetic on a nil value setElementData ( source, "cans", tonumber(getElementData(source, "cans") or 0) + cans, false ) If you still want that in 1 line which I would unless you need to use current cans number more than once, you need to pay close attention to brackets: setElementData ( source, "cans", ( tonumber( getElementData(source, "cans" ) ) or 0 ) + cans, false ) Link to comment
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