Results 1 to 4 of 4

Thread: Another question

  1. #1
    Join Date
    Mar 2007
    Posts
    137
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Another question

    So i asked how i would find out which ore the user chose to mine, but i'm just curious if i could do a if (players[0].strings :='tin, copper, iron, etc') then
    findobj?

  2. #2
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    It would be easier to use a case, and use the string the user inputs are the cases.
    then you can use FindObj after you declare the colors or whatever you're going to use in the case

    example:

    SCAR Code:
    var
      Color: Array of Integer;
    begin
      case Lowercase(players[0].strings[1]) of
        'tin': Color: ...
        'copper': Color: ...
        'iron': Color: ...
      end else
      if FindObj(x, y, uptext, Color, 5) then
    Last edited by Runaway; 08-25-2009 at 12:03 AM.

  3. #3
    Join Date
    Feb 2007
    Posts
    3,616
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    To add to what Runaway said,

    You would want to do CurrentPlayer, not 0 for the number, since it is a multi player script:

    SCAR Code:
    var
      Color: Integer;
    case LowerCase(Players[CurrentPlayer].Strings[1])of
      'tin': Color := 239586;
      'iron': Color := 964053;
      //...etc.
    end;
    if(FindObj(x,y,'Mine',Color,5))then

    And the array shouldn't be necessary unless you have multiple colors for each different rock.

  4. #4
    Join Date
    Mar 2008
    Location
    New Jersey
    Posts
    1,673
    Mentioned
    1 Post(s)
    Quoted
    9 Post(s)

    Default

    and to help you with your if/thens, you would've got an error you did:

    if (players[0].strings :='tin, copper, iron, etc') then

    notice the ":=" you don't use := in if/thens, because you'll get an error, it'll think you are trying to set a value, which you don't do in if/thens. It would be:

    if (players[0].strings='tin, copper, iron, etc') then

    but yea, a case would work better, and remember to do lowercase or uppercase, in:

    case lowercase(... or
    case uppercase(...

    and then remember to have the case ofs to be either upper or lower case, depending on which you put after the word case. Good luck scripting.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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