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 / IF statement issue

Author
Message
Bush Baby
20
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 16th Nov 2005 22:24
Hello,
I am working on a RPG.
I've been having an issue with my object pickup IF statements.
The Player can pick up the objects and everything fine. 'But' it forces the player to pick up the objects in the order I coded them in the loop, which is a bugger.
Is this normal? Did I just screw up?
It's rather annoying since it was obviously not meant to be that way.
I have my ifs like so:
if <return value>
<code>
endif

should they be like:
if <return value> then <code>

or should that not even matter?

Thanks in advanced!

~Dark Padawan
dab
20
Years of Service
User Offline
Joined: 22nd Sep 2004
Location: Your Temp Folder!
Posted: 17th Nov 2005 06:31
I think maybe a little bit of code would help waay more than we can help you THough, it doesn't really matter what form of if statements you use. (To my knowledge). I would love to help, but I don't have code to see what you might be doing wrong.

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 17th Nov 2005 09:44 Edited at: 17th Nov 2005 09:47
Quote: "Is this normal? Did I just screw up?"


You screwed up.

Can't help you much without code.

Quote: "I have my ifs like so:
if <return value>
<code>
endif

should they be like:
if <return value> then <code>

or should that not even matter?"


That doesn't matter.

Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 17th Nov 2005 10:48
i am not actualy seeing any code , and seeing my crystal ball is at the menders, plus I don`t know where you live so I can`t stand behind you and look over your shoulder or use a spy satellite, and seeing you DID NOT POST CODE! <<<hint hint
I am gonna have to guess, I guess you have nested your pick up conditions, what you need is code that reads like this...

do
if object hit(player,sword)
sword=1
endif
if object hit(player,kettle)
kettle=1
endif
if object hit(player,bottle)
bottle=1
endif
loop

allows you to pick up objects in any order you like, I guess you have written your code so that when you pick up the first thing you go into an internal loop where you wait until you pick the other, then you go into another loop waiting for the other object etc, when all you need to do is check for each condition each pass inside the main loop.



if there is one thing I can NOT tolerate, it`s intolerant people.
Bush Baby
20
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 17th Nov 2005 23:14
Well I would've posted code if I thought it was needed to be.
Thankyou Me! for that explanation! I never thought I might've been making an internal loop.

But I don't see how I could be.
Here is my code for picking up the objects:



~ §witchy ~
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 18th Nov 2005 13:02
It should work ok so long as the objects are not on top of each other.

Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 18th Nov 2005 14:41 Edited at: 18th Nov 2005 20:40


example code lets you "collect" the coloured spheres in any order, see what difference your code has to this, maybe it will just give you that sudden "ping!" of inspiration (cursor left/right to turn and up/down to move...you are the grey cube)



if there is one thing I can NOT tolerate, it`s intolerant people.
Bush Baby
20
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 18th Nov 2005 22:17
Quote: "It should work ok so long as the objects are not on top of each other.
"

I know it should work but it doesn't.
I can only pick up the objects in the order you saw in that code snippet.

@Me!
That code doesn't work, I get unrecognized parameter for
Quote: "if object visible (i)"

But thanks for trying to help

I'm going to experiment around again... and see if I can finally get this fixed.

p.s. Sorry if I post so much later after you guys, because I'm a "new member" I have to wait until a moderator basically says "ok" to my post. Sorry for the inconvenience.

Bwahahahahahahaahahaahaah :-o
Bush Baby
20
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 18th Nov 2005 22:20
OH geez I just noticed in my code, I DO have an internal loop!
The Detach object from static is always detaching the next object in the ifs!!! I'll remove that and just keep them all non static!
I'll let you know how it goes!

Bwahahahahahahaahahaahaah :-o
Bush Baby
20
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 19th Nov 2005 16:42
it didn't work
It still forces me to pick up the objects in order!


This is starting to become very annoying!

I only thought I was alive...
Bush Baby
20
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 19th Nov 2005 21:41
It still doesn't work!
I've tryed everything I could think of...
but I shall not give up!
I tryed:

If object hit(player,object) > 0
<code>
endif


but that didn't seem to make a difference, still the same result.

So I think it might be some dumb little thing that I'm not catching on to.


I only thought I was alive...
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 19th Nov 2005 22:08


revised code will run in classic (maybe) but leaves the markers behind after you select the objects (no biggie).



if there is one thing I can NOT tolerate, it`s intolerant people.
Bush Baby
20
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 19th Nov 2005 23:19 Edited at: 19th Nov 2005 23:23
Ah , yes that ran in DBC.
Thanks!

I still haven't figured out this problem though, it shouldn't be there!

Edit//:
Do you think it could just be a DBC error?
Or like a DBC 1.13v error?
It's weird because it's the only thing in the entire loop that is forced in an order.

I only thought I was alive...
Bush Baby
20
Years of Service
User Offline
Joined: 23rd Apr 2005
Location: A cave beneath Jerusalem
Posted: 20th Nov 2005 02:13
Well, I have abandoned this RPG.
I've decided to write a bigger and better RPG!
I've learned a ton with this one, it helped me remember DarkBasic!
So I'm taking what I learned to the next level
Let this topic die in peace....

I only thought I was alive...

Login to post a reply

Server time is: 2025-05-22 19:30:52
Your offset time is: 2025-05-22 19:30:52