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 / File not reading / saving objects?

Author
Message
Mugen Wizardry
User Banned
Posted: 14th Dec 2010 01:58
Hi all. I have 2 small problems. I can get this code to save the objects to a file, but I can't get it to load all the objects that were on the map. Basically, I want to save ALL objects on a map, and regardless of their shape, I want them to REMAIN in the shape they were when they were put on the map

Here's the code:



Thanks! ^^

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mugen Wizardry
User Banned
Posted: 14th Dec 2010 14:51
Anyone? :/

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 15th Dec 2010 05:43
Is your code not loading the objects at all,
or is it not placing the objects in the right position,angle,scale?

Sounds like time for some debug code...
Print to the screen as each object is loading to see that the correct
info is being setup for each object.
Mugen Wizardry
User Banned
Posted: 15th Dec 2010 14:18
I got saving to work. But I can't get loading to work

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 15th Dec 2010 18:44 Edited at: 15th Dec 2010 18:45
look at the following code...



You load object i
then position/rotate/scale object id

My signature is NOT a moderator plaything! Stop changing it!
Mugen Wizardry
User Banned
Posted: 15th Dec 2010 19:26 Edited at: 15th Dec 2010 19:36
i fixed saving.

HOWEVER, when I load a saved dat file, it seems like it's mysteriously positioning it infinite times at the cam's coords.. :/

Idk why

Here's the code



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 15th Dec 2010 23:59 Edited at: 16th Dec 2010 00:00
It's cause your only positioning one object, whatever 'id' is. It should be 'i' instead.

So this:
Quote: "
position object id,x#,y#,z#
rotate object id,x#,y#,z#
scale object id,x#,y#,z#"


Should be:
Quote: "
position object i,x#,y#,z#
rotate object i,x#,y#,z#
scale object i,x#,y#,z#"


A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 16th Dec 2010 17:21
*Sigh*
See my above post.

Quote: "look at the following code...



You load object i
then position/rotate/scale object id"


Kinda thought I'd already explained this...

My signature is NOT a moderator plaything! Stop changing it!
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Dec 2010 17:30 Edited at: 16th Dec 2010 17:34
I still don't get that, you load object i then position object id. There two different objects. Looking at his code, id would be object 1, then for every single object he reads he just updates object 1 with their params. Surely it makes sense to update the new object... Unless i've missed something in his code.

Edit: Wait, are we pointing out the same thing?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Mugen Wizardry
User Banned
Posted: 16th Dec 2010 17:52
For some reason, it's still positioning infinitely

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mugen Wizardry
User Banned
Posted: 16th Dec 2010 19:31 Edited at: 16th Dec 2010 19:32
Here's the code:



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 16th Dec 2010 19:58
Thank you for the code

Mugen Wizardry
User Banned
Posted: 16th Dec 2010 20:40
No problem. Because it wont work for u anyway

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mugen Wizardry
User Banned
Posted: 17th Dec 2010 02:43
ok. ive come to a conclusion that to stop infinite positioning / rotation / scaling, u need a boolean.

can someone please tell me what im doing wrong with this part of the code?



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 17th Dec 2010 03:21
Quote: "
read long 1,object count()
"


I have a feeling this might be part of your problem.

Mugen Wizardry
User Banned
Posted: 17th Dec 2010 04:06 Edited at: 17th Dec 2010 04:10
it still won't allow me to load any objects.

Here's what I have so far:



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 17th Dec 2010 10:36 Edited at: 17th Dec 2010 11:27
Really the best way to get help...is to help us a little more
You should post a code sample here that we can copy and paste
then compile, a working program.

By posting code fragments that we can't run, all we can do is guess.
So PLEASE post code we can compile and test for you....Thanks!
One more thing, please indent your code so all the IF's and ENDIF's line up correctly...Thanks Again.
The last thing, you really should have separate open and save routines,
they will be easier to debug and a more standard way of doing things...

By helping us just a little more, we will be able to help you much better.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 17th Dec 2010 13:36 Edited at: 17th Dec 2010 14:00
Out of interest, because I've never used Read Float, would it try to read other variables too? So if the file was set up:

Write Float 1,a#
Write Float 1,b#
Write Float 1,c#
Write String 1,s$

But you read it:

Read Float 1,a#
Read Float 1,b#
Read Float 1,c#
Read Float 1,s$

Would it try to read the string as a float?

Edit: After a test, that's definitely one issue with your code. You need to read it in the order you wrote it.

Edit: Here's a working example:


A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Mugen Wizardry
User Banned
Posted: 17th Dec 2010 17:02
Ok guys. I wrote up a core that should reproduce the glitch. To reproduce the glitch, simply hold Control, press S, save your DAT file, then hold Control, press O, open your DAT file. You will notice NO objects appear on the screen. The core is set to delete all old objects after a load and load the new 1s onto the screen at the DAT file's given coordinates of position, rotation, and scale for EACH object that was saved.

TestSave.dba:



filereq.dba:



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 17th Dec 2010 18:02
Your load_object function() has faulty logic.

It deletes the objects, but will only load the object if the object already exists, which it doesn't, so it doesn't.

I think u meant



Mugen Wizardry
User Banned
Posted: 17th Dec 2010 18:04
thanks prof, but it's still not loading the objects

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mugen Wizardry
User Banned
Posted: 17th Dec 2010 20:06
Why isnt it loading the objects?

All the coordinates it's reading are right

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 17th Dec 2010 20:43 Edited at: 17th Dec 2010 20:43
Here's your issue:

for i=1 to object count()

Since no objects exists, object count() = 0 so, for i = 1 to 0 will do nothing and entirely skip the loading section.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Mugen Wizardry
User Banned
Posted: 18th Dec 2010 02:31
Problem solved!

Thank you to all that helped!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!

Login to post a reply

Server time is: 2026-07-21 07:03:43
Your offset time is: 2026-07-21 07:03:43