Assign new ID to a type

Started by Santiago, April 09, 2020, 21:27:25

Previous topic - Next topic

Santiago

DNI = i need a ID for my aircrafts, carriers, objetcs, to save and load game, without lose information about who unit have relation with other unit

so i create a DNI (ID number) to asign to my types.

Type object
   field DNI
  field pivot
end type

o.object = new object
o\dni = new_dni()
o\pivot = createpivot()





Graphics3D 1000,800
While Not KeyHit(1)



RenderWorld
Print "DNI : " + new_dni()
Flip
Delay 100
Wend


Function new_dni()

temp = CreateCube()
nuevo_id = temp
;FreeEntity temp
Return nuevo_id

End Function

Matty

How I would do it:


global nextdni;

function new_dni()

nextdni = nextdni + 1
return nextdni

end function