Results 1 to 4 of 4

Thread: Out of range in Form ... Allready searched the whole forum for help =O

  1. #1
    Join Date
    Jan 2007
    Posts
    513
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Out of range in Form ... Allready searched the whole forum for help =O

    Hello, I am getting an out of range error in my script on line 914 =/

    I allready searched the whole forum for this, and I didn't find any answer

    Thanks for your time!

    SCAR Code:
    {.Script Info:
    # ScriptName  = Mage Calc Cost!
    # Author      = Rambozin
    # Description = This calculates how many GP you need from your current Magic xp to you Magic Goal Level.
    # Version     = 5.0
    # Date        = 24 January 2008
    # Comments    = Have Fun! ;)
    /Script Info}


    program MagicCalcCosts;
    {.include SRL/SRL.scar}

    var
      PizzaPointsReturn, RewardsReturn, CosmicLeft, CosmicCost, TotalCosmics,
       CosmicEa, TotalMTAGP, CosmicsPossible, AlchPossible, SpellXP, SpellPoints,
       XPNeeded, CosmicsReturn, TotalCosmicsCost, CosmicsReturnCost, TotalItems,
       CosmicsPossibleXP, AlchXP, TotalAlchGp,AlchPossibleXP, TotalNatureRunes,
       TotalItemCost, AlchBack, AlchCost, TotalItemCostFinal,
       CosmicsReturnPLAN, CosmicsMoneyBack : Extended;
      CosmicLeftRounded, CosmicRounded, GoalXP, AlchPossibleLevel,
       CosmicsPossibleRound, AlchPossibleRound, CosmicsPossibleXPRound,
       CosmicsPossibleXPTotal, CosmicsPossibleLevel, AlchCostRound,
       AlchPossibleXPRound, AlchPossibleXPTotal,  CurrentXP, GoalLevel, Spell,
       TotalMTAGP2, GpNatsEa, GpItemEa,GpAlchEa, TotalAlchGP2, Run : Integer;
      UseMTA2, UseAlch2, StartTheScript, ContinueScriptBool : Boolean;
      ModeAlch, ModeMTA2, AlchSpell, AlchName2, SellRewardRunes, UsePizzaPoints2 : string;
      frmDesign : TForm;
      MagicTrainingArena : TGroupBox;
      MTATitel : TLabel;
      Label1 : TLabel;
      UseMTA : TCheckBox;
      MTAMode : TComboBox;
      SellReward : TComboBox;
      UsePizzaPoints : TComboBox;
      MTAPlanning : TGroupBox;
      MTAMoneyToSpend : TEdit;
      CosmicEa3 : TEdit;
      SpellToUse : TEdit;
      Alchemy : TGroupBox;
      ALCHTitel : TLabel;
      UseAlch : TCheckBox;
      NatsEa : TEdit;
      ItemEa : TEdit;
      AlchEa : TEdit;
      AlchName : TEdit;
      AlchMode : TComboBox;
      AlchModeBox : TComboBox;
      AlchPlanning : TGroupBox;
      AlchMoneyToSpend : TEdit;
      CurrentMagicExp : TEdit;
      MagicGoalLevel : TEdit;
      Button1, Button2 : TButton;

    procedure SetForm;
    begin
      CurrentXP := StrToInt(CurrentMagicExp.Text);
      GoalLevel := StrToInt(MagicGoalLevel.Text);
      UseMTA2 := UseMTA.Checked;
      ModeMTA2 := MTAMode.Text;
      CosmicEa := StrToInt(CosmicEa3.Text);
      Spell := StrToInt(SpellToUse.Text);
      SellRewardRunes := SellReward.Text;
      UsePizzaPoints2 := UsePizzaPoints.Text;
      TotalMTAGP2 :=  StrToInt(MTAMoneyToSpend.Text);
      UseAlch2 := UseAlch.Checked;
      ModeAlch := AlchModeBox.Text;
      AlchSpell := AlchMode.Text;
      GpNatsEa := StrToInt(NatsEa.Text);
      GpItemEa := StrToInt(ItemEa.Text);
      GpAlchEa := StrToInt(AlchEa.Text);
      AlchName2 := AlchName.Text;
      TotalAlchGP2 := StrToInt(AlchMoneyToSpend.Text);
    end;

    procedure ConvertLvlToXPByRambozin;
    begin
      if (GoalLevel = 1) then
        GoalXP := 0;
      if (GoalLevel = 2) then
        GoalXP := 83;
      if (GoalLevel = 3) then
        GoalXP := 174;
      if (GoalLevel = 4) then
        GoalXP := 276;
      if (GoalLevel = 5) then
        GoalXP := 388;
      if (GoalLevel = 6) then
        GoalXP := 512;
      if (GoalLevel = 7) then
        GoalXP := 650;
      if (GoalLevel = 8) then
        GoalXP := 801;
      if (GoalLevel = 9) then
        GoalXP := 969;
      if (GoalLevel = 10) then
        GoalXP := 1154;
      if (GoalLevel = 11) then
        GoalXP := 1358;
      if (GoalLevel = 12) then
        GoalXP := 1584;
      if (GoalLevel = 13) then
        GoalXP := 1833;
      if (GoalLevel = 14) then
        GoalXP := 2107;
      if (GoalLevel = 15) then
        GoalXP := 2411;
      if (GoalLevel = 16) then
        GoalXP := 2746;
      if (GoalLevel = 17) then
        GoalXP := 3115;
      if (GoalLevel = 18) then
        GoalXP := 3523;
      if (GoalLevel = 19) then
        GoalXP := 3973;
      if (GoalLevel = 20) then
        GoalXP := 4470;
      if (GoalLevel = 21) then
        GoalXP := 5018;
      if (GoalLevel = 22) then
        GoalXP := 5624;
      if (GoalLevel = 23) then
        GoalXP := 6291;
      if (GoalLevel = 24) then
        GoalXP := 7028;
      if (GoalLevel = 25) then
        GoalXP := 7842;
      if (GoalLevel = 26) then
        GoalXP := 8740;
      if (GoalLevel = 27) then
        GoalXP := 9730;
      if (GoalLevel = 28) then
        GoalXP := 10824;
      if (GoalLevel = 29) then
        GoalXP := 12031;
      if (GoalLevel = 30) then
        GoalXP := 13363;
      if (GoalLevel = 31) then
        GoalXP := 14833;
      if (GoalLevel = 32) then
        GoalXP := 16456;
      if (GoalLevel = 33) then
        GoalXP := 18247;
      if (GoalLevel = 34) then
        GoalXP := 20224;
      if (GoalLevel = 35) then
        GoalXP := 22406;
      if (GoalLevel = 36) then
        GoalXP := 24815;
      if (GoalLevel = 37) then
        GoalXP := 27473;
      if (GoalLevel = 38) then
        GoalXP := 30408;
      if (GoalLevel = 39) then
        GoalXP := 33648;
      if (GoalLevel = 40) then
        GoalXP := 37224;
      if (GoalLevel = 41) then
        GoalXP := 41171;
      if (GoalLevel = 42) then
        GoalXP := 45529;
      if (GoalLevel = 43) then
        GoalXP := 50339
      if (GoalLevel = 44) then
        GoalXP := 55649;
      if (GoalLevel = 45) then
        GoalXP := 61512;
      if (GoalLevel = 46) then
        GoalXP := 67983;
      if (GoalLevel = 47) then
        GoalXP := 75127;
      if (GoalLevel = 48) then
        GoalXP := 83014;
      if (GoalLevel = 49) then
        GoalXP := 91721;
      if (GoalLevel = 50) then
        GoalXP := 101333;
      if (GoalLevel = 51) then
        GoalXP := 111945;
      if (GoalLevel = 52) then
        GoalXP := 123660;
      if (GoalLevel = 53) then
        GoalXP := 136594;
      if (GoalLevel = 54) then
        GoalXP := 150872;
      if (GoalLevel = 55) then
        GoalXP := 166636;
      if (GoalLevel = 56) then
        GoalXP := 184040;
      if (GoalLevel = 57) then
        GoalXP := 203254;
      if (GoalLevel = 58) then
        GoalXP := 224466;
      if (GoalLevel = 59) then
        GoalXP := 247886;
      if (GoalLevel = 60) then
        GoalXP := 273742;
      if (GoalLevel = 61) then
        GoalXP := 302288
      if (GoalLevel = 62) then
        GoalXP := 333804;
      if (GoalLevel = 63) then
        GoalXP := 368599;
      if (GoalLevel = 64) then
        GoalXP := 407015;
      if (GoalLevel = 65) then
        GoalXP := 449428;
      if (GoalLevel = 66) then
        GoalXP := 496254;
      if (GoalLevel = 67) then
        GoalXP := 547953;
      if (GoalLevel = 68) then
        GoalXP := 605032;
      if (GoalLevel = 69) then
        GoalXP := 688051;
      if (GoalLevel = 70) then
        GoalXP := 373627;
      if (GoalLevel = 71) then
        GoalXP := 814445;
      if (GoalLevel = 72) then
        GoalXP := 899257;
      if (GoalLevel = 73) then
        GoalXP := 992895;
      if (GoalLevel = 74) then
        GoalXP := 1096278;
      if (GoalLevel = 75) then
        GoalXP := 1210421;
      if (GoalLevel = 76) then
        GoalXP := 1336443;
      if (GoalLevel = 77) then
        GoalXP := 1475581;
      if (GoalLevel = 78) then
        GoalXP := 1629200;
      if (GoalLevel = 79) then
        GoalXP := 1798808;
      if (GoalLevel = 80) then
        GoalXP := 1986068;
      if (GoalLevel = 81) then
        GoalXP := 2192818;
      if (GoalLevel = 82) then
        GoalXP := 2421087;
      if (GoalLevel = 83) then
        GoalXP := 2673114;
      if (GoalLevel = 84) then
        GoalXP := 2951373;
      if (GoalLevel = 85) then
        GoalXP := 3258594;
      if (GoalLevel = 86) then
        GoalXP := 3597792;
      if (GoalLevel = 87) then
        GoalXP := 3972294;
      if (GoalLevel = 88) then
        GoalXP := 4385776;
      if (GoalLevel = 89) then
        GoalXP := 4842295;
      if (GoalLevel = 90) then
        GoalXP := 5346332;
      if (GoalLevel = 91) then
        GoalXP := 5902831;
      if (GoalLevel = 92) then
        GoalXP := 6517253;
      if (GoalLevel = 93) then
        GoalXP := 7195629;
      if (GoalLevel = 94) then
        GoalXP := 7944614;
      if (GoalLevel = 95) then
        GoalXP := 8771558;
      if (GoalLevel = 96) then
        GoalXP := 9684577;
      if (GoalLevel = 97) then
        GoalXP := 10692629;
      if (GoalLevel = 98) then
        GoalXP := 11805606;
      if (GoalLevel = 99) then
        GoalXP := 13034431;
    end;

    {*******************************************************************************
    function ConvertXpToLvl(Xp: Integer): Integer;
    By: Brak, Flyboy
    Description: Returns skill level based on xp level
    *******************************************************************************}


    function ConvertXpToLvl(xp: Integer): Integer;
    var
      level, exp: Integer;
    begin
      for level := 1 to 99 do
      begin
        exp := Trunc(level + 300 * Pow(2, level / 7));
        if ((exp / 4) > xp) then
        begin
          Result := level;
          Exit;
        end;
      end;
      Result := 99;
    end;

    procedure Levels;
    begin
      ConvertLvlToXpByRambozin;
      if (UseMTA2 = True) then
      begin
        if (Spell = 1) then
        begin
          if (CurrentXP < 650)then
          begin
           ShowMessage('Sorry, but you can not cast that spell from your current magic level.');
           Exit;
          end;
          SpellXP := 13.125;
          SpellPoints := 0.2;
        end
        if (Spell = 2) then
        begin
          if (CurrentXP < 9730)then
          begin
           ShowMessage('Sorry, but you can not cast that spell from your current magic level.');
           Exit;
          end;
          SpellXP := 27.75;
          SpellPoints := 0.4;
        end
        if (Spell = 3) then
        begin
          if (CurrentXP < 91721)then
          begin
           ShowMessage('Sorry, but you can not cast that spell from your current magic level.');
           Exit;
          end;
          SpellXP := 44.25;
          SpellPoints := 0.6;
        end
        if (Spell = 4) then
        begin
          if (CurrentXP < 203254)then
          begin
           ShowMessage('Sorry, but you can not cast that spell from your current magic level.');
           Exit;
          end;
          SpellXP := 50.25;
          SpellPoints := 0.8;
        end
        if (Spell = 5) then
        begin
          if (CurrentXP < 605032)then
          begin
           ShowMessage('Sorry, but you can not cast that spell from your current magic level.');
           Exit;
          end;
          SpellXP := 58.5;
          SpellPoints := 1;
        end
        if (Spell = 6) then
        begin
          if (CurrentXP < 3972294)then
          begin
           ShowMessage('Sorry, but you can not cast that spell from your current magic level.');
           Exit;
          end;
          SpellXP := 72.75;
          SpellPoints := 1.2;
        end
      end
      if (not (Spell = 1)) and
         (not (Spell = 2)) and
         (not (Spell = 3)) and
         (not (Spell = 4)) and
         (not (Spell = 5)) and
         (not (Spell = 6)) then
      begin
        ShowMessage('Please use 1, 2, 3, 4, 5 or 6 as Spell-name.');
        Exit;
      end
      if (UseAlch2 = True) then
      begin
        if (AlchSpell = 'Low Alchemy') then
          AlchXP := 31;
        if (AlchSpell = 'High Alchemy') then
          AlchXP := 65;
        if (not (AlchSpell = 'Low Alchemy') and (not (AlchSpell = 'High Alchemy'))) then
        begin
          ShowMessage('Please use ''Low Alchemy'' or ''High Alchemy'' as AlchSpell.');
          Exit;
        end;
      end
    end;

    procedure Costs;
    begin
      Levels;
      XPNeeded := GoalXP - CurrentXP;
      if (UseMTA2 = True) then
      begin
        if (ModeMTA2 = 'Calculating') then
        begin
          TotalCosmics := XPNeeded / SpellXP;
          TotalCosmicsCost := TotalCosmics * CosmicEa;
          PizzaPointsReturn := ( TotalCosmics / 10 ) * SpellPoints;
          RewardsReturn := ( TotalCosmics / 20 ) * 3 ;
          if (SellRewardRunes = 'Yes') and (UsePizzaPoints2 = 'Yes') then
          begin
            CosmicsReturn := (PizzaPointsReturn) + (RewardsReturn);
            CosmicLeft := (TotalCosmics) - (PizzaPointsReturn) - (RewardsReturn);
          end
          if (SellRewardRunes = 'Yes') and (UsePizzaPoints2 = 'No') then
          begin
            CosmicsReturn := (PizzaPointsReturn);
            CosmicLeft := (TotalCosmics) - (PizzaPointsReturn);
          end
          if (SellRewardRunes = 'No') and (UsePizzaPoints2 = 'Yes') then
          begin
            CosmicsReturn := RewardsReturn;
            CosmicLeft := (TotalCosmics) - (RewardsReturn);
          end
          if (SellRewardRunes = 'No') and (UsePizzaPoints2 = 'No') then
          begin
            CosmicsReturn := 0;
            CosmicLeft := (TotalCosmics)
          end
          CosmicsReturnCost := CosmicsReturn * CosmicEa;
          CosmicLeftRounded := (Round(CosmicLeft));
          CosmicCost := CosmicLeft * CosmicEa;
          CosmicRounded := (Round(CosmicCost));
          ShowMessage('MAGIC TRAINING ARENA CALCULATOR:' + chr(13) +'You need ' + IntToStr(Round(XpNeeded)) + ' exp for level ' + IntToStr(GoalLevel) + ' magic.' + chr(13) +'You will need to buy ' + IntToStr(Round(TotalCosmics)) +' Cosmic Runes in total.' + chr(13) +'That will cost ' + IntToStr(Round(TotalCosmicsCost)) +' coins.' + chr(13) +'After your reached level ' + IntToStr(GoalLevel) + ' magic, there will be ' + IntToStr(Round(CosmicsReturn))+ ' Cosmic Runes that you get back.' + chr(13) +'That will be ' + IntToStr(Round(CosmicsReturnCost))+ ' coins that you get back.' + chr(13) +'So you actually need to pay ' + IntToStr(CosmicLeftRounded) + ' Cosmic Runes.' + chr(13) +' -->>  That will be ' + IntToStr(CosmicRounded) + ' coins that you will loose. <<-- ');
        end
        if (ModeMTA2 = 'Planning') then
        begin
          CosmicsPossible := (TotalMTAGP) / (CosmicEa);
          CosmicsPossibleRound := Trunc(CosmicsPossible);
          CosmicsPossibleXP := CosmicsPossible * SpellXP;
          CosmicsPossibleXPRound := Round(CosmicsPossibleXP);
          CosmicsPossibleXPTotal := CosmicsPossibleXPRound + CurrentXP;
          CosmicsPossibleLevel := ConvertXPToLvl(CosmicsPossibleXPTotal);
          if (SellRewardRunes = 'Yes') and (UsePizzaPoints2 = 'Yes') then
            CosmicsReturnPLAN := (PizzaPointsReturn) + (RewardsReturn);
          if (SellRewardRunes = 'Yes') and (UsePizzaPoints2 = 'No') then
            CosmicsReturnPLAN := (PizzaPointsReturn);
          if (SellRewardRunes = 'No') and (UsePizzaPoints2 = 'Yes') then
            CosmicsReturnPLAN := RewardsReturn;
          if (SellRewardRunes = 'No') and (UsePizzaPoints2 = 'No') then
            CosmicsReturnPLAN := 0;
          CosmicsMoneyBack := CosmicsReturnPLAN * CosmicEa;
          ShowMessage('MAGIC TRAINING ARENA PLANNER:' + chr(13) +'You can buy ' + IntToStr(CosmicsPossibleRound) + ' Cosmic Runes from ' + IntToStr(TotalMTAGP2) +' gp.' + chr(13) +'That will give you ' + IntToStr(CosmicsPossibleXPRound) + ' exp.' + chr(13) +'After your used all your runes, there will be ' + IntToStr(Round(CosmicsReturnPLAN))+ ' Cosmic Runes that you get back.' + chr(13) +'That will give you ' + IntToStr(Round(CosmicsMoneyBack)) +' coins back.' + chr(13) +' -->> Then you will have ' + IntToStr(Round(CosmicsPossibleXPTotal)) + ' exp. <<-- ' + chr(13) +' -->> That will make you ' + IntToStr(CosmicsPossibleLevel) + ' magic. <<-- [This isn''t correct yet! I need to fix this in my next version]');
        end
        if (not (ModeMTA2 = 'Calculating')) and (not (ModeMTA2 = 'Planning')) then
        begin
          ShowMessage('Please use ''Calculating'' or ''Planning'' as Magic Training Arena-mode.')
          TerminateScript;
        end
      end
      if (UseAlch2 = True) then
      begin
        if (ModeAlch = 'Calculating') then
        begin
          TotalItems := XPNeeded / AlchXP;
          TotalNatureRunes := TotalItems * GpNatsEa;
          TotalItemCost := TotalItems * GpItemEa;
          TotalItemCostFinal := TotalItems * (GpItemEa + GpNatsEa);
          AlchBack := TotalItems * GpAlchEa;
          AlchCost := TotalItemCostFinal - AlchBack;
          AlchCostRound := Round(AlchCost);
          ShowMessage('You need ' + IntToStr(Round(XpNeeded)) + ' exp for level ' + IntToStr(GoalLevel) + ' magic.' + chr(13) +'You will need to buy ' + IntToStr(Round(TotalItems)) +' ' + (AlchName2) + '.' + chr(13) +'You need ' + IntToStr(Round(TotalItemCost)) + ' coins to buy these.' + chr(13) +'You will need to buy ' + IntToStr(Round(TotalItems)) +' Nature Runes.' + chr(13) +'You need ' + IntToStr(Round(TotalNatureRunes)) + ' coins to buy these.' + chr(13) +'So in total, you will need ' + IntToStr(Round(TotalItemCostFinal)) + ' coins to buy everything at once.' + chr(13) +'After your reached level ' + IntToStr(GoalLevel) + ' magic, you will have ' + IntToStr(Round(AlchBack)) +' that you get back from alching.' + chr(13) +' -->> So in total, you will loose ' + IntToStr(AlchCostRound) + ' coins. <<--');
        end
        if (ModeAlch = 'Planning') then
        begin
          AlchPossible := (TotalAlchGP) / (GpNatsEa);
          AlchPossibleRound := Trunc(AlchPossible);
          AlchPossibleXP := AlchPossible * AlchXP;
          AlchPossibleXPRound := Round(AlchPossibleXP);
          AlchPossibleXPTotal := AlchPossibleXPRound + CurrentXP;
          AlchPossibleLevel := ConvertXPToLvl(AlchPossibleXPTotal);
          ShowMessage('You can buy ' + IntToStr(AlchPossibleRound) + ' Nature Runes from ' + IntToStr(TotalAlchGP2) +' gp.' + chr(13) +'That will give you ' + IntToStr(AlchPossibleXPRound) + ' exp.' + chr(13) +'Then you will have ' + IntToStr(AlchPossibleXPTotal) + ' exp. <<-- ' + chr(13) +' -->> That will make you ' + IntToStr(AlchPossibleLevel) + ' magic. <<-- [This isn''t correct yet! I need to fix this in the next version]');
        end
        if (not (ModeAlch = 'Calculating')) and (not (ModeAlch = 'Planning')) then
        begin
          ShowMessage('Please use ''Planning'' or ''Calculating'' as Alchemy-Mode.')
          TerminateScript;
        end
      end
      if (not (UseMTA2 = True)) and (not (UseAlch2 = True)) then
      begin
        ShowMessage('Please check the CheckBox of Mage Training Arena or Alchemy.')
        TerminateScript;
      end
      Writeln('Thank you for using Rambozin''s MagicCalcCost!');
    end;

    procedure SaveDetails;
    begin
      SaveSetting('MCCByRambozin', 'CurrentXP', CurrentMagicExp.Text);
      SaveSetting('MCCByRambozin', 'GoalLevel', MagicGoalLevel.Text);
      SaveSetting('MCCByRambozin', 'UseMTA2', BoolToStr(UseMTA.Checked));
      SaveSetting('MCCByRambozin', 'ModeMTA2', MTAMode.Text);
      SaveSetting('MCCByRambozin', 'CosmicEa', CosmicEa3.Text);
      SaveSetting('MCCByRambozin', 'Spell', SpellToUse.Text);
      SaveSetting('MCCByRambozin', 'SellRewardRunes', SellReward.Text);
      SaveSetting('MCCByRambozin', 'UsePizzaPoints2', UsePizzaPoints.Text);
      SaveSetting('MCCByRambozin', 'TotalMTAGP2', MTAMoneyToSpend.Text);
      SaveSetting('MCCByRambozin', 'UseAlch2', BoolToStr(UseAlch.Checked));
      SaveSetting('MCCByRambozin', 'ModeAlch', AlchModeBox.Text);
      SaveSetting('MCCByRambozin', 'AlchSpell', AlchMode.Text);
      SaveSetting('MCCByRambozin', 'GpNatsEa', NatsEa.Text);
      SaveSetting('MCCByRambozin', 'GpItemEa', ItemEa.Text);
      SaveSetting('MCCByRambozin', 'GpAlchEa', AlchEa.Text);
      SaveSetting('MCCByRambozin', 'AlchNAme2', AlchName.Text);
      SaveSetting('MCCByRambozin', 'TotalAlchGP2', AlchMoneyToSpend.Text);
    end;

    procedure ScriptActive;
    begin
      if (StartTheScript = False) then
      begin
        ShowMessage('Script Canceled.');
        TerminateScript;
      end else
      begin
        Costs;
      end
    end;

    procedure ClickedAtStart(Sender : TObject);
    var
      v : TVariantArray;
    begin
      SetArrayLength(V, 0);
      frmDesign.ModalResult := 1;
      SaveDetails;
      StartTheScript := True;
      ScriptActive;
    end;

    procedure ClickedAtCancel(Sender : TObject);
    var
      v : TVariantArray;
    begin
      SetArrayLength(V, 0);
      frmDesign.ModalResult := 2;
      SaveDetails;
      StartTheScript := False;
      ScriptActive;
    end;

    procedure InitForm;
    begin
    frmDesign := CreateForm;
    frmDesign.Left := 234;
    frmDesign.Top := 169;
    frmDesign.Width := 696;
    frmDesign.Height := 342;
    frmDesign.Caption := 'frmDesign';
    frmDesign.Color := clBtnFace;
    frmDesign.Font.Color := clWindowText;
    frmDesign.Font.Height := -11;
    frmDesign.Font.Name := 'MS Sans Serif';
    frmDesign.Font.Style := [];
    frmDesign.Visible := False;
    frmDesign.PixelsPerInch := 96;
    if (Run <= 1) then
    begin
      ShowMessage('I see that it is the first time that you use this script.' + chr(13) +'Please typ a ''0'' everywhere you don''t need to typ something.' + chr(13) +'As Example: You only want to calculate your MTA-Costs. Then typ a 0 everywhere in the Alchemy-Boxes ;)');
    end
    MagicTrainingArena := TGroupBox.Create(frmDesign);
    MagicTrainingArena.Parent := frmDesign;
    MagicTrainingArena.Left := 8;
    MagicTrainingArena.Top := 8;
    MagicTrainingArena.Width := 329;
    MagicTrainingArena.Height := 297;
    MagicTrainingArena.TabOrder := 0;
    MTATitel := TLabel.Create(MagicTrainingArena);
    MTATitel.Parent := MagicTrainingArena;
    MTATitel.Left := 8;
    MTATitel.Top := 0;
    MTATitel.Width := 265;
    MTATitel.Height := 38;
    MTATitel.Caption := 'Magic Training Arena';
    MTATitel.Font.Color := clWindowText;
    MTATitel.Font.Height := -27;
    MTATitel.Font.Name := 'Comic Sans MS';
    MTATitel.Font.Style := [];
    MTATitel.ParentFont := False;
    Label1 := TLabel.Create(MagicTrainingArena);
    Label1.Parent := MagicTrainingArena;
    Label1.Left := 216;
    Label1.Top := 110;
    Label1.Width := 75;
    Label1.Height := 13;
    Label1.Caption := 'Which enchant level?:' + chr(13) + '1, 2, 3, 4, 5 or 6';
    UseMTA := TCheckBox.Create(MagicTrainingArena);
    UseMTA.Parent := MagicTrainingArena;
    UseMTA.Left := 24;
    UseMTA.Top := 48;
    UseMTA.Width := 235;
    UseMTA.Height := 17;
    UseMTA.Caption := 'Calculate/Plan Magic Training Arena Costs?';
    UseMTA.Font.Color := clWindowText;
    UseMTA.Font.Height := -11;
    UseMTA.Font.Name := 'MS Sans Serif';
    UseMTA.Font.Style := [];
    UseMTA.ParentFont := False;
    UseMTA.State := StrToBool(LoadSetting('MCCByRambozin', 'UseMTA2'));
    UseMTA.TabOrder := 0;
    MTAMode := TComboBox.Create(MagicTrainingArena);
    MTAMode.Parent := MagicTrainingArena;
    MTAMode.Left := 24;
    MTAMode.Top := 144;
    MTAMode.Width := 265;
    MTAMode.Height := 21;
    MTAMode.DropDownCount := 2;
    MTAMode.ItemHeight := 13;
    MTAMode.TabOrder := 1;
    if (Run <= 1) then
    begin
      MTAMode.Text := 'What mode to use?';
    end else
    begin
      MTAMode.Text := LoadSetting('MCCByRambozin', 'ModeMTA2');
    end
    MTAMode.Items.Add('Calculating');
    MTAMode.Items.Add('Planning');
    SellReward := TComboBox.Create(MagicTrainingArena);
    SellReward.Parent := MagicTrainingArena;
    SellReward.Left := 24;
    SellReward.Top := 176;
    SellReward.Width := 265;
    SellReward.Height := 21;
    SellReward.ItemHeight := 13;
    SellReward.TabOrder := 2;
    if (Run <= 1) then
    begin
      SellReward.Text := 'Do you sell your reward-runes?';
    end else
    begin
      SellReward.Text := LoadSetting('MCCByRambozin', 'SellRewardRunes');
    end
    SellReward.Items.Add('Yes');
    SellReward.Items.Add('No');
    UsePizzaPoints := TComboBox.Create(MagicTrainingArena);
    UsePizzaPoints.Parent := MagicTrainingArena;
    UsePizzaPoints.Left := 24;
    UsePizzaPoints.Top := 208;
    UsePizzaPoints.Width := 265;
    UsePizzaPoints.Height := 21;
    UsePizzaPoints.ItemHeight := 13;
    UsePizzaPoints.TabOrder := 3;
    if (Run <= 1) then
    begin
      UsePizzaPoints.Text := 'Do you use your PizzaPoints to buy Comic Runes?';
    end else
    begin
      UsePizzaPoints.Text := LoadSetting('MCCByRambozin', 'UsePizzaPoints2');
    end
    UsePizzaPoints.Items.Add('Yes');
    UsePizzaPoints.Items.Add('No');
    MTAPlanning := TGroupBox.Create(MagicTrainingArena);
    MTAPlanning.Parent := MagicTrainingArena;
    MTAPlanning.Left := 0;
    MTAPlanning.Top := 248;
    MTAPlanning.Width := 328;
    MTAPlanning.Height := 49;
    MTAPlanning.Caption := 'Only fill in if using mode Planning';
    MTAPlanning.TabOrder := 4;
    MTAMoneyToSpend := TEdit.Create(MTAPlanning);
    MTAMoneyToSpend.Parent := MTAPlanning;
    MTAMoneyToSpend.Left := 24;
    MTAMoneyToSpend.Top := 16;
    MTAMoneyToSpend.Width := 265;
    MTAMoneyToSpend.Height := 21;
    MTAMoneyToSpend.TabOrder := 0;
    if (Run <= 1) then
    begin
      MTAMoneyToSpend.Text := 'How much money do u want to spend?';
    end else
    begin
      MTAMoneyToSpend.Text := LoadSetting('MCCByRambozin', 'TotalMTAGP2');
    end
    CosmicEa3 := TEdit.Create(MagicTrainingArena);
    CosmicEa3.Parent := MagicTrainingArena;
    CosmicEa3.Left := 24;
    CosmicEa3.Top := 80;
    CosmicEa3.Width := 265;
    CosmicEa3.Height := 21;
    CosmicEa3.TabOrder := 5;
    if (Run <= 1) then
    begin
      CosmicEa3.Text := 'Price of Cosmic Runes each';
    end else
    begin
      CosmicEa3.Text := LoadSetting('MCCByRambozin', 'CosmicEa');
    end
    SpellToUse := TEdit.Create(MagicTrainingArena);
    SpellToUse.Parent := MagicTrainingArena;
    SpellToUse.Left := 24;
    SpellToUse.Top := 112;
    SpellToUse.Width := 185;
    SpellToUse.Height := 21;
    SpellToUse.TabOrder := 6;
    if (Run <= 1) then
    begin
      SpellToUse.Text := 'Which spell to use?';
    end else
    begin
      SpellToUse.Text := LoadSetting('MCCByRambozin', 'Spell');
    end
    Alchemy := TGroupBox.Create(frmDesign);
    Alchemy.Parent := frmDesign;
    Alchemy.Left := 360;
    Alchemy.Top := 8;
    Alchemy.Width := 320;
    Alchemy.Height := 297;
    Alchemy.TabOrder := 1;
    ALCHTitel := TLabel.Create(Alchemy);
    ALCHTitel.Parent := Alchemy;
    ALCHTitel.Left := 112;
    ALCHTitel.Top := 0;
    ALCHTitel.Width := 107;
    ALCHTitel.Height := 38;
    ALCHTitel.Caption := 'Alchemy';
    ALCHTitel.Font.Color := clWindowText;
    ALCHTitel.Font.Height := -27;
    ALCHTitel.Font.Name := 'Comic Sans MS';
    ALCHTitel.Font.Style := [];
    ALCHTitel.ParentFont := False;
    UseAlch := TCheckBox.Create(Alchemy);
    UseAlch.Parent := Alchemy;
    UseAlch.Left := 96;
    UseAlch.Top := 48;
    UseAlch.Width := 170;
    UseAlch.Height := 17;
    UseAlch.Caption := 'Calculate/Plan Alchemy Costs?';
    UseAlch.State := StrToBool(LoadSetting('MCCByRambozin', 'UseAlch2'));
    UseAlch.TabOrder := 0;
    NatsEa := TEdit.Create(Alchemy);
    NatsEa.Parent := Alchemy;
    NatsEa.Left := 40;
    NatsEa.Top := 80;
    NatsEa.Width := 249;
    NatsEa.Height := 21;
    NatsEa.TabOrder := 1;
    if (Run <= 1) then
    begin
      NatsEa.Text := 'Price of Nature Runes each';
    end else
    begin
      NatsEa.Text := LoadSetting('MCCByRambozin', 'GpNatsEa');
    end
    ItemEa := TEdit.Create(Alchemy);
    ItemEa.Parent := Alchemy;
    ItemEa.Left := 40;
    ItemEa.Top := 144;
    ItemEa.Width := 121;
    ItemEa.Height := 21;
    ItemEa.TabOrder := 2;
    if (Run <= 1) then
    begin
      ItemEa.Text := 'Price of alch-item each';
    end else
    begin
      ItemEa.Text := LoadSetting('MCCByRambozin', 'GpItemEa');
    end
    AlchEa := TEdit.Create(Alchemy);
    AlchEa.Parent := Alchemy;
    AlchEa.Left := 40;
    AlchEa.Top := 112;
    AlchEa.Width := 249;
    AlchEa.Height := 21;
    AlchEa.TabOrder := 3;
    if (Run <= 1) then
    begin
      AlchEa.Text := 'Number of coins you get for every alch';
    end else
    begin
      AlchEa.Text := LoadSetting('MCCByRambozin', 'GpAlchEa');
    end
    AlchName := TEdit.Create(Alchemy);
    AlchName.Parent := Alchemy;
    AlchName.Left := 40;
    AlchName.Top := 176;
    AlchName.Width := 249;
    AlchName.Height := 21;
    AlchName.TabOrder := 4;
    if (Run <= 1) then
    begin
      AlchName.Text := 'Name of item to alch';
    end else
    begin
      AlchName.Text := LoadSetting('MCCByRambozin', 'AlchNAme2');
    end
    AlchMode := TComboBox.Create(Alchemy);
    AlchMode.Parent := Alchemy;
    AlchMode.Left := 40;
    AlchMode.Top := 208;
    AlchMode.Width := 249;
    AlchMode.Height := 21;
    AlchMode.ItemHeight := 13;
    AlchMode.TabOrder := 5;
    if (Run <= 1) then
    begin
      AlchMode.Text := 'High or Low alchemy?';
    end else
    begin
      AlchMode.Text := LoadSetting('MCCByRambozin', 'AlchSpell');
    end
    AlchMode.Items.Add('Low Alchely');
    AlchMode.Items.Add('High Alchemy');
    AlchModeBox := TComboBox.Create(Alchemy);
    AlchModeBox.Parent := Alchemy;
    AlchModeBox.Left := 168;
    AlchModeBox.Top := 144;
    AlchModeBox.Width := 121;
    AlchModeBox.Height := 21;
    AlchModeBox.ItemHeight := 13;
    AlchModeBox.TabOrder := 6;
    if (Run <= 1) then
    begin
      AlchModeBox.Text := 'What mode to use?';
    end else
    begin
      AlchModeBox.Text := LoadSetting('MCCByRambozin', 'ModeAlch');
    end
    AlchModeBox.Items.Add('Calculating');
    AlchModeBox.Items.Add('Planning');
    AlchPlanning := TGroupBox.Create(Alchemy);
    AlchPlanning.Parent := Alchemy;
    AlchPlanning.Left := 1;
    AlchPlanning.Top := 248;
    AlchPlanning.Width := 319;
    AlchPlanning.Height := 48;
    AlchPlanning.Caption := 'Only fill in if using mode Planning';
    AlchPlanning.TabOrder := 7;
    AlchMoneyToSpend := TEdit.Create(AlchPlanning);
    AlchMoneyToSpend.Parent := AlchPlanning;
    AlchMoneyToSpend.Left := 40;
    AlchMoneyToSpend.Top := 16;
    AlchMoneyToSpend.Width := 249;
    AlchMoneyToSpend.Height := 21;
    AlchMoneyToSpend.TabOrder := 0;
    if (Run <= 1) then
    begin
      AlchMoneyToSpend.Text := 'How much money do you want to spend?';
    end else
    begin
      AlchMoneyToSpend.Text := LoadSetting('MCCByRambozin', 'TotalALCHGP2');
    end
    CurrentMagicExp := TEdit.Create(frmDesign);
    CurrentMagicExp.Parent := frmDesign;
    CurrentMagicExp.Left := 304;
    CurrentMagicExp.Top := 24;
    CurrentMagicExp.Width := 97;
    CurrentMagicExp.Height := 21;
    CurrentMagicExp.TabOrder := 2;
    if (Run <= 1) then
    begin
      CurrentMagicExp.Text := 'Current Magic Exp.';
    end else
    begin
      CurrentMagicExp.Text := LoadSetting('MCCByRambozin', 'CurrentXP');
    end
    MagicGoalLevel := TEdit.Create(frmDesign);
    MagicGoalLevel.Parent := frmDesign;
    MagicGoalLevel.Left := 304;
    MagicGoalLevel.Top := 56;
    MagicGoalLevel.Width := 97;
    MagicGoalLevel.Height := 21;
    MagicGoalLevel.TabOrder := 3;
    if (Run <= 1) then
    begin
      MagicGoalLevel.Text := 'Magic Goal Level.';
    end else
    begin
      MagicGoalLevel.Text := LoadSetting('MCCByRambozin', 'GoalLevel');
    end
    Button1 := TButton.Create(frmDesign);
    Button1.Parent := frmDesign;
    Button1.Left := 305;
    Button1.Top := 145;
    Button1.Width := 90;
    Button1.Height := 50;
    Button1.Caption := 'Start';
    Button1.Font.Color := clWindowText;
    Button1.Font.Height := -27;
    Button1.Font.Name := 'Comic Sans MS';
    Button1.Font.Style := [];
    Button1.ParentFont := False;
    Button1.TabOrder := 8;
    Button1.OnClick := @ClickedAtStart;
    Button2 := TButton.Create(frmDesign);
    Button2.Parent := frmDesign;
    Button2.Left := 305;
    Button2.Top := 195;
    Button2.Width := 90;
    Button2.Height := 50;
    Button2.Caption := 'Cancel';
    Button2.Font.Color := clWindowText;
    Button2.Font.Height := -27;
    Button2.Font.Name := 'Comic Sans MS';
    Button2.Font.Style := [];
    Button2.ParentFont := False;
    Button2.TabOrder := 8;
    Button2.OnClick := @ClickedAtCancel;
    end;

    procedure SafeInitForm;
    var
      v : TVariantArray;
    begin
      SetArrayLength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end; // <<-- Here is the error.

    procedure SafeShowFormModal;
    var
      v : TVariantArray;
    begin
      SetArrayLength(V, 0);
      ThreadSafeCall('ShowFormModal', v);
    end;

    procedure SetupForm;
    begin
      SafeInitForm;
      SafeShowFormModal;
    end;

    begin
      SetupSRL;
      Run := 2;
      Run := Run + 1;
      ClearDebug;
      SetupForm;
      SetForm;
      ScriptActive;
    end.
    Srl simply rocks.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Not only an out of range error, but when you first load it this will give problems :

    SCAR Code:
    UseAlch.State := StrToBool(LoadSetting('MCCByRambozin', 'UseAlch2'));

    That setting doesnt exist then and it makes it do StrToBool(''); which also errors. Try StrToBoolDef(); ?

    (Btw, it didnt error now for me, but also use StrToBoolInt where needed...)

    The Out of Range error has something to do with you doing TerminateScript from the form. Apparently you can't do that (didn't know that either )
    Administrator's Warning:


  3. #3
    Join Date
    Jan 2007
    Posts
    513
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yea, I now found out that I only get an error when pressing Cancel, not Start ..

    Here is the script: http://www.villavu.com/forum/showthread.php?t=24759
    Srl simply rocks.

  4. #4
    Join Date
    Jan 2007
    Posts
    513
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I finally found out what I did wrong: I needed to free the form before Terminating the script
    Srl simply rocks.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Scripting Help Forum... FORM
    By Nava2 in forum SRL Site Discussion
    Replies: 3
    Last Post: 08-05-2008, 07:20 PM
  2. Scar Form Error: Out of Global Vars range!
    By Nava2 in forum OSR Help
    Replies: 6
    Last Post: 08-04-2008, 03:47 PM
  3. Replies: 2
    Last Post: 03-29-2008, 11:35 AM
  4. Out Of Range error in my form
    By itSchRis917 in forum OSR Help
    Replies: 16
    Last Post: 09-16-2007, 09:39 AM

Posting Permissions

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