That depends. What do you mean by "types of buildings"? Do you want each different building to hold different data than the other ones, or do you want the different buildings to hold different data formats? Put a little bit simpler, do you want your subvariables to be all the same (so each subvariable might still hold different numbers). For example, do you want all of the buildings to have a "peasantnumber" variable, or do you just want to have castle.building variable named "peasantnumber". Also, you need to declare the type before you can use it. So, if you are just using a single type, you would need something like this in your code.
Type building
Field price
Field name$
Field x
Field y
Field owner
End TypeHere's an example of what you can do with this type declaration. Hopefully it will clear a few things up, as well as give you some useful tricks.
Graphics 800,600,16,2
SetBuffer(BackBuffer())
SeedRnd(MilliSecs())
Type owner
Field FirstName$
Field LastName$
End Type
Type building
Field price
Field name$
Field BuildingID
Field x
Field y
Field owner.owner
End Type
castle.building = New building
farm.building = New building
barracks.building = New building
tower.building = New building
richguy.owner = New owner
richguy\firstname="Richie"
richguy\lastname="Rich"
castle\owner=richguy
farm\owner=richguy
barracks\owner=richguy
tower\owner=richguy
castle\name$="The king's home"
farm\name$="The peasant's home"
barracks\name$="The soldier's home"
tower\name$="The guard's home"
castle\buildingid=1
farm\buildingid=2
barracks\buildingid=3
tower\buildingid=4
For building.building = Each building
building\x=Rand(GraphicsWidth())
building\y=Rand(GraphicsHeight())
Next
Print "--------------------------Welcome to my Types example!--------------------------"
Print "The castle is located at address 0x" + Hex$(Int(castle))
Print "The farm is located at address 0x" + Hex$(Int(farm))
Print "The barracks is located at address 0x" + Hex$(Int(barracks))
Print "The tower is located at address 0x" + Hex$(Int(tower))
Print ""
For show.building = Each building
Dumpinfo(show)
Next
While Not KeyDown(1)
Cls
drawbuildings()
Flip
Wend
Function drawbuildings()
For building.building = Each building
Select building\buildingid
Case 1
disptext$="C"
Case 2
disptext$="F"
Case 3
disptext$="B"
Case 4
disptext$="T"
Default
disptext$="X"
End Select
Text building\x,building\y,disptext$
Next
End Function
Function DumpInfo(dump.building)
Print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
Print "Name: " + dump\name$
Print "Address inside of the computer's memmory: 0x" + Hex$(Int(dump))
Print "Building type: " + buildingwrapper$(dump\buildingid)
Print "Owner: " + dump\owner\firstname + " " + dump\owner\lastname$
Print "-------------------------------------------------------------------------------"
Print ""
End Function
Function buildingwrapper$(buildingid)
Select buildingid
Case 1
Return "Castle"
Case 2
Return "Farm"
Case 3
Return "Barracks"
Case 4
Return "Tower"
Default
Return "Unknown"
End Select
End Function