Thread

two events handlers (Sdk)

two events handlers // Sdk

1  |  

jeanphi

Oct 4, 1998, 11:40am
I wanted to improve the sample1 program that is saying hello to all the new
avatars entering the scene, and I added a procedure that says world settings
changed each time you modify the world settings.

Unfortunately, the program crashes, can some tell me what's wrong with my
code ?

It is written in Delphi, and the code add is between the 2 //*****\\

I also added the code of the procedure in the other unit.

-----------------------

procedure TForm1.Button1Click(Sender: TObject);
var
rc: integer;
c: PChar;
begin
if (Edit1.Text = '') or (Edit2.Text = '') or (Edit3.Text = '') then
begin
Memo1.Lines.Add('Enter Citizen Number, Privilege Password, and
World');
exit;
end;

rc := aw_init(AW_BUILD);

if (rc <> 0) then
begin
Memo1.Lines.Add('Unable to initialize API, reason ' +
IntToStr(rc));
exit;
end else Memo1.Lines.Add('Initialzed');

rc := aw_event_set(AW_EVENT_AVATAR_ADD, at AvatarAdd);

if (rc <> 0) then
begin
Memo1.Lines.Add('Unable to install AvatarAdd handler, reason '
+ IntToStr(rc));
exit;
end else Memo1.Lines.Add('Handler approved');

//*****\\

rc := aw_event_set(AW_EVENT_WORLD_ATTRIBUTES,
at WorldSettingsChangeAnnounce);

if (rc <> 0) then
Begin
Memo1.Lines.Add('Unable to install WorldSettingsChangeAnnounce
handler, reason ' + IntToStr(rc));
exit;
end else Memo1.Lines.Add('Handler 2 approved');

//*****\\



c := nil;
rc := aw_create(c, 0, nil);

if (rc <> 0 ) then
Begin
Memo1.Lines.Add('Unableto create instance, reason '+
IntToStr(rc));
Exit;
end else Memo1.Lines.Add('Instance created');

rc := aw_int_set(AW_LOGIN_OWNER, StrToInt(Edit1.Text));

if (rc <> 0) then
Begin
Memo1.Lines.Add('Unable to Login Owner, reason ' +
IntToStr(rc));
exit;
end else Memo1.Lines.Add('Logged owner in');

rc := aw_string_set(AW_LOGIN_PRIVILEGE_PASSWORD, PChar(Edit2.Text));

if (rc <> 0) then
Begin
Memo1.Lines.Add('Unable to Login Password, reason ' +
IntToStr(rc));
exit;
end else Memo1.Lines.Add('Logged Pawword in');

rc := aw_string_set(AW_LOGIN_APPLICATION, PChar('Sample14'));

if (rc <> 0) then
Begin
Memo1.Lines.Add('Unable to Login Application, reason ' +
IntToStr(rc));
exit;
end else Memo1.Lines.Add('Logged App in');

rc := aw_string_set(AW_LOGIN_NAME, PChar('GreeterBot14'));

if (rc <> 0) then
Begin
Memo1.Lines.Add('Unable to Login Name, reason ' +
IntToStr(rc));
exit;
end else Memo1.Lines.Add('Logged name in');

rc := aw_login;

if (rc <> 0) then
Begin
Memo1.Lines.Add('Unable to Login, reason ' + IntToStr(rc));
exit;
end else Memo1.Lines.Add('Logged in');

rc := aw_enter(PChar(Edit3.Text), 0);

if (rc <> 0) then
Begin
Memo1.Lines.Add('Unable to enter Beta world, reason ' +
IntToStr(rc));
exit;
end else Memo1.Lines.Add(Edit3.Text + ' world entered');

rc := aw_int_set(AW_MY_X, 1000);

if (rc <> 0) then
Begin
Memo1.Lines.Add('Unable to set my x, reason '+ IntToStr(rc));
exit;
end else Memo1.Lines.Add('Reset My X');

rc := aw_int_set(AW_MY_Y, 1000);

if (rc <> 0) then
Begin
Memo1.Lines.Add('Unable to set my y, reason '+ IntToStr(rc));
exit;
end else Memo1.Lines.Add('Reset My Y');

rc := aw_int_set(AW_MY_Z, 1000);

if (rc <> 0) then
Begin
Memo1.Lines.Add('Unable to set my z, reason '+ IntToStr(rc));
exit;
end else Memo1.Lines.Add('Reset My Z');

rc := aw_int_set(AW_MY_YAW, 2250);

if (rc <> 0) then
Begin
Memo1.Lines.Add('Unable to set my y, reason '+ IntToStr(rc));
exit;
end else Memo1.Lines.Add('Reset My Yaw');

rc := aw_state_change;

if (rc <> 0) then
Begin
Memo1.Lines.Add('Could not change my state');
exit;
end else Memo1.Lines.Add('Updated my Position');

rc := aw_wait(60000);

if (rc <> 0) then
Begin
Memo1.Lines.Add('Not able to wait');
exit;
end else Memo1.Lines.Add('Finished with waiting');
end;


-----------------------

the code between the 2 //*****\\ is the code I added there is also my
procedure written in another unit like avataradd.


thx

--------

procedure WorldSettingsChangeAnnounce;
var
Messaging: String;
Begin
Messaging := 'World settings changed';
aw_say(PChar(Messaging));
Form1.Memo1.Lines.Add('Announce posted');

End

-----


jeanphi;









end;

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn