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.

DarkBASIC Discussion / pop up menu problems.

Author
Message
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 3rd Jan 2005 12:34
I am using the following code to show a pop up menu.....



When the B key is pressed (scancode 48) the menu appears, when the B key is released the menu dissapears, great thats what I wanted. However, it appears that DB doesn't register two keys being pressed at the same time, so that makes that last bit of code useless, because it would require you to hold down the B key and then press number 1 on the keyboard to trigger the action, so what I am wondering, is how I can make it so that whan b is pressed the menu appears, and when b is pressed again, the menu dissapears, so far I have tried the following and it didn't work...



If I use that, the menu doesn't appear at all, so how would I accomplish this?

Thanks.

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 3rd Jan 2005 18:18
To fix it:



And as for what's wrong with the second one:



It would look better indented, and you need a wait statement:



2005. 2005. 2005. No way. 2005. 2005. You've got to be kidding me. 2005 already!?
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 4th Jan 2005 01:26 Edited at: 4th Jan 2005 01:39
Thanks that works!

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
blueselah
20
Years of Service
User Offline
Joined: 15th Dec 2004
Location: TN, USA
Posted: 4th Jan 2005 01:42 Edited at: 4th Jan 2005 01:43
move this command

if scancode()=48 then buymenu=0 : wait 200

out of the if endif statements
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 4th Jan 2005 01:50
By the way, I have a problem with how it is subtracting the money it is supposed to. While the buymenu=1 and scancode()=2 your money resource is supposed to be subtracted by only 500, however when I use this line of code...



It keeps subtracting it as long as the button is held down, how would I alleviate this?

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
blueselah
20
Years of Service
User Offline
Joined: 15th Dec 2004
Location: TN, USA
Posted: 4th Jan 2005 06:46
i would put in a goto statement after the calculation
reset your variables
like...

if buymenu=1 and scancode()=2
money(0)=money(0)-500
set cursor 500,500: print "mining vessel purchased"
wait 200
buymenu=0
goto Main_Loop
endif
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 4th Jan 2005 07:18 Edited at: 4th Jan 2005 07:28
With just that Wait 200 command in there it works fine thanks! Oh and while I'm on the subject of buying stuff, say I wanted to create 5 of the same objects, that the player can buy, each time the player buys one, it should appear, and then the next time, another one should appear, I tried this and it only unhides one of the objects...

for miner=80 to 85
if buymenu=1 and scancode()=2
if money(0)>0
money(0)=money(0)-500
set cursor 500,500: print "mining vessel purchased"
show object miner
wait 200
buymenu=0
endif
endif
next miner

I cannot get it to unhide the other 5 objects, and they are randomly positioned so they are not just stuck on top of each other, so what am I doin't wrong?

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 4th Jan 2005 08:55
Dont use scancode, it only controls one key at a time. Instead of

scancode() = 67
scancode() = 98

use

keystate(67) = 1
keystate(98) = 1

Hi
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 4th Jan 2005 09:15
Ok thanks, anybody got any ideas on my last question?

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
blueselah
20
Years of Service
User Offline
Joined: 15th Dec 2004
Location: TN, USA
Posted: 4th Jan 2005 11:14
i'm not exactly sure what you are trying to do..... could you explain a little better..? i don't think you would have the if statements within a for next statement. .... but i don't know exactly what you are trying to do... more information please....
Los
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Location:
Posted: 5th Jan 2005 00:59
I've got an idea about coding. Seems computers are pretty quick at running this code, so you need to trap it somehow. Control it.

I had problem with variables increasing constantly when I only wanted one, so you need that line of code to only read once. by holding down the mouse button you could create a room. By letting go(mouse=0) or by hitting both buttons(mouse=3) you could cancel it. Otherwise it would run through.



By trapping the inc roomnum into an ELSE statement it seemed to have worked.

I think your miner for loop is running through 80 to 85 at any rate, rather than having an option to buy individually. So object miner 84 could appear rather than 80. You might not get me.

Control what your doing.
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 17th Jan 2005 02:13
There's only one problem with this code:

for miner=80 to 85

if buymenu=1 and scancode()=2

if money(0)>0
money(0)=money(0)-500
set cursor 500,500: print "mining vessel purchased"
show object miner
wait 200
buymenu=0
endif

endif

next miner

After buymenu is set to 0, you forget to set it to 1 again...

Avatar - white cat in a snowstorm. Look closely.

Login to post a reply

Server time is: 2025-05-24 19:00:20
Your offset time is: 2025-05-24 19:00:20