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 Discussion / how to make arrays of own type?

Author
Message
Holden
22
Years of Service
User Offline
Joined: 13th Dec 2002
Location:
Posted: 31st Jan 2003 16:29
Hi,

can I make arrays (or anything that works like an array), where I can specify more file-types? So, maybe in (1,1) I want to store a string, in (1,2) a float, whereas(1,3) and (1,4) should hold integer-values.
How would I do that? Maybe someone has a code-snippet which teaches methods.

Thanks in advance and best regards!
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 31st Jan 2003 18:04
hey holden

maybe u need to explore TYPES with an array

notice the NUM value holds the object number or media number that DB requires.

this saves a tonne of arrays and clean up is a breeze.




indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 31st Jan 2003 18:10
i should also mention
when u want multiple monsters

this dimmed array skips the zero location to
make sure the positive media number locations
line up easily

but this number should reflect the maximum monsters

dim Monster(10) as Monster



now we write a loop so we dont have to rewrite each
monster code but in some cases its easier.

for i = 1 to 10
Monster(i).NUM=i
Monster(i).NAME="BugBear"
Monster(i).HPS=35
Monster(i).x#=10.0*i
Monster(i).y#=10.0*i
Monster(i).z#=10.0*i
next i

so Monster(4).HPS = 35
and Monster(4).x# = i * 10.0


maybe that will help a bit more

Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 31st Jan 2003 19:34
unfortunatly you can't Holden ...
however you could use a string array to save all the data you need...

so like

dim Monster$(NUM_MONSTERS,6)
then you add simple using

Monster$(1,1) = str$([variable])

and read the variable with val([variable string])
that will no doubt slow your game, but is around the onlyway to have a contained array.

you could always have several arrays names the same
like
Monster_Name$(NUM_MONSTER)
Monster_Health#(NUM_MONSTER)

then input like that i mean more arrays, but achieves what you want.
you should try Dark Edit as that is a pretty good editor which will recode DarkBasic before compiling allowing you to use basic types

Anata aru kowagaru no watashi!
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 31st Jan 2003 20:36
wait! is this dark basic pro or classic? i ran the code in dark basic and it gave a compile error!

your birth was a blessing, sent to live and die on earth as a lesson, we each have a star all you have to do is find it, once you do, everyone who sees it will be blinded - DMX
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 31st Jan 2003 20:51
Indi is trying to show in Professional ... but as i mentioned that isn't possible in Standard

Anata aru kowagaru no watashi!
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 31st Jan 2003 21:33
you have to use either arrays or guys made darkedit with a psuedo type access for DB1.

Login to post a reply

Server time is: 2025-08-08 11:44:14
Your offset time is: 2025-08-08 11:44:14