Random Contraptions

Some random contraptions:
http://img80.imageshack.us/img80/5061/gmbuttes0069.th.jpghttp://img687.imageshack.us/img687/4301/gmbuttes0068.th.jpghttp://img101.imageshack.us/img101/9606/gmbuttes0067.th.jpghttp://img517.imageshack.us/img517/9986/gmbuttes0066.th.jpghttp://img256.imageshack.us/img256/2390/gmbuttes0065.th.jpg
http://img441.imageshack.us/img441/538/gmbuttes0064.th.jpghttp://img88.imageshack.us/img88/9440/gmbuttes0063.th.jpghttp://img688.imageshack.us/img688/5764/gmbuttes0062.th.jpghttp://img694.imageshack.us/img694/305/gmbuttes0061.th.jpg
When I’m saying they’re random, I’m saying they are random. I’ve really run out of things I want to build, but I still wanted to be creative and have something to do in garrysmod. That led me to make a fairly simple e2 that spawns random props from a list.

The objective is pretty simple, I can use whatever wire or construction tools I like, but I only use the props the chip spawns. It provides a fun little challenge.

If you want to give it a try, here’s the e2 I used to spawn the props - it has three commands:
!pc # - Set the number of props to be spawned to #
!pspawn - Spawns the number of props you set
!wspawn - Spawns 4, 6, or 8 wheels of one type from the wheel list.


@name Random Props (!)
@inputs 
@outputs Debug
@persist AR:array LS:string PC N Proplist:array Wheellist:array Active
@persist WT
@trigger 

if(first() | duped())
{
    runOnChat(1)
    Proplist[1, string] = "models/props_vehicles/apc_tire001.mdl"
    Proplist[2, string] = "models/Combine_Helicopter/helicopter_bomb01.mdl"
    Proplist[3, string] = "models/props_borealis/borealis_door001a.mdl"
    Proplist[4, string] = "models/props_borealis/bluebarrel001.mdl"
    Proplist[5, string] = "models/props_c17/canister_propane01a.mdl"
    Proplist[6, string] = "models/props_c17/concrete_barrier001a.mdl"
    Proplist[7, string] = "models/props_trainstation/clock01.mdl"
    Proplist[8, string] = "models/props_c17/door02_double.mdl"
    Proplist[9, string] = "models/props_c17/FurnitureBathtub001a.mdl"
    Proplist[10, string] = "models/props_c17/FurnitureCouch001a.mdl"
    Proplist[11, string] = "models/props_c17/FurnitureCouch002a.mdl"
    Proplist[12, string] = "models/props_c17/FurnitureFridge001a.mdl"
    Proplist[13, string] = "models/props_c17/FurnitureRadiator001a.mdl"
    Proplist[14, string] = "models/props_c17/gravestone001a.mdl"
    Proplist[15, string] = "models/props_c17/gravestone002a.mdl"
    Proplist[16, string] = "models/props_c17/gravestone003a.mdl"
    Proplist[17, string] = "models/props_c17/gravestone004a.mdl"
    Proplist[18, string] = "models/props_c17/Lockers001a.mdl"
    Proplist[19, string] = "models/props_c17/oildrum001.mdl"
    Proplist[20, string] = "models/props_c17/pulleywheels_large01.mdl"
    Proplist[21, string] = "models/props_c17/signpole001.mdl"
    Proplist[22, string] = "models/props_combine/headcrabcannister01a.mdl"
    Proplist[23, string] = "models/props_wasteland/medbridge_post01.mdl"
    Proplist[24, string] = "models/props_docks/channelmarker_gib02.mdl"
    Proplist[25, string] = "models/props_c17/FurnitureWashingmachine001a.mdl"
    Proplist[26, string] = "models/props_docks/channelmarker_gib04.mdl"
    Proplist[27, string] = "models/props_docks/dock01_pole01a_128.mdl"
    Proplist[28, string] = "models/props_interiors/BathTub01a.mdl"
    Proplist[29, string] = "models/props_interiors/Furniture_Couch01a.mdl"
    Proplist[30, string] = "models/props_interiors/Furniture_Couch02a.mdl"
    Proplist[31, string] = "models/props_interiors/refrigerator01a.mdl"
    Proplist[32, string] = "models/props_wasteland/controlroom_filecabinet001a.mdl"
    Proplist[33, string] = "models/props_junk/TrashBin01a.mdl"
    Proplist[34, string] = "models/props_junk/TrashDumpster02b.mdl"
    Proplist[35, string] = "models/props_junk/TrashDumpster01a.mdl"
    Proplist[36, string] = "models/props_lab/blastdoor001a.mdl"
    Proplist[37, string] = "models/props_trainstation/trashcan_indoor001a.mdl"
    Proplist[38, string] = "models/props_wasteland/controlroom_filecabinet002a.mdl"
    Proplist[39, string] = "models/props_wasteland/laundry_cart001.mdl"
    Proplist[40, string] = "models/props_wasteland/laundry_cart002.mdl"
    Proplist[41, string] = "models/props_wasteland/laundry_basket001.mdl"
    
    Wheellist[1, string] = "models/xeon133/offroad/off-road-20.mdl"
    Wheellist[2, string] = "models/xeon133/offroad/off-road-30.mdl"
    Wheellist[3, string] = "models/xeon133/offroad/off-road-40.mdl"
    Wheellist[4, string] = "models/xeon133/offroad/off-road-50.mdl"
    Wheellist[5, string] = "models/xeon133/offroad/off-road-60.mdl"
    Wheellist[6, string] = "models/xeon133/offroad/off-road-70.mdl"
    Wheellist[7, string] = "models/xeon133/offroad/off-road-80.mdl"
    Wheellist[8, string] = "models/xeon133/racewheel/race-wheel-30.mdl"
    Wheellist[9, string] = "models/xeon133/racewheel/race-wheel-35.mdl"
    Wheellist[10, string] = "models/xeon133/racewheel/race-wheel-40.mdl"
    Wheellist[11, string] = "models/xeon133/racewheel/race-wheel-45.mdl"
    Wheellist[12, string] = "models/xeon133/racewheel/race-wheel-50.mdl"
    Wheellist[13, string] = "models/xeon133/racewheel/race-wheel-55.mdl"
    Wheellist[14, string] = "models/xeon133/racewheel/race-wheel-60.mdl"
    Wheellist[15, string] = "models/xeon133/racewheel/race-wheel-65.mdl"
    Wheellist[16, string] = "models/xeon133/racewheel/race-wheel-70.mdl"
    Wheellist[17, string] = "models/xeon133/racewheel/race-wheel-75.mdl"
    Wheellist[18, string] = "models/xeon133/racewheel/race-wheel-80.mdl"
    Wheellist[19, string] = "models/props_vehicles/tire001a_tractor.mdl"
    Wheellist[20, string] = "models/props_vehicles/tire001b_truck.mdl"
    Wheellist[21, string] = "models/props_vehicles/tire001c_car.mdl"
}

