Author Topic: Learning Simple E2 with Kräsher!  (Read 3488 times)

0 Members and 1 Guest are viewing this topic.

Offline Peetah

  • Unnecessary encouragement guy.
  • Übermensch
  • *****
  • Posts: 877
  • Karma: +16/-4
  • Gender: Male
  • And God saw that it was Good.
    • View Profile
    • Youtube Account
Re: Learning Simple E2 with Kräsher!
« Reply #30 on: May 16, 2010, 02:53:01 PM »
gets pretty complicated once you get to the animating the bones part. use a timer.





Offline Krasher

  • -=RND Help Center=-
  • WaffleBBQrz
  • ******
  • Posts: 2764
  • Karma: +75/-47
  • Gender: Male
  • PM me if you have questions.
    • View Profile
    • Forum Page
Re: Learning Simple E2 with Kräsher!
« Reply #31 on: June 30, 2010, 06:49:57 PM »
Arrays
Lets do some simpler arrays, maybe one that prints every players name in the server :D.

Full Code:
Code: [Select]
@name Array Test
@persist [Array Players]:array Total

runOnChat(1)

LastS=owner():lastSaid():lower()

Total=findByClass("player")
Players=findToArray()

for(I=1,Players:count()){
    Array[I,string]=Players[I,entity]:name()

if(LastS=="/run"){
for(K=1, Array:count()){
    print(Array[K,string])
        }
    }
}
Explanation:
runOnChat(1) makes the e2 trigger-able by the chat.
LastS=owner():lastSaid():lower(), this is a variable I made that will make life easier.
findByClass("player") is the part where we find all the players.
findToArray() is the part where we put it into an array. I put mine into a variable. (Players)
for(I=1, Player:count()) this function (for) lets me set up my arrays. I (or 1) is our index, Player:count() is the number of players. So it is basically for(1 to 4) (Implying we have 4 people in the server.)
Array[I,string] tell the e2 that our array 1 (I) will be a string. (Basically saying: Array 1 (or I) is a string)
Players[I,entity]:name() Players will be put into an array. The array tells the e2 that we will classify "Players" as an entity. name() Will get the name of the players.
LastS=="/run" ''=='' means 'Is equal to", Basically this line means, If the players last said is /run.
for(K=1, Array:count()) using K as an index this time, then we just count the number of arrays in our previous index. (Amount of players)
print(Array[K,string]) telling the e2 to print the Array (Index) of K as a string.

If you need further help on Arrays, it is best if you steam message me, PM me, or ask me in-game. Arrays can be hard to understand at first, but they are super easy :P.

-Admin Application-

Follow the rules or I will you.

Offline SheepsAholy

  • Regular Member
  • ***
  • Posts: 211
  • Karma: +8/-2
  • Gender: Male
  • BAAA or GTFO
    • View Profile
Re: Learning Simple E2 with Kräsher!
« Reply #32 on: July 01, 2010, 12:24:05 AM »
Krasher I'd rather do this:

Code: [Select]
@name Array Test
@persist Players:array

runOnChat(1)
LS = owner():lastSaid():explode(" ")
Clk = chatClk(owner())

if(Clk & LS:string(1) == "/r")
{
findByClass("player")
Players = findToArray()
}

if(Clk & LS:string(1) == "/i")
{
print(Players[LS:string(2):toNumber(),entity]:name())
}

Players:array
will hold all the players the chip finds in the "/r" if-statement (the first if line.)
If you type /r again all the indexes of the old will be replaced with the new find values.

LS = owner():lastSaid():explode(" ")
this is similar to krashers but instead of :lower() its :explode(" ") which turns it into an array.

This array makes an index for each space you type and the value for that index is anything but a space. Example:

this is a test.

Index|Value
1: this
2: is
3: a
4: test.

Clk = chatClk(owner())
You don't have to use this, I do in all my chat cmd e2's just because I believe its good coding practice.

Similar to above, when you have used the /r cmd it will make the Players:array equal to what it finds. And when you type /i <value> it will print what it finds at that index. Example again:

Index | Name
1. Bob
2. Joe
3. Dirt

/i 1 = Bob
/i 2 = Joe
/i 3 = Dirt

Any value under 1 and any value over 3 will still run the chip and print a "space"

also if you do something like below:

/i tom

it will also run the chip but will not be of much help.

but the way the /r is coded, it will run even if you do this:

/r tom

I'm not much of the explainer online meet me ingame and I'm more of a help ;)

P.s sry about stealing you thread krasher :P
« Last Edit: July 01, 2010, 12:26:10 AM by SheepsAholy »




Offline Krasher

  • -=RND Help Center=-
  • WaffleBBQrz
  • ******
  • Posts: 2764
  • Karma: +75/-47
  • Gender: Male
  • PM me if you have questions.
    • View Profile
    • Forum Page
Re: Learning Simple E2 with Kräsher!
« Reply #33 on: July 01, 2010, 12:30:33 AM »
its k

Arrays are hard to explain online in text
lol xP
-Admin Application-

Follow the rules or I will you.

Offline SheepsAholy

  • Regular Member
  • ***
  • Posts: 211
  • Karma: +8/-2
  • Gender: Male
  • BAAA or GTFO
    • View Profile
Re: Learning Simple E2 with Kräsher!
« Reply #34 on: July 01, 2010, 12:35:22 AM »
its 3 a.m. in the morning I'm to sleepy to explain anything accurate online. Had to type that stuff above 3 times and even edit that once to get it decent lol.




Offline Krasher

  • -=RND Help Center=-
  • WaffleBBQrz
  • ******
  • Posts: 2764
  • Karma: +75/-47
  • Gender: Male
  • PM me if you have questions.
    • View Profile
    • Forum Page
Re: Learning Simple E2 with Kräsher!
« Reply #35 on: July 01, 2010, 01:24:18 AM »
dude

same here

just thought I should update a bit

I was thinking the whole time while writing, "this isn't gonna make any sense"
-Admin Application-

Follow the rules or I will you.