Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local speed = 3;
- local inputs = {};
- local lastjoy = nil;
- local idx = 0;
- local L = {left = 5, right = 10, up = 15, down = 20, A = 25, B = 30, C = 35, start = 40, X = 45, Y = 50, Z = 55};
- local C = {}
- local R = {};
- local last = {};
- for k, v in pairs(L) do
- R[k] = v+3;
- C[k] = "#0000FF80";
- end
- gens.registerbefore(function ()
- local joy = joypad.get();
- if (lastjoy == nil) then
- for k,v in pairs(joy) do
- if (v and L[k] ~= nil) then
- local t = {};
- t.x1 = L[k];
- t.x2 = R[k];
- t.c = C[k];
- t.y1 = 0;
- t.y2 = 0;
- t.i = idx;
- inputs[idx]=t;
- idx = idx + 1;
- last[k]=t;
- end
- end
- lastjoy = joy;
- else
- local todel = {};
- for k,v in pairs(inputs) do
- v.y1 = v.y1 + speed;
- v.y2 = v.y2 + speed;
- if (v.y1 > 240) then
- todel[v.i] = true;
- end
- end
- for k,v in pairs(todel) do
- inputs[k] = nil;
- end
- for k,v in pairs(joy) do
- if (L[k] ~= nil) then
- if (v) then
- if (lastjoy[k]) then
- local t = last[k];
- t.y1 = 0;
- else
- local t = {};
- t.x1 = L[k];
- t.x2 = R[k];
- t.c = C[k];
- t.y1 = 0;
- t.y2 = 0;
- t.i = idx;
- inputs[idx]=t;
- idx = idx + 1;
- last[k]=t;
- end
- end
- -- if (lastjoy[k]) then
- -- last[k] = nil;
- -- end
- --end
- end
- end
- lastjoy = joy;
- end
- end)
- gui.register(function ()
- for k, v in pairs(inputs) do
- gui.box(v.x1,v.y1,v.x2,v.y2,v.c,v.c);
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement