Page 1 of 1

Knorkes Car Traffic System

Posted: 11 Sep 2013, 12:56
by PicassoCT
I distinctly remember a gif, were the great Knorke produced a traffic jam..

Anybody willing/able to show me were to find this lua-wizzardry? The inquisition needs to aquire this for - scientrivic puroses

Re: Knorkes Car Traffic System

Posted: 11 Sep 2013, 13:49
by FireStorm_
I can not help by remembering when it was :-)

http://springrts.com/phpbb/viewtopic.ph ... start=8200

Re: Knorkes Car Traffic System

Posted: 12 Sep 2013, 13:51
by knorke
Will post it when I get home but was not so much wizzardry:
Just units following waypoints.

Re: Knorkes Car Traffic System

Posted: 12 Sep 2013, 14:16
by Funkencool
knorke wrote:Will post it when I get home but was not so much wizzardry:
Just units following waypoints.
Then witchcraft perhaps?

Re: Knorkes Car Traffic System

Posted: 12 Sep 2013, 21:26
by PicassoCT
Image

Re: Knorkes Car Traffic System

Posted: 13 Sep 2013, 10:23
by PicassoCT
post reply..
you came home, but you forgot about code.. oh Knorke..

Thousands died a worrible death because of you not posting..


Image

Re: Knorkes Car Traffic System

Posted: 13 Sep 2013, 15:21
by knorke
MOM IAM SORRY.
I see you already have flying sky bonbons now?
---

At the top you can define many different sets of waypoints:

Code: Select all

local tn = "track1" --L hochstrasse
waypoints[tn] = {}
waypoints[tn][1] = {x=2880 , z=1091}  --1
waypoints[tn][2] = {x=2920 , z=879}  --
...
Not sure why the table is bit silly with the [tn][1] like that, maybe I did not know better at the time?
Make sure each sets of waypoints forms a closed loop.
Units spawn at a random waypoint of the loop and continue from there.

Put your unit names here:

Code: Select all

trafficUnitNames[1] = "redvan"
trafficUnitNames[2] = "whitevan"
trafficUnitNames[3] = "yellowvan"
The strange part with the for-loop is explained by comment and you can just remove it.

wtfisthisshit: :roll:

Code: Select all

function gadget:UnitDestroyed(unitID, unitDefID, teamID, attackerID, attackerDefID, attackerTeamID)
	local un = unitname (unitID)
	--if (un == "whitevan" or un == "redvan" or un == "yellowvan" or un == "yellowbus") then
	if (string.find(un, "tpcar_")) then
		units[unitID] = nil
		nUnits=nUnits-1
A counter how many units are alive or something. Do not know why so strange? But should not be too hard to make it less silly.
/edit:
Ah, I remember. The traffic cars unitdefs were "generated" and all named tpcar_number