Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Jul 12, 2007 10:45 am    Post subject: Problem Reply with quote

Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6:
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
 Current := 'Current Location:  ';
 Location := 1;
 //LocArray Declaration
 LocArray[0] := 'Merdoth Town';
  LocArray[1] := 'Dark Swamp';
   LocArray[2] := 'Ergoth Mountains';
    LocArray[3] := 'Gremlor Mines';
     LocArray[4] := 'Haplor Docks';

 //MonArray Declaration
 MonArray[0] := 'Bandit';
  MonArray[1] := 'Small Poison Frog';
   MonArray[2] := 'Huge Poison Frog';
    MonArray[3] := '';


if(Location = 1) then
    begin
 ListBox1.Items.Add('Dark Swamp');
  ListBox1.Items.Add('Ergoth Mountains');
   ListBox1.Items.Add('Gremlor Mines');
    ListBox1.Items.Add('Haplor Docks');
    end;
end;

procedure TForm1.ListBox1Click(Sender: TObject);
begin


if(Location = 1) then
begin
  if(ListBox1.Items.Strings[ListBox1.ItemIndex] = LocArray[1]) then
  begin
  Label11.Caption := Current + LocArray[1];
  Location := 2;
  end;

  if(ListBox1.Items.Strings[ListBox1.ItemIndex] = LocArray[2]) then
  Label11.Caption := Current + LocArray[2];
  Location := 3;


  if(ListBox1.Items.Strings[ListBox1.ItemIndex] = LocArray[3]) then
  Label11.Caption := Current + LocArray[3];
  Location := 4;


  if(ListBox1.Items.Strings[ListBox1.ItemIndex] = LocArray[4]) then
  Label11.Caption := Current + LocArray[4];
  Location := 5;
end;


end;



procedure TForm1.Button1Click(Sender: TObject);
begin

  Memo2.Lines.Add(IntToStr(Location));
  if(Location = 1) then
  begin
  Memo2.Lines.Clear;
  Memo2.Lines.Add('You are in town silly, you cant fight here.');
  end;

  if(Location = 2) then
  begin

  Memo2.Lines.Clear;
  Memo2.Lines.Add('Fight Bandit'); //This is just here to test out the if
  end;



end;

end.



when i run this code and click on fight monster after clicking on Dark Swamp in the Listbox1 it wont run the if.

it sets the Location to 5 if i click anything in ListBox1 even though it should only set to 5 for Haplor Docks.

Am i making any sense?

i want Location to set to the right value

_________________
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Thu Jul 12, 2007 11:21 am    Post subject: Reply with quote

not sure about location but there's a way you could shorten your code:

Code:

procedure TForm1.FormCreate(Sender: TObject);
const
  LocArray : array[0..4] of string = ('Merdoth Town', 'Dark Swamp',
    'Ergoth Mountains', 'Gremlar Mines', 'Haplor Docks');
begin
...
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Jul 12, 2007 11:29 am    Post subject: Reply with quote

ok thanks i shortened both arrays but did it out of a procedure in the form var area

anyone help with Location?

_________________
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25815
Location: The netherlands

PostPosted: Thu Jul 12, 2007 12:08 pm    Post subject: Reply with quote

in the ListBox1Click put the code after if's between a begin and end
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites