Hi,
As some of you know I've been trying to make a good item menu. Well I have this code that IanM and Blazer helped me make. It worked good and I added too it a lot. Here is my code:
waitup=20
pot$="test"
rem Start arrays
DIM Item$(15)
DIM Item#(15)
DIM Item_Description$(15)
` Everything empty to start with
ResetItems()
dim potion_d$(9)
potion_d$(1)="Heals 30 HP"
start:
rem background for menu
Ink 400000,0
BOX 0,0,575,425
rem make menu raw
Ink 5000000,0
`left line
Line 0,0,0,425
Line 1,0,1,425
Line 2,0,2,425
`Middle left Line
Line 120,0,120,425
Line 121,0,121,425
Line 122,0,122,425
`right line
Line 575,0,575,425
Line 574,0,574,425
Line 573,0,573,425
`middle line
Line 0,35,575,35
Line 0,36,575,36
Line 0,37,575,37
`top line
Line 0,0,575,0
Line 0,1,575,1
Line 0,2,575,2
`bottom line
Line 0,425,575,425
Line 0,426,575,426
Line 0,427,575,427
sync on : sync rate 50
do
` Text on Menu
Ink 999999999999999999999999999999,0
Perform checklist for fonts
Set text size 20
Set text font "Abaddon"
Text 35,60,"Healing"
Text 30,100,"Weapons"
text 40,140,"Armor"
text 20,180,"Accessories"
text 35,220,"Damage"
text 45,260,"Keys"
text 45,300,"Gift"
text 25,340,"Containers"
text 40,380,"Other"
Text 45,10,"Item"
text 300,10,"Amount"
text 150,10,"Name"
text 470,10,"Effect"
dec waitup,1
sync
set text size 10
set text font "system"
rem print the Items
for i=1 to 15
text 140,20+i*25,Item$(i-1)
next i
rem print the Items
for i=1 to 15
text 440,20+i*25,Item_Description$(i-1)
next i
rem Print the Numbers
for i=1 to 15
text 320,20+i*25,STR$(Item#(i-1))
next i
if spacekey()=1
UpdateItemCount("Potion", 1, "Recover 30HP")
cls
endif
if mouseclick()=2 and waitup<0
waitup=20
gosub test
endif
if returnkey()=1
UpdateItemCount("Elixer", 1, "Recover Everything")
cls
endif
if shiftkey()=1
UpdateItemCount("Elixer", -1, "Recover Everything")
cls
endif
if upkey()=1
UpdateItemCount("Super Potion", 1, "Recover 100HP")
cls
endif
if downkey()=1
UpdateItemCount("Super Potion", -1, "Recover 100HP")
cls
endif
if rightkey()=1
UpdateItemCount("Revive", 1, "Revive the Dead")
cls
endif
if leftkey()=1
UpdateItemCount("Revive", -1, "Revive the Dead")
cls
endif
sync
rem end loop
loop
function ResetItems()
for Pos = 0 to 15
Item#(Pos) = 0
Item$(Pos) = "Empty"
Item_Description$(Pos) = ""
next Pos
sync
endfunction
function UpdateItemCount(Name$, Count, Description$)
Pos = LocateItem(Name$)
Pos1 = LocateItem1(Description$)
if Pos < 0 then Pos = LocateItem("Empty")
if Pos1 < 0 then Pos1 = LocateItem1("Empty")
Item#(Pos) = Item#(Pos) + Count
if Item#(Pos) <= 0
Item#(Pos) = 0
Item$(Pos) = "Empty"
Item_Description$(Pos) = ""
else
Item$(Pos) = Name$
Item_Description$(Pos) = Description$
endif
sync
endfunction
function LocateItem(Name$)
for Pos = 0 to 15
if Item$(Pos) = Name$ then exitfunction Pos
next Pos
sync
endfunction -1
function LocateItem1(Description$)
for Pos = 0 to 15
if Item_Description$(Pos1) = Description$ then exitfunction Pos1
next Pos1
sync
endfunction -1
test:
rem background for menu
Ink 400000,0
BOX 0,0,575,425
rem make menu raw
Ink 5000000,0
`left line
Line 0,0,0,425
Line 1,0,1,425
Line 2,0,2,425
`Middle left Line
Line 120,0,120,425
Line 121,0,121,425
Line 122,0,122,425
`right line
Line 575,0,575,425
Line 574,0,574,425
Line 573,0,573,425
`middle line
Line 0,35,575,35
Line 0,36,575,36
Line 0,37,575,37
`top line
Line 0,0,575,0
Line 0,1,575,1
Line 0,2,575,2
`bottom line
Line 0,425,575,425
Line 0,426,575,426
Line 0,427,575,427
` Text on Menu
Ink 999999999999999999999999999999,0
Perform checklist for fonts
Set text size 20
Set text font "Abaddon"
Text 35,60,"Healing"
Text 30,100,"Weapons"
text 40,140,"Armor"
text 20,180,"Accessories"
text 35,220,"Damage"
text 45,260,"Keys"
text 45,300,"Gift"
text 25,340,"Containers"
text 40,380,"Other"
Text 45,10,"Item"
text 300,10,"Amount"
text 150,10,"Name"
text 470,10,"Effect"
UpdateItemCount("Potion", -1, "Recover 30HP")
return
Well that is my full little code I got going so far. Here is where my "Problem" is. I want to change the ifs where I have if mouseclick or if shiftkey yadayadayada, to the mouseclick code:
pot$="test"
x=10
y=10
h=text hieght(pot$)
w=text width(pot$)
if mousex()>=x and mousex()<=x+w and mousey()>=y and mousey()<=y+h
ink rgb(0,232,0),0
rollover=2
if mouseclick()=1 then end
else
ink rgb(255,255,255),0
rollover=1
endif
text x,y,pot$
Well at least a mouselick code thats like that that gets the job done. I want to move the mouse over and get rollover but when I click the item it does what I want. Here is where I am stuck. I dont know what I would replace x,y with if I dont have an x,y because I use
for i=1 to 10
text 10,i*35,"Empty"
next i
Well something like that.. Well anyway it has no x,y. I need a mouselick that will work wherever that specific item pops up. I hope you follow what I am saying.
Like if Potion is in spot one and you move mouse over it turns green and it exits. Maybe you run out of that item, get a different item and then get potion again. Potion is now in spot 2, and I would still like potion to have green rollover and exit when clicked.
How would I do this with "For To, Next" statements?
Thanks for the help
Nicolas
*Current Project: Untitled RPG
*Working With: Vash the Stampede 815
*Future Number: Eleventy