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 / Type examples

Author
Message
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 13th May 2004 00:47
Ok um Can I get a example of using types like when subtracted there variables and stuff?

A 1 man team
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 13th May 2004 00:53 Edited at: 13th May 2004 00:54
type Person
Age as Integer
EndType

You as Person

You.Age=15


intAdd as integer
intAdd=You.Age + 10

print str$(intAdd)
wait key


* DBP_NETLIB_v1 - VB.NET PLUGIN FOR DBP * Click Logo
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th May 2004 00:55
Not a lot different from normal variables really, except that you *have* to declare them.

type MyType
a as integer
b as float
c as string
endtype

` Declare 2 variables
V1 as MyType
V2 as MyType

` Fill out the first
V1.a=1
V1.b=1.2
V1.c="Hello"

` Fill out the second
V2.a=4
V2.b=99.99
V2.c="Goodbye"

` Subtract their values in the normal way - all arithmetic is identical to standard variables
print V1.a + V2.a

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 13th May 2004 00:57
YAY! its sorta like my old langauge can I have a type of a type?
like in my langauge There was Mob and from there I made enemys and Players for online player like
Mob/Character
and
Mob/Enemies

A 1 man team
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 13th May 2004 04:50
you can have a typed array like Monster(x).hitpoints


fall down seven times, stand up eight
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 14th May 2004 05:19
Um can you please explain the type array part please

A 1 man team
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 14th May 2004 06:22
Just like you declair a normal varable as a type you can do it with arrays as well


You can also have types within types


[beat the machine that works in your head]
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 15th May 2004 03:49
how do I make the player the type?

A 1 man team
ssj3_shadow
21
Years of Service
User Offline
Joined: 12th Jan 2003
Location:
Posted: 17th May 2004 03:05
As of just recently i discovered that DBPro could use types, which in my opinion is the most useful thing that a program can have... but as of my attempts there seems to be no support of arrags within types.
eg.

Type Model
Dim Equipment(4) As String
EndType

Has any one got arrays to work in types, either through work arround or a dll function, any help would be much appreciated.

w00t -what does it mean?
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 17th May 2004 03:09
you can array the type instance, not a var within the type - would be very useful however.

also, if you think types are cool you should see Classes.


* DBP_NETLIB_v1.1 - VB.NET PLUGIN FOR DBP * Click Logo
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 18th May 2004 00:36
@the_winch if I do
Type Monster
sfdf
endtype

Raeckon as Monster
sfdf
endtype

could I do
M as Monster
and still control the sub types of the types?

A 1 man team
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 18th May 2004 00:59
` create a UDT
type monsterData
name$ as string
hp as integer
ID as integer
endType

` create an array of monsters
dim monster(10) as monsterData

` describe the first monster
monster(1).name$ = "Scarecrow"
monster(1).hp = 10
monster(1).ID = scarecrowObject :` a previously loaded model ID

remStart
A model already had XYZ position and rotation so we don't need to include that in the monsterData UDT, just the object ID the monster uses.
remEnd

How about that for a starter?
--
TAZ

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 18th May 2004 01:02
Quote: "` describe the first monster
monster(1).name$ = "Scarecrow"
monster(1).hp = 10
monster(1).ID = scarecrowObject :` a previously loaded model ID"


the first monster would be monster(0)



* DBP_NETLIB_v1.1 - VB.NET PLUGIN FOR DBP * Click Logo
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 18th May 2004 01:02
um I guess thats good but I just need something to call their variable in the code when a person attacks like M as Monster will that still work as a universal name?

A 1 man team
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 18th May 2004 01:22
if you have "M as Monster" in your code then you will have 1 monster with the attributes of the type. If you have "Dim M(9) as Monster" in your code then you'll have 10 monsters, all with the attributes of the base type - BUT - it's up to you to know which moster you are dealing with by keeping track of the INDEX value (num) of the arrayed monsters.


* DBP_NETLIB_v1.1 - VB.NET PLUGIN FOR DBP * Click Logo
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 18th May 2004 01:49
poo so I have to re route my attack code to include all monsters?
So i cant just make one that works with all?

A 1 man team
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 18th May 2004 02:14
if you correlate the object numbers of the monsters to the exact array index of that monster then you could be "notified" of which monster was attacked by the collision value returned.


* DBP_NETLIB_v1.1 - VB.NET PLUGIN FOR DBP * Click Logo
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 18th May 2004 05:36
um can I see a example?

A 1 man team
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 18th May 2004 16:20 Edited at: 18th May 2004 16:21
Yes, CR. I know about DB's N+1 array behavior and base zero. Since Oneka is just starting out, I didn't want to go into that right away.


Oneka, we're creating these examples on the fly. I doubt there is any code to show unless someone sits down and writes it for you.
--
TAZ

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 18th May 2004 16:31
zirch, I know you know I am just of the mindset of "teach it as it is, straight away" Instead of learning a bad habit that has to be unlearned later.


Oneka, I have no code example


* DBP_NETLIB_v1.1 - VB.NET PLUGIN FOR DBP * Click Logo

Login to post a reply

Server time is: 2024-09-22 09:40:51
Your offset time is: 2024-09-22 09:40:51