Jump to content

"Or" function


dewu

Recommended Posts

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 by Guest
Link to comment

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

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

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
  • Moderators
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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...