i think you're looking for
InstanceObject if you're just re-using the same object (which would share some attributes of the original) to save memory.
otherwise, the array itself won't necessarily simplify placement but, if you're going to modify/remove/replace the objects, you'll do well to keep track of them (pun intended
![](/images/smilies/happy.gif)
).
without knowing much of your endeavor, see the function inside:
// Project: xcode77Track
// Created: 2020-06-02
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "xcode77Track" )
SetWindowSize( 1080, 720, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1080, 720 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
GLOBAL Size# = 32.0
GLOBAL Rail as Integer
Rail = CreateObjectBox(Size#,4,Size#)
GLOBAL Tracks as Integer []
LayRail(30,100, 0, 100, "south")
LastRail = Tracks[Tracks.Length] `the last section placed
SetCameraPosition(1,100,100,-100)
SetCameraLookAt(1, GetObjectX(LastRail), GetObjectY(LastRail), GetObjectZ(LastRail), 0 )
do
Print( Tracks.Length+1 )
Print( GetCameraAngleY(1) )
Sync()
loop
Function LayRail(Sections, x, y, z , direction$)
for this = 0 to Sections-1
ThisRail = InstanceObject(Rail)
if direction$ = "north" then SetObjectPosition(ThisRail,x,y,this*size#)
if direction$ = "south" then SetObjectPosition(ThisRail,x,y,this*-size#)
if direction$ = "east" then SetObjectPosition(ThisRail,this*size#,y,z)
if direction$ = "west" then SetObjectPosition(ThisRail,this*-size#,y,z)
Tracks.Insert(ThisRail)
next this
EndFunction
...which helps place multiple sections of track while keeping the object numbers stored in an array for future reference.
and,
Tip: this 3D Board has historically been used for dialogue about modelling itself. you'll receive more exposure to inquiries like this using the
Studio or
Classic boards, instead