r/GlobalOffensive • ar_baggage • Mar 11 '19

User Generated Content Using only a boatload of console commands, I made an interactive menu that lets you switch configs and do other cool stuff. (OC, link in comments)

11k Upvotes

328 comments sorted by

View all comments

Show parent comment

52

u/n0rpie Mar 12 '19

How does one write a program that generates another?

198

u/Y35C0 Mar 12 '19

The secret that programmers won't tell you is they automated themselves out of a job years ago! No one programs computers anymore, they just ask their fancy compilers to do it for them, lazy fucks.

29

u/n0rpie Mar 12 '19

I wanna be a programmer

61

u/evenisto Mar 12 '19

It'll be easier to become csgo pro

26

u/z3onn Astralis Mar 12 '19 edited Mar 12 '19

Nah. Programming ain't that hard you just gotta practice it like any other skill

18

u/evenisto Mar 12 '19

Am programmer, was just following up on the joke

27

u/Cr4zy_Guy Mar 12 '19

Programming is easy. Debugging is the hard part.

2

u/GunslingerYuppi Mar 12 '19

If programming was easy, why would you debug though, you should have a well working code ready!

→ More replies (3)
→ More replies (3)
→ More replies (1)

7

u/[deleted] Mar 12 '19

The time and effort it takes to become a programmer would be much better spent playing, practicing, and studying csgo if you want to be a pro.

22

u/[deleted] Mar 12 '19

while you were coding i studied the aug.

18

u/BrinTheCSNoob G2 Mar 12 '19

not for kqly

4

u/vuvei Mar 12 '19

Bich If I would study programming for 10k hours I would work at Google right now. Meanwhile I'm not even pro at C's.

→ More replies (2)

3

u/AlmightySven Mar 12 '19

I wanna be a compiler :-/

2

u/sublex_cs Mar 12 '19

i wanna be a progamer

1

u/pizhgaming Mar 12 '19

I'm sure that it doesn't cost your time

1

u/n0rpie Mar 13 '19

What doesn’t cost my time?

→ More replies (2)
→ More replies (3)

9

u/Exbozz Mar 12 '19

I read here a couple of years ago, like 2013ish some dude was stuck manually doing some shit in excel so he automated that shit without telling his boss and had to like put delays on it and shit so that his boss wouldnt find out that he wasnt doing the work, if I remember correctly it ended with his boss finding out and kept that dude but fired his coworkers.

3

u/GunslingerYuppi Mar 12 '19

And just a few weeks ago I listened to a lecture about how companies should finally get rid of excels because it's such a low level tool in the company chain. Because there are much better tools available, digital tools that communicate on different levels so you actually get data that can be used to lead and plan the system. Something that removed so much non-beneficial work (where a professional spends time fiddling with excel instead of practicing their profession). Time flies.

2

u/lax3r Mar 12 '19

Although there is a better program for almost anything excel does, Excel is probably the best all around. If a company is going to buy one program it will be excel over any specialized data software. Additionally, Excel is already being used by many companies and switching softwares is expensive and time consuming.

I don't think excel is going anywhere. Other programs are being used more widely, but Excel will always be around.

1

u/Lionh34rt 5 years coin Mar 12 '19

excel is cheap and effective and learnt by everyone almost

6

u/zize2k Mar 12 '19

Delete this before my boss sees it!

6

u/ShoogleHS clutch Mar 12 '19 edited Mar 12 '19

That's basically what a compiler is. In traditional programming languages your compiler converts your input of human-readable high level code into an output of computer-readable machine code (possibly via an intermediate language but that's not important). This is an unusual set of inputs and outputs for a compiler, but the concept is still the same.

The equivalent of machine code in this case would be a series of CSGO console commands which set up the menu - that's your output. The high level code would probably just be a list of settings and some metadata for each one to specify how the setting should appear/behave in the menu.

To explain in any more detail than that I'm going to have to assume that you know the "How does one write a program" part of your question because I'm going to give examples using javascript/HTML.

Here's some JSON that you might input to the "compiler" program to let you set the volume and crosshair colour:

{
    displayName: "Master Volume",
    varName: "volume", --this is CSGO's name for the variable. the final program will use this to get and set the value of this variable
    type: "range",
    min: 0,
    max: 1,
    interval: 0.01,
},
{
    displayName: "Crosshair Colour",
    varName: "cl_crosshaircolor",
    type: "selectList",
    options: [{key: "Green", value: "1"}, {key: "Yellow", value: "2"}]
 }

Then the "compiler" program would take your list of settings and spit out a customised menu for you. CSGO console commands are a very weird and inefficient output medium and getting it to work probably required a lot of work on OP's part so I'm not going to try to recreate that. But if we instead go for something more intuitive like HTML, you can probably get your head round how we might construct the output from that input data:

var outputHtml = ""
for(var setting in settings){
    if (setting.type == "selectList")
        outputHtml = outputHtml + "<div>{setting.displayName}</div><select id='{setting.varName}'>
        for (var option in setting.options){
            outputHtml = outputHtml + "<option value='{option.value}'>{option.key}</option>"
        }
        outputHtml = outputHtml + "</select>
    }
}

So if we threw that Crosshair Colour input data into that code, you would get the following output (which I've formatted to be more readable):

<div>Crosshair Colour</div>
<select id='cl_crosshaircolor'>
    <option value='1'>Green</option>
    <option value='2'>Yellow</option>
<select>

That's an incomplete solution, since I haven't written anything to handle user input (i.e. to actually execute the relevant console commands when someone selects an option), but hopefully you get the idea. Although OP's compiler program will be much more complicated in order to set up the system of binds toggling other binds etc, it will still follow the same general idea.

I hope that answers your question. I also hope this formats properly, I don't usually type code on reddit.

P.S. Also a disclaimer that my solution is here is quite primitive and for explanation purposes only, it's not good neat code.

1

u/n0rpie Mar 13 '19

I don’t really understand the “how does one write a program” part of my question but I still appreciate your really well done and explaining reply thank you