SyntaxBomb - Indie Coders

Languages & Coding => Blitz Code Archives => Miscellaneous => Topic started by: Santiago on April 09, 2020, 21:27:25

Title: Assign new ID to a type
Post by: Santiago on April 09, 2020, 21:27:25
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()




Code: [Select]
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
Title: Re: Assign new ID to a type
Post by: Matty on April 09, 2020, 22:15:48
How I would do it:

Code: [Select]
global nextdni;

function new_dni()

nextdni = nextdni + 1
return nextdni

end function
SimplePortal 2.3.6 © 2008-2014, SimplePortal