Hi,
I have been working on trying to get a decent item menu going on where as the are non-specific item spots. I got a code from Blazer and I changed it a little. Then IanM helped me fix it up some more.
Works good except I cant get it so my item has its own mouseclick.
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
I want each item in my game to have its own mouseclick that does a specific thing. Right now I have accomplished that with buttons. The thing about mouseclicks it you need an x,y and if I use
for i=1 to 10
whatever in here
next i
It has no x,y.
This is the mouseclick code I usually use:
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 something like that. But you see the mouseclick will follow that variable only. I want that for mine.
Please help me out guys. Similar post circulating in Newb Corner but no responses.
Thanks
Nicolas
*Current Project: Untitled RPG
*Working With: Vash the Stampede 815
*Future Number: Eleventy