Results 1 to 9 of 9

Thread: Little help with a script.

  1. #1
    iBot User
    Join Date
    Aug 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    1 Post(s)
    Reputation
    28
    Rep Power
    5

    Little help with a script.

    Hello brothers, I'm creating a script and I'm having problems with an action.
    In my setup, i put an option to chose what's the cave that the char will hunt, like that:

    cave1 = true
    cave2 = true
    cave3 = false

    But in the action, on waypoints... the action that I made is not working.
    that's the action:

    if cave1 = true then
    gotolabel('downcave1')
    else
    gotolabel('nocave1')
    end

    What I'm doing wrong?

  2. #2
    Normal User
    Join Date
    Jun 2012
    Location
    Sweden
    Posts
    1,671
    Mentioned
    18 Post(s)
    Tagged
    1 Thread(s)
    Quoted
    8 Post(s)
    Reputation
    132
    Rep Power
    9
    if cave1 == true then

  3. #3
    iBot User
    Join Date
    Aug 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    1 Post(s)
    Reputation
    28
    Rep Power
    5
    Thank you sir =]

    But, can you explain me why I need to use two "=="?
    Cuz I'm learning =]

  4. #4
    Normal User
    Join Date
    Jun 2012
    Location
    Sweden
    Posts
    1,671
    Mentioned
    18 Post(s)
    Tagged
    1 Thread(s)
    Quoted
    8 Post(s)
    Reputation
    132
    Rep Power
    9
    One "=" means define a variable
    Double "==" means compare two values or strings
    PHP Code:
    -- in this case it will execute the action below as the values match
    one 
    1
    if one == 1 then
        
    --code
    end



    -- in this case it wont execute the code below as the values dont match
    two 
    3
    if two == 2 then 
        
    -- code
    end 
    Last edited by soder; 10-25-2012 at 12:27 AM.

  5. #5
    iBot User pink_panther's Avatar
    Join Date
    May 2012
    Location
    Australia
    Posts
    4,075
    Mentioned
    49 Post(s)
    Tagged
    1 Thread(s)
    Quoted
    178 Post(s)
    Reputation
    309
    Rep Power
    10
    actually, saying "two == 3" will cause an error in itself :P

    Also, what you can do is say....
    PHP Code:
    if cave1 true then 
    which is the same as saying
    PHP Code:
    if cave then 
    If the value is a bool (a bool is a true or false value), it will assume you mean true.

    Furthermore, if you want:
    PHP Code:
    if cave == false then 
    You can you say
    PHP Code:
    if not cave then 
    Doing it like that side steps the whole = or == thing completely :P

    That being said, if you want to compare an int (number) you need to use ==
    Last edited by pink_panther; 10-25-2012 at 12:28 AM.

  6. #6
    Normal User
    Join Date
    Jun 2012
    Location
    Sweden
    Posts
    1,671
    Mentioned
    18 Post(s)
    Tagged
    1 Thread(s)
    Quoted
    8 Post(s)
    Reputation
    132
    Rep Power
    9
    Quote Originally Posted by pink_panther View Post
    actually, saying "two == 3" will cause an error in itself :P
    Ah, my bad :P And you got an error in yours
    PHP Code:
    if cave1 true then 

  7. #7
    iBot User pink_panther's Avatar
    Join Date
    May 2012
    Location
    Australia
    Posts
    4,075
    Mentioned
    49 Post(s)
    Tagged
    1 Thread(s)
    Quoted
    178 Post(s)
    Reputation
    309
    Rep Power
    10
    Ah, thats just coz i copy n pasted sergioasj's :P

  8. #8
    Normal User dragonicevo's Avatar
    Join Date
    May 2012
    Location
    canada
    Posts
    1,600
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    3 Post(s)
    Reputation
    65
    Rep Power
    8
    haha nice job guys i have wondered this as well.
    this was my 800th post wish me more luck so i can be better hehe
    http://www.tibiaibot.com/forum/showt...2925#post42925 for basic setup for knight

    If i helped or you liked my scripts rep + me

    trusted free scripts by pink_panther and 3173654 and acid alchamy and marlhex and spens13

  9. #9
    iBot User
    Join Date
    Aug 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    1 Post(s)
    Reputation
    28
    Rep Power
    5
    Thank you brothers, now I understand...
    So I can make my own actions.
    Thank you all.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •