Ooops
October 28, 2020, 11:19:46 PM

Author Topic: Assign new ID to a type  (Read 479 times)

Offline Santiago

  • Sr. Member
  • ****
  • Posts: 276
  • Blitz3d
    • Indiesoft
Assign new ID to a type
« on: April 09, 2020, 09:27:25 PM »
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

Offline Matty

  • Hero Member
  • *****
  • Posts: 1210
    • MattiesGames
Re: Assign new ID to a type
« Reply #1 on: April 09, 2020, 10:15:48 PM »
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