I’ll try to select the important parts:
function on_input(self, action_id, action)
if action.released and scroll_by_bar == true then scroll_by_bar = false end
if action_id == hash("touch") and button_picked ~= true then
if gui.pick_node(gui.get_node("display"), action.x, action.y) then
if action.pressed then
scroll = true
keep_moving = false
start_w_pos = gui.get_position(gui.get_node("wordbuttons"..u))
if not scroll_by_bar then start_h2_pos = gui.get_position(barhorizontal2) ; start_mouse_pos1 = action ; scroll_by_finger = true end
tim = socket.gettime()*1000
elseif action.released then
if os.difftime(socket.gettime()*1000, tim2) > 100 then sp = 0 else
end_mouse_pos1 = action
sp = (math.abs(start_mouse_pos1.y-end_mouse_pos1.y)*(1000/60)/(os.difftime(socket.gettime()*1000, tim)))*60
if sp < 500 then sp = 500 end
sp = math.pow((sp-500),1.1)
end
keep_moving = true
else
if not stay or stay ~= action.y then stay = action.y tim2 = socket.gettime()*1000 end
end
end
end
end
function update(self, dt)
if scroll == true and dont_scroll ~= true then
local scrolllist_length = 1500050--(10000*gui.get_size(gui.get_node("wordbutton1")).y*0.5+(10000-1)*(140-gui.get_size(gui.get_node("wordbutton1")).y*0.5))+2*(333-240-gui.get_size(gui.get_node("wordbutton1")).y/4)
if not keep_moving then
if scroll_by_finger then direction = (self.mouse.y-start_mouse_pos1.y)/math.abs(self.mouse.y-start_mouse_pos1.y) end
if scroll_by_bar then direction = 1 if q and self.mouse.y > q then direction = -1 end q = self.mouse.y end
if scroll_by_finger then cont = true ; gui.set_position(barhorizontal2, vmath.vector3(gui.get_position(barhorizontal2).x, start_h2_pos.y-((self.mouse.y-start_mouse_pos1.y)*(480-25))/scrolllist_length, 0)) end
if scroll_by_bar then
if math.abs(self.mouse.y-333) < 227.5 then gui.animate(barhorizontal2, "position", vmath.vector3(gui.get_position(barhorizontal2).x, self.mouse.y-333+12.5,0), gui.EASING_LINEAR, 0.035)
elseif self.mouse.y-333 >= 227.5 then gui.animate(barhorizontal2, "position", vmath.vector3(gui.get_position(barhorizontal2).x, 240+0.2,0), gui.EASING_LINEAR, 0.035)
elseif self.mouse.y-333 <= -227.5 then gui.animate(barhorizontal2, "position", vmath.vector3(gui.get_position(barhorizontal2).x, -215-0.2, 0), gui.EASING_LINEAR, 0.035) end
end
end
whereIam_bar = -(gui.get_position(barhorizontal2).y-240)*(1/455)
if whereIam_bar <= 0 then
gui.set_position(barhorizontal2, vmath.vector3(175, 240, 0))
gui.set_position(gui.get_node("wordbuttons1"), vmath.vector3(0,318,0))
gui.set_position(gui.get_node("wordbuttons-1"), vmath.vector3(0,-1082,0))
set_buttons_end(-1)
whereIam_bar = 0
end
if whereIam_bar >= 1 then
gui.set_position(barhorizontal2, vmath.vector3(175, -215, 0))
gui.set_position(gui.get_node("wordbuttons1"), vmath.vector3(0,2500,0))
gui.set_position(gui.get_node("wordbuttons-1"), vmath.vector3(0,1100,0))
set_buttons_end(1)
whereIam_bar = 1
end
if whereIam_bar > 0 and whereIam_bar < 1 and whereIam_bar + direction > -1 and whereIam_bar + direction < 2 then
if not keep_moving then
if scroll_by_finger then
gui.set_position(gui.get_node("wordbuttons"..u), vmath.vector3(0, start_w_pos.y+(self.mouse.y-start_mouse_pos1.y), 0))
gui.set_position(gui.get_node("wordbuttons"..-u), vmath.vector3(0, start_w_pos.y+(self.mouse.y-start_mouse_pos1.y)-1400, 0))
elseif scroll_by_bar then
gui.set_position(gui.get_node("wordbuttons"..u), vmath.vector3(0, ((scrolllist_length-1400)*whereIam_bar)%724+346,0))
gui.set_position(gui.get_node("wordbuttons"..-u), vmath.vector3(0, ((scrolllist_length-1400)*whereIam_bar)%724+346-1400,0))
if u == 1 then c = 0 else c = 1 end
local num = (10000*whereIam_bar)-(10000*whereIam_bar)%20
for y = 1,2 do
for i = 1,10 do
if english[num+i] then
gui.set_text(gui.get_node("word"..(i+c*10)..1), english[num+i])
gui.set_text(gui.get_node("word"..(i+c*10)..2), pronunciation[num+i])
gui.set_text(gui.get_node("levelnumberbutton"..(i+c*10)), num+i)
dots("dot", (i+c*10), num+i)
end
end
if u == 1 then c = 1 num = num+10 else c = 0 num = num - 10 end
end
end
end
for i = -1,1,2 do
if gui.get_position(gui.get_node("wordbuttons"..i)).y < -1112 then
gui.set_position(gui.get_node("wordbuttons"..i), vmath.vector3(0, gui.get_position(gui.get_node("wordbuttons"..-i)).y+1400, 0))
start_w_pos.y = start_w_pos.y + 1400
if i == 1 then c = 0 else c = 1 end
set_buttons(-1, c)
elseif gui.get_position(gui.get_node("wordbuttons"..i)).y > 2480 and whereIam_bar < 0.99 then
gui.set_position(gui.get_node("wordbuttons"..i), vmath.vector3(0, gui.get_position(gui.get_node("wordbuttons"..-i)).y-1400, 0))
start_w_pos.y = start_w_pos.y - 1400
if i == 1 then c = 0 else c = 1 end
set_buttons(1, c)
end
end
if keep_moving and scroll_by_finger then --momentum
gui.set_position(gui.get_node("wordbuttons"..u), gui.get_position(gui.get_node("wordbuttons"..u))+vmath.vector3(0,sp*dt*direction,0))
gui.set_position(gui.get_node("wordbuttons"..-u), vmath.vector3(0,gui.get_position(gui.get_node("wordbuttons"..u)).y-1400,0))
gui.set_position(barhorizontal2, vmath.vector3(gui.get_position(barhorizontal2).x, gui.get_position(barhorizontal2).y-((sp*dt*direction)*(480-gui.get_size(barhorizontal2).y/8))/scrolllist_length, 0))
sp = sp/1.02 if math.abs(sp) < 20 then sp = 0 scroll_by_finger = false keep_moving = false scroll = false end
end
end
end
end
function set_buttons(direction, c)
if scroll_by_finger then u = -u end
for i = 1,10 do
local num = gui.get_text(gui.get_node("levelnumberbutton"..(i+10*c)))+20*direction
if english[num] then
gui.set_text(gui.get_node("word"..(i+10*c)..1), english[num])
end
end
end
function set_buttons_end(direction)
for i = 1,20 do
if direction == -1 then num = i else num = 9980+i end
gui.set_text(gui.get_node("word"..i..1), english[num])
end
end
If necessary, I can add comments to it.