{code};Basis Functions and Types
Type Rock
Field x,z,y,RockType,Name$
Field model,modeltex,state,maxhits
Field currenthits
Field tooltip$
Field requiredlevel
Field regen
End Type
Type item
Field x,z,y,where,quantity
Field ItemType,SellValue,BuyValue,Sellable
Field name$,tooltip$
End Type
Type Pickable
Field x,z,y,quantity,regenrate,model,modeltex
Field name$,tooltip$
End Type
;rock types
;1 = copper
;2 = tin
;3 = iron
;rock states
;1 full hits
;2 half gone
;3 gone
Function UpdateRock(rock1.rock)
If rock1\RockType = 1
rock1\name$ = "Copper"
rock1\tooltip$ = "This is a minable rock"
rock1\maxhits = 5
rock1\regen = 7
EndIf
If rock1\rocktype = 2
rock1\name$ = "Tin"
rock1\tooltip$ = "This is a minable rock"
rock1\maxhits = 5
rock1\regen = 7
EndIf
If rock1\rocktype = 3
rock1\name$ = "Iron"
rock1\tooltip$ = "This is a minable rock"
rock1\maxhits = 4
rock1\regen = 10
EndIf
If rock1\maxhits >= rock1\currenthits
rock1\state = 1
EndIf
If rock1\maxhits / 2 = rock1\currenthits
rock1\state = 2
EndIf
If rock1\currenthits = 0
rock1\state = 3
EndIf
End Function
Function SetRockType(rock1.rock,roktype)
rock1\rocktype = roktype
UpdateRock(rock1)
End Function
Function MineRock(rock1.rock)
Repeat
.sub
rock1\currenthits = rock1\currenthits - 1
Until rock1\currenthits <= 0
.checksub
If rock1\currenthits > 0
Goto sub
EndIf
Goto checksub
Delay (rock1\regen * 1000)
rock1\currenthits = rock1\maxhits
End Function
{/code}
The above code is a file to include
{code}
Graphics3D 800,600,0,2
Global AppVersion# = .5
Global Copper = 1
Global Tin = 2
Global Iron = 3
rock = True
Include "Basis.bb"
AppTitle ("ZScape Version " + AppVersion#)
WaitKey()
Copper1.rock = New rock
SetRockType(Copper1,Copper)
copper1\currenthits = 5
WaitKey()
.top
If rock = True
MineRock(copper1)
rock = False
EndIf
If KeyHit(28)
Goto next1
EndIf
Goto top
.next1
Cls
Print copper1\currenthits
Delay(3000)
Goto next1
{/code}
Why wont this work?
Type Rock
Field x,z,y,RockType,Name$
Field model,modeltex,state,maxhits
Field currenthits
Field tooltip$
Field requiredlevel
Field regen
End Type
Type item
Field x,z,y,where,quantity
Field ItemType,SellValue,BuyValue,Sellable
Field name$,tooltip$
End Type
Type Pickable
Field x,z,y,quantity,regenrate,model,modeltex
Field name$,tooltip$
End Type
;rock types
;1 = copper
;2 = tin
;3 = iron
;rock states
;1 full hits
;2 half gone
;3 gone
Function UpdateRock(rock1.rock)
If rock1\RockType = 1
rock1\name$ = "Copper"
rock1\tooltip$ = "This is a minable rock"
rock1\maxhits = 5
rock1\regen = 7
EndIf
If rock1\rocktype = 2
rock1\name$ = "Tin"
rock1\tooltip$ = "This is a minable rock"
rock1\maxhits = 5
rock1\regen = 7
EndIf
If rock1\rocktype = 3
rock1\name$ = "Iron"
rock1\tooltip$ = "This is a minable rock"
rock1\maxhits = 4
rock1\regen = 10
EndIf
If rock1\maxhits >= rock1\currenthits
rock1\state = 1
EndIf
If rock1\maxhits / 2 = rock1\currenthits
rock1\state = 2
EndIf
If rock1\currenthits = 0
rock1\state = 3
EndIf
End Function
Function SetRockType(rock1.rock,roktype)
rock1\rocktype = roktype
UpdateRock(rock1)
End Function
Function MineRock(rock1.rock)
Repeat
.sub
rock1\currenthits = rock1\currenthits - 1
Until rock1\currenthits <= 0
.checksub
If rock1\currenthits > 0
Goto sub
EndIf
Goto checksub
Delay (rock1\regen * 1000)
rock1\currenthits = rock1\maxhits
End Function
{/code}
The above code is a file to include
{code}
Graphics3D 800,600,0,2
Global AppVersion# = .5
Global Copper = 1
Global Tin = 2
Global Iron = 3
rock = True
Include "Basis.bb"
AppTitle ("ZScape Version " + AppVersion#)
WaitKey()
Copper1.rock = New rock
SetRockType(Copper1,Copper)
copper1\currenthits = 5
WaitKey()
.top
If rock = True
MineRock(copper1)
rock = False
EndIf
If KeyHit(28)
Goto next1
EndIf
Goto top
.next1
Cls
Print copper1\currenthits
Delay(3000)
Goto next1
{/code}
Why wont this work?