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 / Help with saving arrays that contain UDTs; I can't get it to work!

Author
Message
Yodaman Jer
User Banned
Posted: 13th Feb 2012 14:28
Hello all,

for my next game I REALLY need to figure out how to save arrays that contain user-defined types. Here's an example of code I tried...



I keep getting a "Can't save array type!" error and I have no idea how to get about it. Can anyone give me some pointers please?


Click to go to my blog!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Feb 2012 14:36
Generic DBPro can't save UDT arrays to files. If you want to do that they you need to write the code to do it for you.

However, if you use my plug-ins then using the datafile commands instead of DBPro's file command will allow you to use the LOAD ARRAY FROM DATAFILE and SAVE ARRAY TO DATAFILE commands

Yodaman Jer
User Banned
Posted: 13th Feb 2012 14:47 Edited at: 13th Feb 2012 14:48
Awesome! Thanks Ian! Before I get too far ahead in my project I'm going through your Matrix1 commands and see just how many I can use. While reading up on the commands you listed I discovered about three other ones that will definitely help in this project!

EDIT: This saves SOOOO much work for save files!


Click to go to my blog!
Yodaman Jer
User Banned
Posted: 14th Feb 2012 23:31
This is completely unrelated, and forgive my ignorance, but I can't seem to figure out how to attach a 3D object to the mouse cursor and have it move wherever the cursor is moved to. Can anyone help point me in the right direction please?


Click to go to my blog!
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 15th Feb 2012 05:10
Quote: "This is completely unrelated, and forgive my ignorance, but I can't seem to figure out how to attach a 3D object to the mouse cursor and have it move wherever the cursor is moved to. Can anyone help point me in the right direction please?"

there's an example of this in the dbpro help files under pick object command i believe

Yodaman Jer
User Banned
Posted: 16th Feb 2012 03:45
That's not quite what I'm going for. Sorry, I should've been more descriptive in my last post!

What I want is a 3D cursor of sorts, that moves with the mouse cursor but translated into 3D movements (along the x/Z axis). I've gotten a small example to work but the object doesn't stay with the mouse cursor, it flies off into oblivion.

What I want is something similar to this video, where the object that the user is placing stays underneath the mouse cursor. I know it can be done in DBP but I just can't figure out how, nothing I try works at all!


Click to go to my blog!
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 16th Feb 2012 12:01
Quote: "Sorry, I should've been more descriptive in my last post!"

no, i understood what you meant

The pick example contains part of the code which you need but it needs to me modified a little bit

The attached example has the exact thing you need. Check the Move_Cursor() function

Yodaman Jer
User Banned
Posted: 16th Feb 2012 14:49
Thanks Brendy Boy, that example works great!

I had no idea you could make vectors in DBP... Seriously, that's pretty cool. Definitely going to have to look into that more.

Can you please explain a little of how to set up a function like that? I've been studying it for a while now and I'm still not sure what does what. I've never seen vector commands used in DBP before.


Click to go to my blog!
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 16th Feb 2012 16:39
Quote: "Can you please explain a little of how to set up a function like that?"

what function?

Quote: " I've been studying it for a while now and I'm still not sure what does what. I've never seen vector commands used in DBP before."

when you use pick object command dbpro transforms the 2d mouse coordinates from screen space to 3D world space and stores the offset values in internal variables. These offsets can be retrieved with get pick vector commands. To get 3D position of a point where you click with the mouse you have to add that offsets to camera position, and that's basicaly it.

Yodaman Jer
User Banned
Posted: 19th Feb 2012 15:43
The move cursor function is the one I was talking about, but I believe you answered the questions already. That doesn't sound nearly as complicated as I originally thought! I'm definitely going to study those commands later!


Click to go to my blog!
Seppuku Arts
Moderator
21
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 19th Feb 2012 16:29
IanM's solution seems pretty cool, considering we seem to be using the same method I might grab it too and use that instead.

However, my work around for it has been to transfer any UDTs into a separate array for saving, but then only a handful of my UDTs have data I want to save, so it's not a big problem.

For example:

When saving

And when loading



Yodaman Jer
User Banned
Posted: 19th Feb 2012 19:47
Ah, yeah, that technique wouldn't exactly have worked for me but it's a good idea nonetheless! I'm definitely loving IanM's commands though, they're terrific!


Click to go to my blog!

Login to post a reply

Server time is: 2026-07-10 08:48:37
Your offset time is: 2026-07-10 08:48:37