Custom Train Tracks: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (→‎Functions: add plan)
m (→‎Functions: update api)
Line 25: Line 25:
-- nodes is a table of trainNodes
-- nodes is a table of trainNodes


track = TrainTrack(...trainNode node) -- createTrack(...trainNode node) -- multiple nodes in the arguments
track = TrainTrack(table nodes) -- createTrack(table nodes)
track = TrainTrack(table nodes) -- createTrack(table nodes)


Line 31: Line 30:
table track:getNodes() -- get all nodes
table track:getNodes() -- get all nodes


table track:getNode(int nodeIndex) -- get individual node
Vector3 track:getNode(int nodeIndex) -- get individual node position. use case ???
track:insertNode(trainNode node, int nodeIndex) -- set individual node. if nodeIndex>numNodes, error.
track:removeNode(int nodeIndex) -- removes an individual node. could be replaced with track:removeNode
-- what happens to the nodes (nodes > nodeIndex) after the node delete?
-- perhaps get rid of individual node manipulation, but then you have to sync all the nodes
-- would be wasteful for huge tracks
-- the nodeIndexes would change for all the nodes later on in the array


-- Default track
-- Default track

Revision as of 13:30, 14 July 2016

This branch makes it possible to make your own train tracks.

Status Work in progress
Branch custom-train-tracks
Branch version 1.6

Functions

-- trainNode is a Vector3, or table of three coordinates
-- nodes is a table of trainNodes

track = TrainTrack(table nodes) -- createTrack(table nodes)

track:setNodes(table nodes) -- set all nodes, changing the size
table track:getNodes() -- get all nodes

Vector3 track:getNode(int nodeIndex) -- get individual node position. use case ???

-- Default track
track = TrainTrack.getDefault(int trackID) -- only situation IDs are used
-- These tracks can be manipulated like the above

-- These functions already exist, but I'm not sure how these lengths are used or what they are fore
float track:getLength() -- getTrainTrack(track)
bool track:setLength(float length) -- setTrackLength(track, float length)

-- No train track ID functions. Completely get rid of IDs. Thinking about it now, it feels SAMPish
-- REMOVED: track:getTrackID()    getTrackID(track)

-- No train "number of nodes". Number of nodes are automatically enlarged or shorter

Old Functions

(will be removed once new functions are implemented)

Media

Issues

  • There may be some issues (relating to infinite loops) if a track runs across another or crosses another
    • Infinite loop occurs at 006f8fda, see call stack. Occurs when a track of two nodes have same x/y, but different z. Only occurs for tracks that ONLY consist of nodes atop each other.
  • Tracks may not be cleaned up
  • int CWorldSA::FindClosestRailTrackNode needs updating. It needs to use MAX_TOTAL_TRACKS and the train manager. See 09e3ee8f25810c17742

Re-merge

Status Abandoned
Branch custom-train-tracks-old (renamed from custom-train-tracks)
Branch version 1.4

The old custom-train-tracks branch contains commits cherry-picked and other merges from the 1.4 branch. The first task in updating this branch is to distinguish between merge commits and actual branch commits:

This means that there are only four commits that need to be merged into the new branch. There is currently a packet issue introduced by the merge that needs to be fixed.