Welcome to my Tutorial, There are a few things i will cover In this
---Arithmetic
|-Entitys
|-Sound Playback
|-Timers
|-HoloGrams
|-Color
|-Console Commands
|-Strings
ArithmeticThis is the most basic of all e2 you'll ever learn!
Basic Functions
A+B | It Adds A And B
A*B | It Multiplys A And B
A/B | It Divides A By B
A-B | Subtracts B From A
A^B | A to the B Power
floor(A) | Rounds The Variable down to the closest Integer
round(A) | Rounds A To the nearest whole number
random(A,B) | Finds A Random Value Between A and B A+= 1 | It Adds 1 to A
A-=1 | It Takes 1 Away from A
A==B | Returns If A is equal to B
A!=B | Returns 1 if A isn't equal to B
A>B | Returns 1 if A is greater than B
A<B | Returns 1 if A is less than B
A<=B | Returns 1 if A is less than or equal to B
A=>B | Returns 1 if A is Equal to or greater than BSay you wanted to make a rounded value between 1 and 5.
It would be typed out as,
round(random(1,5))For example, We could make A variable Equal it.
Variable=round(random(1,25))
Not to Hard is it?
Also, Say you wanted to make A Go up 1 when Button==1
if(Button==1){A+=1}Pretty Darn Simple!
Entitys owner() | Finds the Spawnee Of the chip
entity() | Finds The Chip itself
:isWeldedTo()| Finds the item that is welded to the entity
:isPlayer() | Is it a player?
:isOnFire() | Is it on fire?
:isWeapon() | Is it a weapon?
:isFrozen () | Is it Frozen?
:isAdmin() | Is that player a admin?
isSuperAdmin() | Is that player a super admin?
:isCrouching() | Is that player crouching?
:isNPC() | Is it a NPC?
:inNoclip() | Is The player in noclip?
:isUnderWater() | Is it under water?
:isOnGround() | Is it on the ground?
:keyAttack1() | Are they pressing Mouse1?
:keyAttack2() | Are they pressing Mouse2?
:keyUse() | Are they pressing Use?
Lets Say You Wanted to know if your pressing mouse 1
if(owner():KeyAttack1()==1){A=B}Simple Enough?
Also
O=owner()
if(O:inNoclip()){concmd("say Im Nocliping!")}
Simple Eh?
Sound Playback Its alot like entitys
say you wanted to say BLARGH!
Function
if(owner():lastSaid()=="!blargh"){owner():soundPlay(1,0"npc/stalker/go_alert2a.wav")} Now, Explain it!
so we want the Owner ( owner() ) to play the sound ( soundPlay )
The One is the ID
The 0 is the Duration ( 0 = unlimited )
TimersThese are just plain and simple
timer("Name",Duration in milleseconds)
And
if(clk("Name")){A=B}
Example
timer("A2B",5000)
That would make a timer that resets after 5 seconds
if(clk("A2B")){A=B}
So, When A2b resets, A=B
Holo GramsholoCreate(#) - Creates A Holo With the specified number
holoMaterial(#,String) - Sets the material for the holo
holoColor(#,vec(255,255,255)) - Sets the color for the holo
holoParent(#,#) - Parents the holo to another holo or owner()
List of holo modelscone
cube
cylinder
prism
pyramid
icosphere
icosphere2
icosphere3
sphere
sphere2
sphere3
torus
torus2
torus3
plane
tetra
List of high quality holo modelshqcone
dome
dome2 (hollow)
hqcylinder
hqcylinder2
hqsphere
hqsphere2
hqicosphere
hqicosphere2
hqtorus
hqtorus2
ColorUse these to set entity colors and materials
E:setColor(N,N,N) Changes the RGB color of an entity (leaves alpha alone)
E:setColor(N,N,N,N) Changes the RGBA color of an entity
E:setColor(V) Changes the RGB color of an entity (leaves alpha alone), using a vector with values (R,G,B)
E:setColor(V,N) Changes the RGBA color of an entity, using a vector with values (R,G,B). The additional argument sets alpha
E:setColor(V4) Changes the RGBA color of an entity, using a 4D vector with values (R,G,B,A)
For Example
Say You wanted to change your color randomly
Using what we learned before...
R=round(random(1,255))
G=round(random(1,255))
B=round(random(1,255))
owner():setColor(R,G,B
Or You wanted to change your material
owner():setMaterial("models/props_lab/warp_sheet")That would make your player material The star Sheet
My Example For this is,
Code:
@name PropRandomizer
interval(10)
if(first()){entity():soundPlay(1,0,"player/sprayer.wav")}
Randomvar=(round(random(1,5)))
if(Randomvar==1){RandomTxt="models/debug/debugwhite"}
if(Randomvar==2){RandomTxt="models/XQM/CoasterTrack/Special_Station"}
if(Randomvar==3){RandomTxt="pheonix_storms/MetalSet_1-2"}
if(Randomvar==4){RandomTxt="hunter/myplastic"}
if(Randomvar==5){RandomTxt="models/props_lab/warp_sheet"}
if(first()){concmd("say Selecting Random Color , Material And Cost ...")}
Target=entity():isWeldedTo()
Target:setColor(random(150,255),random(150,255),random(150,255))
Target:setMaterial(""+RandomTxt+"")
timer("Delete",2000)
if(clk("Delete")){concmd("say Paint Job Complete! Cost is "+round(random(0,10000))+""), selfDestruct()}
This Code, is Very simple
Just put the E2 on a prop or car.
And it will select a random color.
Then delete itself.
Console Commandswire_expression2_model <model> Changes the E2 model
wire_expression2_reload Reloads all E2 extensions
wire_expression2_debug 0/1 Toggles debug mode
Say you wanted to say IM FLYING OMG When your in Noclip
Code:
if(owner():inNoclip()){concmd("say IM FLYING OMG")}
If your writing a chatbot...
Code:
MeSaid = Command:find("chatbot:")
Command = lastSaid():lower()
if(Command:find("hi") & !MeSaid) {concmd("say ChatBot: Hello "+lastSpoke():name()+".")}
So, Ingame That would look like....
ChatBot: Hello Player.
[/code]
StringThese are also really simple
S:reversed - My Favorite, It flips text
S:explode() - Cuts A string into words
String explodes easy
For my OS Im Writing I use this
Code:
SExplode=S:explode(" ")
Var1=SExplode:string(1):lower()
Var2=SExplode:string(2):lower()
Var3=SExplode:string(3):lower()
Var4=SExplode:string(4):lower()
Var5=SExplode:string(5):lower()
Var6=SExplode:string(6):lower()
Var7=SExplode:string(7):lower()
Var8=SExplode:string(8):lower()
Var9=SExplode:string(9):lower()
Var10=SExplode:string(10):lower()
Yes I Know the Variable says Sexplode
But to make strings work, we need to make the Special
@outputs Variable:string
The same goes for entitys
@outputs Variable:entity
and Vectors
@outputs Variable:vector
And Angles
@outputs Variable:angle
say you wanted to make a text screen say " FART POOP "
Screen=" FART POOP"
A Text screen can also be used for a Os, Such as mine
This took me a hour to write so please respond!
if(Var1=="play"&Enter==1){entity():soundPlay(3,0,Var2)}
So Basically, When I Press Enter and the screens first word is play, It will try to play the sound after it.
-JG