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 / Function doesn't seem to do what it's suppose too o.O

Author
Message
Mudbud Productions
15
Years of Service
User Offline
Joined: 1st May 2011
Location: Cloud 9
Posted: 14th May 2012 06:36
Hey I have been working with 3D modelling and trying to get cars working with dark physics but this function I made which, is suppose to collect limb information and output it to a file, isn't doing anything.


So I put in an object ID as the perimeter, then it checks if that object ID is valid. If it is then it checks how many limbs are in the object, then creates an array that holds each limb, and some information per limb, so limb 1 has 17 slots, for positions, angles, etc. Each command is a float so I initialized the array as a float aswell. It even creates a file like it's suppose to. But nothing is put in... I don't see why.

I've debugged it with putting models I know have limbs in them, like the beach buggy. So it should have output into the file in this order:

limbname
Limbdata
..
...
....

etc

But nothing is written.

If someone could help me find the error and/ test the function I would be ever grateful. Thanks
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th May 2012 09:49 Edited at: 14th May 2012 10:29
As far as I know and remember that file ["ObjectInfo.txt"] must be checked for existence, and then be deleted ... so you MUST perform a check for its existence then delete and then open to write...

please confirm this

EDIT

Here is what I did and yup does not write anything...



conclusion, there is something wrong with your code... and I am not experienced enough to fix it... but this has been an interesting experience

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 14th May 2012 13:02
You also have 'ii' set as a loop but within the loop you're using 'inc ii'. I'd check what you're after because that's wrong.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th May 2012 13:39
There are at least three errors in the original code:

1. This line



should be



2. Limbs are numbered from 0 to LimbCount-1 so you need something like:



instead of




3. You need to delete the following two lines:



and



and initialise ii for each limb, e.g.




The problem with this:



is that ii is being incremented in two different ways and rapidly exceeds the valid range.

I don't know why you didn't get array runtime errors.

I attach a typical file I get when I make those changes. I don't guarantee there aren't other errors - but at least you should get something you can check.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th May 2012 14:52
I don't like this use of ii, it look too much like...

11
iii
i
ll
lll
l
jj

They all look the same, or similar. The very first program I ever worked on in 1980 was written from a magazine. They used A = 1, and also A = i. My mate had typed the program in, but asked me if I could fix it. I changed A = i to A = 1, and it worked. So I would never use i in a program.

Mudbud Productions
15
Years of Service
User Offline
Joined: 1st May 2011
Location: Cloud 9
Posted: 14th May 2012 18:09 Edited at: 14th May 2012 21:26
Ah I see. Thanks GG, I guess my code was worse than I thought since it was a very late night
@ Pincho I've been using that for a few years now and I don't mix up i with 1..


I also know that the problem was with the for loop and before you all posted I already had it fixed a few hours later Thanks for the help though.

Quote: "I don't know why you didn't get array runtime errors. "

I didn't get array errors but sometimes when I compiled the project it would throw an addpkt to exe error.. Seems like I've fixed it since then.

Thanks again


EDIT: If anyone was curious to see the new working function I've posted it below



I loaded in a random car from DarkMATTER and it successfully wrote the limb names, followed by some data and then creates new line and starts with the next name. It's dynamic so there can be any number of limbs from 1 to 900 etc

This is the output from the police car in DarkMATTER:

Login to post a reply

Server time is: 2026-07-22 00:34:38
Your offset time is: 2026-07-22 00:34:38