Check this out:
You paid $3.5K for a truck that should give you 100K miles with minimum maintenance, more if you put some effort in to keeping it. Even if it eats something large these trucks are comparatively simple compared to new stuff, parts are everywhere and repairs are relatively cheap. A lot of the maintenance can be done in your driveway if you have the time and the patience. Keep the rust away and drive it until you can no longer bear the sight of it. Junk it for $500 at the end and walk away satisfied.
Not so the new truck. At $40K you'd have to drive 1 million miles plus to break even and maintenance is likely to cost you a lot more.
Let's look at it another way. Suppose you were to take your $3.5K and another $4.5K and use it for a down payment on a new 5 Gen. Your payment would rock in at something like $1K per month, $12K per year, 5 years minimum and the value of the truck would drop with every single payment you made.
$12K per year is more than the craziest modder on this board spends on their truck every year - at least after the first year. $12K you don't spend for 4 years = $48K you've saved by buying your 3rd gen.
My Dad always said that the time to buy a new car was when the cost of repairs each month exceeded the cost of payments on a new car. This never happens unless you buy some stupid European thing and particularly never happens with Toyotas.
I think you made a good buy.