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.

Author
Message
CSGames94
18
Years of Service
User Offline
Joined: 27th Dec 2007
Location:
Posted: 15th Jul 2010 19:32
Does DBPro have anyway to do dynamic types?

The Pokemon Engine is still alive.
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 15th Jul 2010 19:37
Nope.

"everyone forgets a semi-colon sometimes." - Phaelax
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 15th Jul 2010 19:45
What do you mean by "dynamic type"? A type by definition is a data storage type like integer except that there are sub-variables to it.

The fastest code is the code never written.
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 15th Jul 2010 20:33
IanM's plugins have raw memory allocation and access, and there are some key/value lookup commands. I'm sure anything that you need can be accomplished using them, even if the syntax is a bit awkward.

[b]
CSGames94
18
Years of Service
User Offline
Joined: 27th Dec 2007
Location:
Posted: 15th Jul 2010 20:45
Quote: "What do you mean by "dynamic type"? A type by definition is a data storage type like integer except that there are sub-variables to it."
I know, but what I mean by dynamic type is something like this:

Ex-
Type Game
Player As Integer
Price As Integer
EndType

Then Later on, add in company.
Type Game
Player As Integer
Price As Integer
Company As String
EndType

Quote: "IanM's plugins have raw memory allocation and access, and there are some key/value lookup commands. I'm sure anything that you need can be accomplished using them, even if the syntax is a bit awkward."
Thanks , I will take a look at his plugins.

The Pokemon Engine is still alive.
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 15th Jul 2010 20:48
I was thinking you meant dynamic types in it's usual definition: where a variable can be of any type. DBP can't do that natively but as Diggsey pointed out, you can do raw memory allocation on the heap, which would be tricky but possible.

As for what you're looking for, I don't think it's possible. Why would you need to do that anyway?

"everyone forgets a semi-colon sometimes." - Phaelax
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 15th Jul 2010 21:22
If you're going to add it later in the code, why not just include it at the initial declaration?

My signature is NOT a moderator plaything! Stop changing it!
CSGames94
18
Years of Service
User Offline
Joined: 27th Dec 2007
Location:
Posted: 15th Jul 2010 22:32
I need Dynamic Types, because I'm working on a new engine, and I want users to be able to add their own attributes to their characters.

The Pokemon Engine is still alive.
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 15th Jul 2010 23:41
Quote: "I need Dynamic Types, because I'm working on a new engine, and I want users to be able to add their own attributes to their characters."


If you could do that, you could basically wrap darkbasic inside itself and sell it as your own product.

But, You could create an array with an extra dimension, and use that as an id.

instead of




Rawwrr. Sig Fail.
Newcastle is awesome
CSGames94
18
Years of Service
User Offline
Joined: 27th Dec 2007
Location:
Posted: 16th Jul 2010 00:48
@Mad Nightmare, Okay thanks I forgot all about that .

The Pokemon Engine is still alive.
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 16th Jul 2010 02:10
Or alternatively move it over to C++ with GDK. You can use classes, which are essentially typed, and then people can extend them and add only the extra fields that they want, as well as new methods, or override existing methods.

"everyone forgets a semi-colon sometimes." - Phaelax
bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 17th Jul 2010 11:55
Quote: "I need Dynamic Types, because I'm working on a new engine, and I want users to be able to add their own attributes to their characters."


Or use a lua plugin!

RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 17th Jul 2010 21:21 Edited at: 17th Jul 2010 21:22
Alternative solution for adding attributes to a character:

Create an Array that stores both an Attribute ID and a Value for that attribute. You can track attribute names in a separate array, or using Ian M's Matrix Utilities "Key to Value lookup tables."

Once all attributes for a character have been added to the attribute array, copy the array to a memblock. Next, add the memblock to the character object (assuming this is a 3d game).

Pulling memblocks from objects can slow things down, so while an object is "active" or in "active range" (a range where it can be expected the attributes will be checked), keep the memblock in memory. Otherwise, the memblocks can be deleted once stored in the object.

=====================

Next issue:

Besides storing values and corresponding meaningful attribute names for the user, how will the values be used? Simply storing a value with a unique name is not particularly useful. Some process must occur with that value in order for it to be useful. For example, Hit Points determine if a character is alive or dead. When processing a Hit Points attribute value, a check is made to determine if the value is greater than 0, indicating the character is alive and can perform the next action. Monetary attributes are checked against prices of goods.

Let's suppose the user creates a "Banana" attribute. Sure, the user can freely name the attribute and supply a value. But what will the program do with it? A less extreme example would be creating an Agility attribute. Dexterity might be defined, and Agility would pretty much be the same thing. But how would the code know the difference between Agility and Banana? It wouldn't unless a function or subroutine was specifically coded to accept these attribute names.

If anyone can get around that roadblock, I would really like know how. It is a problem I have been considering for a very long time.

Login to post a reply

Server time is: 2026-07-25 07:54:25
Your offset time is: 2026-07-25 07:54:25