Or this way:
sync on
items = 6
dim string$(items)
`store data
restore inventory
For I = 1 to items
read item$
string$(I) = item$
Next I
`set variables
posx = 20
posy = 50
sizex = 150
sizey = 200
`the scroll var
sy = -10
`the loop
do
`clear screen
cls
`main window
ink rgb(255,255,255),0
box posx,posy,posx+sizex,posy+sizey
ink rgb(0,0,255),0
box posx+1,posy+1,posx+sizex-1,posy+sizey-1
`display all data
for data = 1 to items
texty = sy + data * 18
if texty>5 and texty<sizey-12
ink rgb(255,255,255),0
if textbutton(posx + 5, posy + texty, string$(data)) > 0
goto ending
endif
endif
next data
`scroll buttons
if textbutton(posx + sizex - 10, posy + 10, "^") > 0 or upkey() = 1
sy = sy + 2
endif
if textbutton(posx + sizex - 10, posy + sizey - 10, "v") > 0 or downkey() = 1
sy = sy - 2
endif
sync
loop
ending:
ink rgb(255,255,255),0
text 0,0,"you pressed " + string$(data)
suspend for key
end
`************
`FUNCTIONS
`************
function textbutton(x,y,text$)
pressed = 0
tx = text width(text$)
ty = text height(text$)/2
if mousex() > x and mousex() < x + tx
if mousey() > y - ty and mousey() < y + ty
pressed = 1
endif
endif
if pressed = 1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
text x, y - ty, text$
if mouseclick() = 0 then pressed = 0
endfunction pressed
`************
`DATA
`************
inventory:
Data "Potion", "H-Potion", "S-Potion", "Pheonix Tear", "Elixer"
Also a quick way to test what item is clicked on...
or this is just an idea I got. (Nothing special though)
sync on
items = 6
dim string$(items)
`store data
restore inventory
For I = 1 to items
read item$
string$(I) = item$
Next I
`set variables
posx = 20
posy = 50
sizex = 150
sizey = 200
`the scroll var
sy = -10
`the loop
do
`clear screen
cls
`main window
ink rgb(255,255,255),0
box posx,posy,posx+sizex,posy+sizey
ink rgb(0,0,255),0
box posx+1,posy+1,posx+sizex-1,posy+sizey-1
`display all data
for data = 1 to items
texty = sy + data * 18
if texty>5 and texty<sizey-12
ink rgb(255,255,255),0
if textbutton(posx + 5, posy + texty, string$(data)) > 0
goto ending
endif
endif
next data
`scroll buttons
if textbutton(posx + sizex - 10, posy + 10, "^") > 0 or upkey() = 1
sy = sy + 2
endif
if textbutton(posx + sizex - 10, posy + sizey - 10, "v") > 0 or downkey() = 1
sy = sy - 2
endif
sync
loop
ending:
ink rgb(255,255,255),0
text 0,0,"you pressed " + string$(data)
suspend for key
end
`************
`FUNCTIONS
`************
function textbutton(x,y,text$)
if redi = 0 or redv <= 0 then redi = 1
if redv >= 255 then redi = -1
redv = redv + redi
pressed = 0
tx = text width(text$)
ty = text height(text$)/2
if mousex() > x and mousex() < x + tx
if mousey() > y - ty and mousey() < y + ty
pressed = 1
endif
endif
if pressed = 1 then ink rgb(redv,0,0),0 else ink rgb(255,255,255),0
text x, y - ty, text$
if mouseclick() = 0 then pressed = 0
endfunction pressed
`************
`DATA
`************
inventory:
Data "Potion", "H-Potion", "S-Potion", "Pheonix Tear", "Elixer"
Immunity and Annihalation makes Immunihalation...