Go to most recent revision |
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
151 |
MrJackdaw-1942 |
function Stack() |
2 |
|
MrJackdaw-1942 |
|
3 |
|
MrJackdaw-1942 |
Timer=Turbine.UI.Control() |
4 |
|
MrJackdaw-1942 |
|
5 |
|
MrJackdaw-1942 |
function Timer:Start() |
6 |
|
MrJackdaw-1942 |
FirstStart= Turbine.Engine.GetGameTime() |
7 |
|
MrJackdaw-1942 |
|
8 |
|
MrJackdaw-1942 |
Slot=1 |
9 |
|
MrJackdaw-1942 |
Start= Turbine.Engine.GetGameTime() |
10 |
|
MrJackdaw-1942 |
Timer:SetWantsUpdates(true) |
11 |
|
MrJackdaw-1942 |
end |
12 |
|
MrJackdaw-1942 |
|
13 |
|
MrJackdaw-1942 |
function Timer:Update() |
14 |
|
MrJackdaw-1942 |
local Time = Turbine.Engine.GetGameTime() |
15 |
|
MrJackdaw-1942 |
local elapsed = Time - Start |
16 |
|
MrJackdaw-1942 |
|
17 |
|
MrJackdaw-1942 |
if elapsed>0.2 then |
18 |
|
MrJackdaw-1942 |
if Slot>size then |
19 |
|
MrJackdaw-1942 |
Timer:SetWantsUpdates(false) |
20 |
|
MrJackdaw-1942 |
Timer=nil |
21 |
|
MrJackdaw-1942 |
Turbine.Shell.WriteLine("<rgb=#888888>Stack finished after "..Time-FirstStart.." seconds.") |
22 |
|
MrJackdaw-1942 |
return |
23 |
|
MrJackdaw-1942 |
end |
24 |
|
MrJackdaw-1942 |
|
25 |
|
MrJackdaw-1942 |
--Get the name of the current item |
26 |
|
MrJackdaw-1942 |
aitem=backpack:GetItem(Slot) |
27 |
|
MrJackdaw-1942 |
|
28 |
|
MrJackdaw-1942 |
--If there is no item to search for then see what is in the current slot. |
29 |
|
MrJackdaw-1942 |
if SearchItem==nil then |
30 |
|
MrJackdaw-1942 |
if aitem~=nil then |
31 |
|
MrJackdaw-1942 |
Current= aitem:GetName() |
32 |
|
MrJackdaw-1942 |
StackSize= aitem:GetMaxStackSize() |
33 |
|
MrJackdaw-1942 |
Quantity= aitem:GetQuantity() |
34 |
|
MrJackdaw-1942 |
if StackSize>Quantity then |
35 |
|
MrJackdaw-1942 |
SearchItem=Current |
36 |
|
MrJackdaw-1942 |
else |
37 |
|
MrJackdaw-1942 |
Slot=Slot+1 |
38 |
|
MrJackdaw-1942 |
return |
39 |
|
MrJackdaw-1942 |
end |
40 |
|
MrJackdaw-1942 |
else |
41 |
|
MrJackdaw-1942 |
Slot=Slot+1 |
42 |
|
MrJackdaw-1942 |
return |
43 |
|
MrJackdaw-1942 |
end |
44 |
|
MrJackdaw-1942 |
end |
45 |
|
MrJackdaw-1942 |
|
46 |
|
MrJackdaw-1942 |
if SearchItem~=nil then |
47 |
|
MrJackdaw-1942 |
--If the stack is full - get outta here! |
48 |
|
MrJackdaw-1942 |
if aitem:GetQuantity()==StackSize then |
49 |
|
MrJackdaw-1942 |
SearchItem=nil |
50 |
|
MrJackdaw-1942 |
Slot=Slot+1 |
51 |
|
MrJackdaw-1942 |
Start= Turbine.Engine.GetGameTime() |
52 |
|
MrJackdaw-1942 |
return |
53 |
|
MrJackdaw-1942 |
end |
54 |
|
MrJackdaw-1942 |
|
55 |
|
MrJackdaw-1942 |
--Search for the item in the rest of the pack. |
56 |
|
MrJackdaw-1942 |
for i=Slot+1,size do |
57 |
|
MrJackdaw-1942 |
item=backpack:GetItem(i) |
58 |
|
MrJackdaw-1942 |
if item~=nil then Name=item:GetName() |
59 |
|
MrJackdaw-1942 |
if Name==SearchItem then |
60 |
154 |
MrJackdaw-1942 |
if item:GetQuantity()~=StackSize then |
61 |
151 |
MrJackdaw-1942 |
backpack:PerformItemDrop(item,Slot, false) |
62 |
|
MrJackdaw-1942 |
Start= Turbine.Engine.GetGameTime() |
63 |
|
MrJackdaw-1942 |
return |
64 |
|
MrJackdaw-1942 |
end |
65 |
|
MrJackdaw-1942 |
end |
66 |
|
MrJackdaw-1942 |
end |
67 |
|
MrJackdaw-1942 |
end |
68 |
|
MrJackdaw-1942 |
SearchItem=nil |
69 |
|
MrJackdaw-1942 |
Slot=Slot+1 |
70 |
|
MrJackdaw-1942 |
Start= Turbine.Engine.GetGameTime() |
71 |
|
MrJackdaw-1942 |
return |
72 |
|
MrJackdaw-1942 |
end |
73 |
|
MrJackdaw-1942 |
end |
74 |
|
MrJackdaw-1942 |
end |
75 |
|
MrJackdaw-1942 |
Timer:Start() |
76 |
|
MrJackdaw-1942 |
end |
All times are GMT -5. The time now is 05:49 PM.