This tutorial assumes you have a basic knoledge of DBP. I'm not sure if this tutorial will work on DBC. You need to know about variables and data types before you can understand types.
What is a type?
A type is a set of variables that are contained inside a larger catagory. You can use these variables again and again to make many items that have all the characteristics associated with the catagory.
How to make a type
You are given a challenge: make the properties in monopoly in DBP. This is when you need to use types. Each property must have a name, a price, and price per house, a starting rent, a rent with 1-4 houses, a rent with a hotel, a mortage, and a color. First we define all these characteristics of a "property"
type property
price as integer
houseprice as integer
rent as integer
rent1h as integer
rent2h as integer
rent3h as integer
rent4h as integer
renthotel as integer
mortage as integer
color as dword
endtype
As you can see, we created a type property. We then made a variable for each characteristic of a property, and defined what kind of variable it was. Now we just need to make different properties.
type property
price as integer
houseprice as integer
rent as integer
rent1h as integer
rent2h as integer
rent3h as integer
rent4h as integer
renthotel as integer
mortage as integer
color as dword
endtype
` properties:
`Mediterranean Avenue:
Medit_Ave as property
Medit_Ave.price=60
Medit_Ave.houseprice=50
Medit_Ave.rent=2
Medit_Ave.rent1h=10
Medit_Ave.rent2h=30
Medit_Ave.rent3h=90
Medit_Ave.rent4h=160
Medit_Ave.renthotel=250
Medit_Ave.mortage=30
Medit_Ave.color=purple
So we have made a variable name for mediterranean Avenue, and made it a property. Notice how there is a rem statement at the beginning. This is because though we want to be able to easily recognize what property it is, we want to variable name to be shorter, so we made a rem statement that shows what property it is. Then we gave it the values for each characteristic of a property. We can do this again and again, changing the name of Medit_Ave to anything we want, and it will become a property.
Hopefully now you have a better understanding of what types are and how to use them. Feel free to post questions if you have them, or errors if there are any(
).