Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
gothboy 101
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Watonga, ok, usa
Posted: 29th Jul 2004 06:37
someone please help me out it says it cant close neat line



data "Items",1
data "Potion"
data "save"
data "Characters"
data "exit"
if "exit"
end
load image "first page.bmp",1
paste image 1, 100,100
`Number of submenus
numSubMenus=5

`Where the sub menu names will be stored
dim mainMenu$(numSubMenus)
`Where the item names will be stored
dim subMenu$(numSubMenus,20)
`Where the amount of item will be stored
dim subMenuQuantity(numSubMenus,20)
`Where the amount of items in the sub menu will be stored
dim subMenuAmount(numSubMenus)

`Read in data
for x=1 to numSubMenus
read mainMenu$(x)
read subMenuAmount(x)
for y=1 to subMenuAmount(x)
read subMenu$(x,y)
subMenuQuantity(x,y)=rnd(10)+1
next y
next x

sync on

do



`Do left menu graphics
ink rgb(0,0,0),0
text 40,35,"MENUS"
line 40,55,180,55

`Do right menu graphics
ink rgb(0,0,0),0
text 270,35,"ITEM"
text 500,35,"QUANTITY"
line 270,55,600,55
line 480,35,480,440


`Loop through sub menus
for x=1 to numSubMenus
`If the mouse is hovering it
if mousex()>40 and mousex()<40+text width(mainMenu$(x)) and mousey()>40+20*x and mousey()<40+20*x+text height(mainMenu$(x))
ink rgb(0,200,0),0
`If the mouse is clicked then switch menus to that one
if mouseclick()=1 then currentMenu=x
else
ink rgb(100,100,100),0
endif
`Print main menu text
text 40,40+20*x,mainMenu$(x)
next x

`Reset the 'cursor' for printing the text to the top of the list
listInc=0
`Loop through items
for x=1 to subMenuAmount(currentMenu)
`If the amount is more than 0
if subMenuQuantity(currentMenu,x)>0
`Move the 'cursor' for printing the text down, so we don't get overlapping text
inc listInc
`If mouse is hovering it
if mousex()>270 and mousex()<270+text width(subMenu$(currentMenu,x)) and mousey()>40+20*listInc and mousey()<40+20*listInc+text height(subMenu$(currentMenu,x))
ink rgb(255,255,0),0
`If the mouse is clicked and the time has passed from the last item click
if mouseclick()=1 and timer()-clickTimer>200
`Decriment the number of items
subMenuQuantity(currentMenu,x)=subMenuQuantity(currentMenu,x)-1
`Reset timer
clickTimer=timer()
endif
else
ink rgb(100,100,100),0
endif
`Print item name
text 270,40+20*listInc,subMenu$(currentMenu,x)
`Print item quantity
text 500,40+20*listInc,str$(subMenuQuantity(currentMenu,x))
endif
next x

sync
cls

Chaos Games
eat much pie
20
Years of Service
User Offline
Joined: 9th Apr 2004
Location: Within the mind of a lowly mortal...
Posted: 29th Jul 2004 06:45
I haven't had a look at our code, but if you're going to use menus, why not just use the free menus dll at RobK's website? http://blue.robert-knight.net/. It's the same menus system you see in practically all windows applications, eg.




Checkpoint Router: my very own AI routing program: http://eatmuchpie.dbspot.com
gothboy 101
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Watonga, ok, usa
Posted: 29th Jul 2004 06:48
it dont work man

Chaos Games
gothboy 101
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Watonga, ok, usa
Posted: 29th Jul 2004 06:49
but thanks ill sty with mine cuase i dint want to spend a bonch of time changing it.

Chaos Games
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 30th Jul 2004 11:46 Edited at: 30th Jul 2004 11:46
near the beginning you have

if "exit"
end

I'm guessing that should be

if "exit" then end

Also you need to add the work 'loop' just below 'cls' at the end
gothboy 101
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Watonga, ok, usa
Posted: 31st Jul 2004 01:25
tthank you sparky

Chaos Games
gothboy 101
20
Years of Service
User Offline
Joined: 31st May 2004
Location: Watonga, ok, usa
Posted: 31st Jul 2004 01:30
although still if i press exit then it doesn't exit?

data "Items",1
data "Potion"
data "save"
data "Characters"
data "exit"
if "exit" then end
load image "first page.bmp",1
paste image 1, 100,100
`Number of submenus
numSubMenus=5

`Where the sub menu names will be stored
dim mainMenu$(numSubMenus)
`Where the item names will be stored
dim subMenu$(numSubMenus,20)
`Where the amount of item will be stored
dim subMenuQuantity(numSubMenus,20)
`Where the amount of items in the sub menu will be stored
dim subMenuAmount(numSubMenus)

`Read in data
for x=1 to numSubMenus
read mainMenu$(x)
read subMenuAmount(x)
for y=1 to subMenuAmount(x)
read subMenu$(x,y)
subMenuQuantity(x,y)=rnd(10)+1
next y
next x

sync on

do



`Do left menu graphics
ink rgb(0,0,0),0
text 40,35,"MENUS"


`Do right menu graphics
ink rgb(0,0,0),0
text 270,35,"ITEM"
text 500,35,"QUANTITY"




`Loop through sub menus
for x=1 to numSubMenus
`If the mouse is hovering it
if mousex()>40 and mousex()<40+text width(mainMenu$(x)) and mousey()>40+20*x and mousey()<40+20*x+text height(mainMenu$(x))
ink rgb(0,200,0),0
`If the mouse is clicked then switch menus to that one
if mouseclick()=1 then currentMenu=x
else
ink rgb(100,100,100),0
endif
`Print main menu text
text 40,40+20*x,mainMenu$(x)
next x

`Reset the 'cursor' for printing the text to the top of the list
listInc=0
`Loop through items
for x=1 to subMenuAmount(currentMenu)
`If the amount is more than 0
if subMenuQuantity(currentMenu,x)>0
`Move the 'cursor' for printing the text down, so we don't get overlapping text
inc listInc
`If mouse is hovering it
if mousex()>270 and mousex()<270+text width(subMenu$(currentMenu,x)) and mousey()>40+20*listInc and mousey()<40+20*listInc+text height(subMenu$(currentMenu,x))
ink rgb(255,255,0),0
`If the mouse is clicked and the time has passed from the last item click
if mouseclick()=1 and timer()-clickTimer>200
`Decriment the number of items
subMenuQuantity(currentMenu,x)=subMenuQuantity(currentMenu,x)-1
`Reset timer
clickTimer=timer()
endif
else
ink rgb(100,100,100),0
endif
`Print item name
text 270,40+20*listInc,subMenu$(currentMenu,x)
`Print item quantity
text 500,40+20*listInc,str$(subMenuQuantity(currentMenu,x))
endif
next x

sync
cls
paste image 1, 100,100
loop

Chaos Games
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 31st Jul 2004 08:31
You need to add some code to check if the button you click on is the exit button, in which case you end. I added it on line 58.

It also looks like you're missing some values on your data statements, since your for loop wants to read integers after every main menu entry.

Something like this perhaps:

data "Items",1
data "Potion"
data "save",0
data "Characters",0
data "exit",0

Login to post a reply

Server time is: 2024-11-27 03:45:10
Your offset time is: 2024-11-27 03:45:10