if(chatClk(owner()) & (owner():lastSaid():left(3):lower() == "!pc"))
{
    AR = owner():lastSaid():explode(" ")
    PC = AR[2, string]:toNumber()
    print("Numprops = " + PC)
}

if(chatClk(owner()) & (owner():lastSaid():left(7):lower() == "!pspawn") & !Active)
{
    Active = 1
    N = PC
    print("Running")
    timer("spawn", 1000)
}

if(chatClk(owner()) & (owner():lastSaid():left(7):lower() == "!wspawn") & !Active)
{
    Active = 1
    N = floor(random(3)+2)*2
    WT = floor(random(Wheellist:count()))+1
    print("Running")
    timer("wspawn", 1000)
}

if(clk("spawn"))
{
    concmd("gm_spawn " + Proplist[floor(random(Proplist:count()))+1, string])
    N--
    if(N > 0)
    {
        timer("spawn", 1000)
    }
    else
    {
        Active = 0
        print("finished!")
    }
}
if(clk("wspawn"))
{
    concmd("gm_spawn " + Wheellist[WT, string])
    N--
    if(N > 0)
    {
        timer("wspawn", 1000)
    }
    else
    {
        Active = 0
        print("finished!")
    }
}


I dig the hovertank thing

Yeah, I dig that hovertank and the big mech. But I do say they are pretty random.

Trying to spice up the gmod experience there hey sestze. nice stuff.

Sestze, this is some badass shit you’ve gon and made. :colbert:

Funny chip, good if someone is really bored.

I like that jeep :3

Fun chip you have there! I have to go make one now. (I have an inexplicable dislike of using anyones code but mine. I honestly dont know why.)

I’m the same way, Balto.

The chip and the idea are AWSOME! Great idea. But… it doesn’t work for me, it says its running after i did !pc 30 and !pspawn, but when it says that it’s finished there’s no single prop on the map. Can you help me with that? because i’d would be rather awsome to build with random stuff!

you need to have expression2 concmd enabled.

to do this, type wire_expression2_concmd 1 in console.

Thanks! Ill test it right now.

If its completely random, how do you keep getting the same parts to put on either side of your contraption?

You don’t necessarily have to use all of the props it spawns. Just skip through until you get what you need.

There’s 41 props, and I’m spawning 30 at random.

You’d think to yourself “well, it’d be possible that you’d have only one of each prop, with 11 left over!”, but that’s not necessarily true.

Let’s look at a system where we are picking 4 objects from a pool of 5 with replacement. You’d have a probability of 4/5 of picking a unique object on the first pick, 3/5 on the second, 2/5 on the third, and 1/5 on the fourth. Add to that the possiblity of there being five flavors of possible unique leftovers, and you have:
4/5 * 3/5 * 2/5 * 1/5 * 5c1 = .192
or a 19.2% chance of getting all unique objects.

So if we expand that example to 30 props out of 41 uniques:
30/41 * 29/41 * 28/41 * 27/41 * … * 1/41 * 41c11 = 30!/(41^30) * 41!/(11! * (30!)) = 41! / (41^30 * 11!) = 3.4654 * 10^-7

or, uh, 0.000034654%.

There’s your answer.

That being said, I try to use as many props as I can, and I don’t spawn props and put them in the contraption.

:psyboom:

Anyway this is pretty cool, but I am disappointed because originally I thought it automatically moved and mirrored them into those formations :saddowns:

Cool story bro?

Lolz. J/k. Sestze I just have to say that you do way to much to prove yourself right. But I guess that’s why your awesome too.

(it doesn’t require effort if you’ve gotten higher education)

you should have included in the op that concmd needs to be on for yourself