English How to Make a Infinite Menu?

3 replies
Goto Page
To the start Previous 1 Next To the start
28.05.12 09:18:22 pm
Up
Jhony
User
Offline Off
Please help me
example :

Menu > Next > Next > Next ... infinite
Menu < previous < previous < previous ... infinite
28.05.12 09:27:24 pm
Up
Communism
Reviewer
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
tbl={
[1] = "lol 1";
[2] = "lol 2";
[3] = "lol 3";
[4] = "lol 4";

[5] = "lol 1";
[6] = "lol 2";
[7] = "lol 3";
[8] = "lol 4";

[9] = "lol 1";
[10] = "lol 2";
[11] = "lol 3";
[12] = "lol 4";

[13] = "lol 1";
[14] = "lol 2";
[15] = "lol 3";
[16] = "lol 4";
}

function menue(id, page)
        local page = page or 1
        local pages = math.ceil(#tbl / 6)
        if page < 1 then page = pages end
        if page > pages then page = 1 end
        local m = 'Select a hat P'.. page
        for i = 6 * page - 5, 6 * page do
                if tbl[i] then m = m ..', '.. tbl[i] else m = m ..',' end
        end
        if page == pages then m = m ..',,<<- First page' else m = m ..',,Next page -->' end
        if page == 1 then m = m ..',Last page ->>' else m = m ..',<-- Previvius page' end
        menu(id, m)
end

addhook('menu', 'd')
function d(id, title, button)
        if title:sub(1, 14) == 'Select a hat P' then
                local page = tonumber(title:sub(15))
                if button == 8 then menue(id, page + 1) end
                if button == 9 then menue(id, page - 1) end
         end
end
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
29.05.12 06:06:46 am
Up
Fasttt
User
Offline Off
see my Advanced Buying Menu script
29.05.12 09:48:20 am
Up
EngiN33R
Moderator
Offline Off
Or file cs2d [EngiN33R] UniMenu (31). The general scheme is what user Communism has written though.
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
To the start Previous 1 Next To the start