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 Professional Discussion / Picking and Deleting

Author
Message
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 5th Mar 2014 11:57
Hello community!

Bothering with another question of mine.

First of all i would like to thank everyone who helped me all this time to achieve a big project of mine(of course i have a lot more to do).

Second,

My problem is that i am creating objects by incrementing a number but after incrementing that number its not available anymore. I tested it with the pick objects to tell me the object number and it says always 0.
The thing that i want to achieve is when i create some objects to be able to delete them and manipulate them whenever i want.

Now i am using this code to add objectsforgive me but its a bit large)


Thank You again for your support!

Alex Matei CEO
www.alexmatei.com
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 5th Mar 2014 12:20 Edited at: 5th Mar 2014 12:36
First of all, proper indentation makes the code a lot easier to read for anybody (yourself included ).



Second, "I tested it with the pick objects to tell me the object number and it says always 0." doesn't really make any sense to me. Could you go into a little more detail, or provide the code responsible for that?

I don't quite understand what exactly isn't working. Do you get an error message at any point? Or does it just not behave the way it's supposed to?

A few things I noticed in your code:

1. obj isn't initialized, so it may or may not start with the value 0 - this, however, would result in an error message as soon as you check object exist(obj), which seemingly is not the case? Which leads me to the conclusion that obj is possibly a global variable defined somewhere else? If so, bad idea. If not, I don't really know what's going on.

2. This block:



I'm not sure what multiplyimpob does (the name doesn't really tell me much and there are no comments regarding the variable), but it seems as if the else part of the code has a problem - you delete the object on mouseclick() = 2 (not even checking whether it's a new press or the key is being pressed constantly - you did that for the LMB check, but not here), without checking if the object exists, and without resetting the obj variable. Hence, when pressing RMB for more than one frame (i.e. a few miliseconds), the program will probably crash

3. Just as obj, the file$ variable doesn't seem to be initialized anywhere

4. Not a problem, but kind of strange:



Is there a reason why you check the object's existence four times in this piece of code, instead of just once? Kind of peculiar.

Well, so much about that. Sorry if that didn't solve your problem, but I feel that's hardly possible without a few additional details.




IMPORTANT: I just visited your website. As soon as I loaded the Games site, it basically hijacked my browser, telling me something about "POLICE WARNING: YOUR SYSTEM HAS BEEN DEACTIVATED" and it didn't let me close the tab or opera. Had to shut it down using the task manager. Basically this seems to be a not too unusual kind of malware that I stumbled upon a few times throughout the last years - once even from my own webspace. Hence I assume you're just another victim and didn't know this problem exists. Check your site files (without opening the website itself), preferably all index.htm/html/php files and of course the once of your games section. If they have been changed recently without your knowledge, make sure to replace them with the respective files from your hard disk.

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 5th Mar 2014 13:00
Sorry if i didn't included some details.

The variables are global from the default file of the project but thats not the problem i think

The only thing that i want to achieve and i don't seem to achieve it is to create some objects and then to manipulate them such moving, scaling retexturing them everytime i want etc like in Unreal Engine. Yes it doesn't behave as it should do. If you have an example i would really appreciate it to see what i am doing wrong Thats the only thing i need to do and these are the details if i missed something please just tell me and i will rephrase

Alex Matei CEO
www.alexmatei.com
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 5th Mar 2014 13:15
I don't see pick object anywhere in this code.Are you sure you use it properly?If not used properly it will throw 0 back at you.For example this is how i use it:



Hovered object is an object where mouse is over and Selected object is one which you select with mouseclick.My range of objects is trough 1 to 70, hovering over any other outside this range will throw back 0 and selecting it will be impossible.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 5th Mar 2014 13:33
That code i didn't included sorry, the fact is that this code with pick object as you typed, it doesn't detect the objects that i placed.

This is my code:



This code tells me if a number on the string with the objects that i am hovering. The fact is that it doesn't show the number it shows alway 0! So the fact is that i can't initiate a code to manipulate those objects that i created because it doesn't even detect the objects.

Alex Matei CEO
www.alexmatei.com
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 5th Mar 2014 13:41
Are you sure the objects you're trying to manipulate have IDs between 2000 and 3000? Doesn't it work either if use pick object(mousex(), mousey(), 1, 3000) ?

MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 5th Mar 2014 14:41
Yes my global var obj starts at 2000 to 3000

Alex Matei CEO
www.alexmatei.com
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 5th Mar 2014 16:20
Quote: "The thing that i want to achieve is when i create some objects to be able to delete them and manipulate them whenever i want."


I suppose ther must be better ways to achieve this. This is a quick example I made right now. I hope that helps.



I'm not a grumpy grandpa
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 5th Mar 2014 17:12
Very good example chafari! I also found out that it was because i had a so large number but from the test that i also made. But when applying in my engine nothing seem to work...is that because i have a global var on the default dba file and the function in a totally different dba file?

Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
12
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 5th Mar 2014 20:20
Just to announce, i resolved the problem...the actual problem was the camera's range that i set.

Thank You all very much again for your time!!!

Alex Matei CEO
www.alexmatei.com

Login to post a reply

Server time is: 2026-07-06 04:28:52
Your offset time is: 2026-07-06 04:28:52