Wanted to make something move gems to the bottom of the inventory for my Powerminer, this is what I came up with.
Also uses recursion, which took a while to wrap my head around.
Simba Code:
program InventorySorting;
{$DEFINE SMART}
{$i Aerolib/Aerolib.simba}
{$i Reflection/Reflection.simba}
{
Inventory Sorting
Author: Dissimulo (https://villavu.com/forum/member.php?u=160877)
Last Update: 23/05/2016
Version: 2.0
Category: Utility
Description: Moves Items to the bottom of the backpack
Includes: Reflection and AeroLib
Features:
- Aerolib (https://villavu.com/forum/showthread.php?t=108953)
- Reflection (https://villavu.com/forum/showthread.php?t=111662)
- Simple SMART paint
Versions:
- 2.0 (22/05/2016)
Reworked functions into Color and Reflection
Rewrote functions (thanks to Turpinator and Le Jingle
Using proper wrappers for Reflection (thanks Harrier)
- 1.0 (22/05/2016)
Cleaned up for public release
Credits:
- Flight (Aerolib)
- Kyle (Lape Reflection)
}
var
MyGuy: TReflectLocalPlayer;
function InventorySorterColor: Boolean;
var
i, j: Integer;
begin
for i := 28 downto 1 do
if (not itemInSlot(i)) then
begin
for j := 1 to i do
if (itemInSlot(j)) then
begin
dragMouseBox(invBox(j), invBox(i));
wait(RandomRange(400, 550));
Break;
end;
end;
Result := not isInvFull;
end;
function InventorySorterReflect: Boolean;
var
i, j: Integer;
begin
if Reflect.Gametab.Current <> 55 then
Reflect.Gametab.Open(55);
for i := 28 downto 1 do
if (not Reflect.Inv.ItemInSlot(i)) then
begin
for j := 1 to i do
if (Reflect.Inv.ItemInSlot(j)) then
begin
dragMouseBox(Reflect.Inv.InvBox(j), Reflect.Inv.InvBox(i));
wait(RandomRange(400, 550));
Break;
end;
end;
Result := not Reflect.Inv.IsFull;
end;
begin
initAL();
Reflect.Setup;
MyGuy.Username := 'USERNAME';
MyGuy.Password := 'PASSWORD';
MyGuy.Active := True;
MyGuy.Login;
wait(RandomRange(1000, 1550));
if not InventorySorterReflect then
Writeln('Inventory full');
end.