SRL Archive - Reflection Development

R_EquipID


**BANNED The Man

2011-02-13 08:52:10

function R_EquipID(ID:integer): boolean;
begin
Result := IsEquippedID(ID);
for i := 1 to 28 do
if(GetItemIDAt(i) = ID)then
begin
TB := InvBox(i);
MouseBoxEx(TB.X1, TB.Y1, TB.X2, TB.Y2,14, 2);
if not R_ChooseOption('Wield') then
R_ChooseOption('Wear');
end;
Result := IsEquippedID(ID);
end;

Will equip the selected ID.
I will make an R_UnEquip later :)

-Boom

Sir R. M8gic1an

2011-02-13 08:58:11

humm… This could be better if it used something such as

IDinInv

and then equipID would call that one.

basically breaking it down further ;) And if you're looking into inventory management then I'd suggest something among these lines:


type
TInvSpot = record;
ID: integer;
Name: string;
Quantity: integer;
Equip: boolean;
//ID 0 = empty
end;

TInv: Array[0..27] of TInvSpot;

then you'd have all your inventory on memory, rather than searching for it each time ;)

~RM

mormonman

2011-02-13 14:15:15

You need to add a timeout failsafe.

Train

2011-02-13 16:14:07

You also need to break out of the loop if you wear/wield it.