Results 1 to 6 of 6

Thread: Need help....

  1. #1
    Join Date
    Mar 2007
    Location
    Mars, I thought all men were from Mars.
    Posts
    513
    Mentioned
    7 Post(s)
    Quoted
    124 Post(s)

    Default Need help....

    Sry about the vague title, couldn't think of a good title that would explain what I need help with.

    I want the variable make[0] to hold 2 strings. the first sting is what to make the second is the amount to make. make[1] would hold another 2 strings of the same type, etc. I then would be able to call the variable make[0].potion or make[0].amount to get the different stings from each array. I am not sure on how exactly to set this up. here is what I have come up with so far.

    This should print out:
    Super Attack
    Super Strength
    Super Defence
    Attack
    Simba Code:
    program New;
    {$i srl/srl.scar}

    procedure What_to_Make;
    var
    //don't know how to do this
     Make: TStringArray;
    begin
    SetArrayLength(Make, 2);

        //Fill in what to make
                //Make[i].potion   Make[i].amount
      Make[0] := ('Super Attack', '100');
      Make[1] := ('Super Strength', '100');
      Make[2] := ('Super Defence', '100');
      Make[3] := ('Attack', '100');
    end;

    Begin
    SetupSRL();
    for i := 0 to High(Make) do
      begin
        Writeln(Make[i].potion)

    End.
    Last edited by bud_wis_er_420; 01-08-2012 at 09:07 PM.

  2. #2
    Join Date
    Feb 2011
    Location
    Earth
    Posts
    1,784
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    The way you have it is storing a String Array in a string array, which I don't think you want to do

    Why are the '100' needed?

    Currently: Working on Defending&Attacking in my Castle-Wars Script
    Project Rebuild: 90M/170M

  3. #3
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    something like this
    Simba Code:
    type
      Custom = record
        Potion: string;
        Amount: Integer;
      end;

    var
      Make: array of Custom;

      SetArrayLength(Make, 4);
      Make[0].Potion := 'Super Attack';
      Make[0].Amount := 100;

      Make[1].Potion := 'Super Strength';
      Make[1].Amount := 100;

      Make[2].Potion := 'Super Defence';
      Make[2].Amount := 100;

      Make[3].Potion := 'Attack';
      Make[3].Amount := 100;

    ~shut
    Last edited by Shuttleu; 01-08-2012 at 09:13 PM.

  4. #4
    Join Date
    Mar 2007
    Location
    Mars, I thought all men were from Mars.
    Posts
    513
    Mentioned
    7 Post(s)
    Quoted
    124 Post(s)

    Default

    Quote Originally Posted by Shuttleu View Post
    something like this
    Simba Code:
    type
      Custom = record
        Potion: string;
        Amount: Integer;
      end;

    var
      Make: array of Custom;

      SetArrayLength(Make, 4);
      Make[0].Potion := 'Super Attack';
      Make[0].Amount := 100;

      Make[1].Potion := 'Super Strength';
      Make[1].Amount := 100;

      Make[2].Potion := 'Super Defence';
      Make[2].Amount := 100;

      Make[3].Potion := 'Attack';
      Make[3].Amount := 100;

    ~shut
    Ok i see. Thx but is there anyway to still use my setup procedure with the above for easier reading of users. What I mean is the I like being able to enter the value of the variable make this way:
    Simba Code:
    Make[0] := ('Super Attack', '100');
    This is what people are gona fill out to tell what pots they wana make until I make a GUI for the script anyways.

    ...and is there a tut for this
    Simba Code:
    type
      Custom = record
        Potion: string;
        Amount: Integer;
      end;
    stuff. Never used that before
    Edit: nvm found one.
    Last edited by bud_wis_er_420; 01-08-2012 at 09:22 PM.

  5. #5
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    you can do this
    Simba Code:
    function SetVars(Potion: string; amount: Integer): Custom;
    begin
      Result.Potion:= Potion;
      Result.Amount:= Amount;
    end;

    then you can set them like this
    Simba Code:
    Make[0] := SetVars('Super Attack', 100);

      Make[1] := SetVars('Super Strength', 100);

      Make[2] := SetVars('Super Defence', 100);

      Make[3] := SetVars('Attack', 100);

    ~shut

  6. #6
    Join Date
    Mar 2007
    Location
    Mars, I thought all men were from Mars.
    Posts
    513
    Mentioned
    7 Post(s)
    Quoted
    124 Post(s)

    Default

    Thx for the help, but can you give me an actual compilable example, I'm having trouble arranging everything. Thx very much.

    At least it compiles. But it don't write the viable out.
    Simba Code:
    program New;
    {$i srl/srl.scar}

    type
      Custom = record
        Potion: string;
        Amount: Integer;
      end;

    var
      i: integer;
      Make: array of Custom;

    procedure What_to_Make;
      begin
      SetArrayLength(Make, 4);
      Make[0].Potion := 'Super Attack';
      Make[0].Amount := 100;

      Make[1].Potion := 'Super Strength';
      Make[1].Amount := 100;

      Make[2].Potion := 'Super Defence';
      Make[2].Amount := 100;

      Make[3].Potion := 'Attack';
      Make[3].Amount := 100;
      end;

    Begin
    SetupSRL();
    What_to_Make;
    Writeln(Make[0].potion)
    for i := 0 to High(Make) do
      begin
        Writeln(Make[i].potion)
      end;
    End.
    Last edited by bud_wis_er_420; 01-08-2012 at 10:17 PM.

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
  •