Tech Lounge > Programming

Learning Simple E2 with Kräsher!

<< < (2/8) > >>

Krasher:
Simple HologramThis is a LITTLE bit more advanced, :P.
Full Code:
--- Code: ---@name Tutorial E2 5
@persist Timer
# This E2 makes a cube holo that spins :D #
interval(0.5)
Me = owner()
Chip = entity()
T = Timer
Timer = Timer+1*1
if(first()) {holoCreate(1)}

holoModel(1,"cube")
holoAng(1,ang(T,T,T))
holoPos(1,Chip:pos()+vec(0,0,45))
holoColor(1,vec(255,200,0))
holoScale(1,vec(1,1,1))

--- End code ---
Variation of Color:Change:

--- Code: ---holoColor(1,vec(255,200,0))
--- End code ---
To:

--- Code: ---holoColor(1,vec(random(255),random(255),random(255)))
--- End code ---
This sets the holo to rave light.
Explanation:Timer is a variable, that means it is a number that can mean anything depending on the string it is set in.
Timer = Timer+1*1 adds 1 to the variable every interval.
holoCreate states that we are creating a hologram.
holoModel(1,"cube") states that this hologram will be in the shape of a cube :D.
holoAng(1,ang(T,T,T)) sets the angle of the hologram (You can put any numbers in place of T,T,T.)
holoPos(1,Chip:pos()+vec(0,0,45)) states the position of the holo. (in X,Y,Z, format.)
holoColor(1,vec(255,200,0)) states the color of our holo. (in RGB format.)
holoScale(1,vec(1,1,1)) states the scale of the holo. (in length, width, depth, format.)

Frank:

--- Quote ---@name Tutorial E2 2
# This E2 changes your material #
owner():setMaterial("phoenix_storms/chrome")
--- End quote ---

With the above one, you only change your skin ONCE.

BUT, by making some simple modifications, you can get it to switch between different materials by just typing a tiny chat command, see:


--- Quote ---@name Tutorial E2 2
# This E2 changes your material #
interval(20)
if(owner():lastSaid()=="!chrome"){owner():setMaterial("phoenix_storms/chrome")}
if(owner():lastSaid()=="!blkchrome"){owner():setMaterial("phoenix_storms/black_chrome")}
--- End quote ---

We make an 'if' statement, where "if   'x=z'    'z=c' ".

That means, for example, that if 'x' equals to 'z', 'z' will equal to 'c'.


How to make it easier?

--- Quote ---If I had U$S2000, I'd buy an awesome computer.
--- End quote ---

Now, let's make it E2!

--- Quote ---If (I had U$S==2000) {Can buy an awesome computer}
--- End quote ---

--- Quote ---if(Money==2000){AwesomePC==Affordable}
--- End quote ---

I hope you understand it.

You can also make statements shorter, I'll show you:

--- Quote ---@name Tutorial E2 2
# This E2 changes your material #
interval(20)
if(owner():lastSaid()=="!chrome"){owner():setMaterial("phoenix_storms/chrome")}
if(owner():lastSaid()=="!blkchrome"){owner():setMaterial("phoenix_storms/black_chrome")}
--- End quote ---

Can be reduced to:


--- Quote ---@name Tutorial E2 2
# This E2 changes your material #
interval(20)
LS = owner():lastSaid()
if(LS=="!chrome"){owner():setMaterial("phoenix_storms/chrome")}
if(LS=="!blkchrome"){owner():setMaterial("phoenix_storms/black_chrome")}
--- End quote ---



I hope it was useful.

Krasher:
I will go over commands later Frank...

me4488:
nice stuffz here  ::)

Krasher:

--- Quote from: me4488 on April 10, 2010, 10:23:28 PM ---nice stuffz here  ::)

--- End quote ---
Thank you.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version