Jump to content

Gingie's E2 Lessons | Lesson 2 - EGP Crosshair


Recommended Posts

Alright class, take a seat, no talking. Flip your wire mod handbooks to page 69 and give me your undivided attention. 

In today's class we will be learning how to use EGP screens, and I figured what better way to learn than making a cross hair for your screen, to cover that ugly stock GMOD one. 

Step 1:

  • Click new expression to create a new E2.

Step 2:

  • Name your E2
    • If you don't know how, refer to Lesson 1

Step 3:

  • Define your EGP screen's wirelink
    • Your EGP wirelink will be under @inputs, so write E:wirelink after the @inputs line of the new E2.
      • The First letter "E" can be whatever you want, I choose E because its easier to re-type 1000 times when making a big E2.

Step 4: 

  • For this lesson, you wont be needing any of the last 3 lines of the fresh E2, so you can remove them.
    • @persist @outputs and @trigger can be deleted from the E2, not needed but cleans things up.

Step 5:

  • Making the EGP
    • To start off you will need a box
      • This will be the X axis of the crosshair.
    • To make a box refer to the letter you put in the @inputs, for me I chose "E"
      • Write on the next open line of the E2, "E:egpBox()"
    • Next you will need to define the EGP box
      • Inside of the parenthesis put a "1" followed by a comma, so it should look like "1,"
        • The 1 refers to the box's identity, so if you wanted to change the size you would use that number to change its size.
    • Next we need to finish creating the EGP, as is right now it will cause an Error, because it has no defined size or defined "Spawn" area.
      • To finish creating the EGP, we will need to define where the EGP "Spawns" and how big it will be.
        • After the 1, write "vec2(),vec2()" 
          • This will define where it spawns and how big it will be, the first Vec2 is where is starts, and the second is how big it will be.
    • To find where the middle of your screen is you will need to do some quick math. Garrys mod is 1920 x 1080 so we will simply divide 1920x1080 in half and we will be left with the middle of our screen.
      • inside of the first "vec2()" parenthesis write as follows "960,540" it should look something like this  "E:egpBox(1,vec2(960,540),vec2())"
    • Now the EGP has a defined place to spawn, but it doesn't have a determined size. the next "vec2()" is what will define its size.
      • inside the second "vec2()" parenthesis write as follows "15,2" 15 is how long it will be, and 2 is how wide it will be. I choose 15,2 as it seems like a good size for me.
        • it should look something like this now, "E:egpBox(1,vec2(960,540,vec2(15,2))"
    • The first part of the crosshair is done, but if you were to wire this up now, it would show just 1 single line across your screen instead of the 2 a normal crosshair consists of. 
  • Now we have to make a second EGP for the second half of the crosshair. 
    • Repeat the above steps that you took to make the first box, (to save time, you can just copy and paste it)
      • Now you will have 2 boxes, but it will still only show one, because you have yet to define the second EGP's identity
        • Simply change the 1 that comes after "E:egpBox(1,)" to a 2 so now the second half of the code should look something like this "E:egpbox(2,vec2(960,540),vec2(15,2))"
  • To verify that you are doing everything properly, your entire E2's code should look something like this: 
@name Crosshair
@inputs E:wirelink

  • If you haven't noticed yet, if you were to wire this up now, it would still only show 1 line across your screen instead of 2, because both of the boxes are spawning on-top of each-other.
    • Now we don't want to change the first vec2 because that defines where it spawns, and 960,540 is the middle of your screen. 
  • So we want to change the second vec2, since this defines the width and length. simply, reverse the 2 numbers in the second vec2. now your code should look like this: 
@name Crosshair
@inputs E:wirelink


  • reversing the two numbers at the end simply makes it go across the Y axis instead of the X because you made its Width super small and its length super long, instead of the other way around.                  (Check the comments for Part 2 (how to change the color and how to wire) (i ran out of space here and cant type anymore :/)

Part 2:

You might notice, hey these box's are only white, you would be correct. So lets change their color.


Step 1:

  • Take the code you already have and put a space between both of the box's. 
  • In that space write "E:egpColor()"
    • This is the same process as if you were making a new box just instead we are changing its color. 
  • Inside the parenthesis write the index number of the box you wish to change the color of, so it should look like this "E:egpColor(1,)" or "E:egpColor(2,)" depending on which one you want to color. 
  • Next we need to define the color, this is simple, after the comma write  "vec()" so now it should look like "E:egpColor(1,vec())" or "E:egpColor(2,vec())" depending on which one you are coloring.
  • inside of the parenthesis of the vec you want to use the RGB color code of the color you want, for example "vec(0,0,0)" would be black and "vec(0,255,0)" would be green. ETC.
  • Follow the same steps to color the second EGP box and you are done.
  • Your code should look like this now
@name Crosshair
@inputs E:wirelink



But wait, How TF do you wire this thing, I place it down and nothing happens

How To Wire:

  • Go to the EGP v3 tool under wiremod, located under visuals.
    • You don't want to spawn a normal EGP screen however. You want to spawn a HUD EGP screen.
  • Where it says screen type, click it and change it to HUD, like so
  • ughg3Og.png
  • It should look like this now
  • hN4udR2.png
  • Next spawn the EGP HUD, it will look like this 
  • AUxc6fW.png
  • Next spawn your E2
  • Gp6cSxn.png
  • Take out the wiring tool, and aim at the E2, it should pop up with something that says "E[WIRELINK]" (The E will change depending on what you choose to define your EGP Screen)
  • Tz03fw2.png
  • click the E2 and then click on the EGP 
  • DONE!
  • Simply Press E on the EGP screen, and your dank crosshair will pop up like so
  • 6KvzsNp.png
Link to comment
Share on other sites

They will get progressively harder and harder, I cant just go from the basics of E2 to 100 in 2 tutorials. Next tutorial is how to use the money request function, so and after that how to make EGP buttons, then you can pair all 3 of the tutorials and make a gunshop or a donation sign

and so on.

Link to comment
Share on other sites

  • 3 months later...


This topic is now archived and is closed to further replies.

  • Create New...