dewu Posted October 9, 2014 Share Posted October 9, 2014 (edited) Hi guys. I have a problem with the use of "or" function, that's my code: if itemName == "Box of Matches" and (getElementData(getLocalPlayer(), "Wood Pile") or getElementData(getLocalPlayer(), "Wooden Sticks") == 0) then i tried every combinations, nothing works, help ;/ That's orginial function: if itemName == "Box of Matches" and getElementData(getLocalPlayer(), "Wood Pile") == 0 then How to add or? Edited October 9, 2014 by Guest Link to comment
spoty Posted October 9, 2014 Share Posted October 9, 2014 did you tryed this if itemName == "Box of Matches" then getElementData(getLocalPlayer(), "Wood Pile") == 0 then return end or if itemName == "Box of Matches" then (getElementData(getLocalPlayer(), "Wood Pile") or getElementData(getLocalPlayer(), "Wooden Sticks") == 0) then return end just a try Link to comment
dewu Posted October 9, 2014 Author Share Posted October 9, 2014 It's not working. Also i tried: if itemName == "Box of Matches" and (getElementData(getLocalPlayer(), "Wood Pile") == 0 or getElementData(getLocalPlayer(), "Wooden Sticks") == 0) then if itemName == "Box of Matches" and getElementData(getLocalPlayer(), "Wood Pile") == 0 or getElementData(getLocalPlayer(), "Wooden Sticks") == 0 then if itemName == "Box of Matches" and getElementData(getLocalPlayer(), "Wood Pile") or getElementData(getLocalPlayer(), "Wooden Sticks") == 0 then if itemName == "Box of Matches" and (getElementData(getLocalPlayer(), "Wood Pile") or getElementData(getLocalPlayer(), "Wooden Sticks") == 0) then if itemName == "Box of Matches" and (getElementData(getLocalPlayer(), "Wood Pile") or getElementData(getLocalPlayer(), "Wooden Sticks")) == 0 then Link to comment
Moderators IIYAMA Posted October 9, 2014 Moderators Share Posted October 9, 2014 then something is wrong with your elementdata. This should work: (your code, not changed at all) if itemName == "Box of Matches" and (getElementData(getLocalPlayer(), "Wood Pile") == 0 or getElementData(getLocalPlayer(), "Wooden Sticks") == 0) then Link to comment
dewu Posted October 10, 2014 Author Share Posted October 10, 2014 It's works if I have Wood Pile and Wooden Sticks in my inventory, then i can use Box of matches ;/ I want use Box of matches when I have Wood Pile or Wooden Sticks. Link to comment
Moderators IIYAMA Posted October 10, 2014 Moderators Share Posted October 10, 2014 if itemName == "Box of Matches" -- if itemName is Box of Matches and ( -- start a new priority ( ( -- tonumber converts it to a number, tonumber(getElementData(localPlayer, "Wood Pile") ) or 0) > 0 or -- if not a number then it is 0 and check if it is higher then 0. ( -- same here tonumber(getElementData(localPlayer, "Wooden Sticks") ) or 0) > 0 ) -- end priority then Link to comment
dewu Posted October 10, 2014 Author Share Posted October 10, 2014 Still it's not working ;c Link to comment
Moderators IIYAMA Posted October 10, 2014 Moderators Share Posted October 10, 2014 debug it manually then. I can't help you if you aren't debugging your variables and elementdata. 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