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.

Newcomers DBPro Corner / Using Arrays inside of Data Types

Author
Message
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 17th Dec 2002 22:28
I have a feeling it's not possible but without a search engine on these forums its hard to see if anyone has said it's not possible in the past and not embarrass myself by asking .

An example of what i'd like to do if possible is:

With Character being the custom data type.

Character.Str=20
Character.Items(1)=10
Character.Items(2)=22

I can't see a way of declaring this within a custom data type.

Thanks for any help.

Jas
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 18th Dec 2002 00:16
Unfortunately it's not possible.

Ogres have layers.
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 18th Dec 2002 00:38
Thanks, I had a feeling it wouldnt be able to. I'll have to make that a seperate array.

Cheers,

Jas
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 18th Dec 2002 14:49
yes it is possible with types!





What the flame does not consume, consumes the flame.
------------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Home
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 18th Dec 2002 15:18
Thanks for that Kale, but i was planning on using the backpack type of thing with an array like
Character.Backpack(0)="Item1"

So i can use loops to process it in the game.

But thanks about that GLOBAL keyword, must have missed that in my searchings, it will help me out a bit in other things.

Jas
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 18th Dec 2002 19:34
Global is not in the manual, nor is #constant, infact i can't find anything about user defined types either! i tried to create an array within a UDT but it doesn't seem to allow it, which is a shame, other basics do! Also its very annoying that an 'eval()' function isn't included as these are an invaluble aid to iteration. You could of done this:


What the flame does not consume, consumes the flame.
------------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Home
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 19th Dec 2002 03:44
its possible or my 8000 line sof prototype code would fall over.

patch 3.1 is what I use in DBP.

I have posted a dim array type snippet around here before.

Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 19th Dec 2002 14:46
could you post the type here to show how an array was coded within a type? pretty please?

What the flame does not consume, consumes the flame.
------------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Home
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 19th Dec 2002 17:39
sure



empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 19th Dec 2002 17:44
I thought he meant arrays in types, something like:



that is not possible AFAIK

Ogres have layers.
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 19th Dec 2002 19:30
Yup, empty, that is what i was trying to do. I've just created a sepearate Arry outside the Type now. ( Called BackPack funnily enough ).

I'm currently working on a text input routine to allow for more control over inputs like Numeric only input and limited number of characters. Has anyone else done something similar that might save me the hassles? If not i'll post mine in the code snippets area when it's finished.

Jas
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 19th Dec 2002 20:19
Quote: "I thought he meant arrays in types"


yep! i can't find a way

What the flame does not consume, consumes the flame.
------------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Home
Vandetta
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 19th Dec 2002 22:04
Hmm maybe this will settle confusion. As far as I know, there is no way to make an array in a type but you can make an array of types.


is perfectly legal

is not legal, I think I remember reading a while ago that it is possible to make arrays in a type or at least an equivalent using memblocks, but I have no idea how you would go about doing this

indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 20th Dec 2002 02:11
you guys are not making much sense.

whats wrong with using the method above I posted?

Vandetta
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 20th Dec 2002 05:01
Indi your method is fine, but thats not what he wants. He doesn't want an array of a type he wants an array inside of a type.

indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 20th Dec 2002 14:49
so instead of

Monster(1).HPS

he wants Monster(1).HPS(1) ?

empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 20th Dec 2002 15:09
I think so.
So he can make a function like:

function AddToBackpack(CharNum,Item$)
i = 0
while i < 11
inc i
if Character(CharNum).Backpack(i) = ""
Character(CharNum).Backpack(i) = Item$

endif

Ogres have layers.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 20th Dec 2002 15:10
ooops

Once again:



Ogres have layers.
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 20th Dec 2002 18:25
Yup, thats exactly the sort of thing I was on about.

Cheers,

Jas
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 21st Dec 2002 03:14
I see your point now and to ammend that code above to be more in tune wouldnt the backpack dim be a string as the items?
eg:
Backpack$(i) = Item$ would be more the case tho?

jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 21st Dec 2002 12:36
I've just created a new seperate array to get round this.

DIM BackPack(6,10,2)

So If Character 1 has a Sword Equipped in slot three it would look like:

BackPack(1,3,0)=1 :` 1=Sword Item Code
BackPack(1,3,1)=2 :` 2=Code for Item Equipped

All the Items in the game will be coded so it doesnt need to store the text value in the array.

Thanks for all the help from peeps.

Jas

Login to post a reply

Server time is: 2024-02-21 22:52:03
Your offset time is: 2024-02-21 22:52:03