Scripting School
Would you like to react to this message? Create an account in a few clicks or log in to continue.

New to scripting? We want you!

Official Ventrilo: Host:Apollo.MaxFrag.net Port:3840
TestBed needs our help! Please donate a few dollars to keep it running here!
Have you mastered a specific part of GS2? Create a guide and help others!

You are not connected. Please login or register

Assignment 2

Go down  Message [Page 1 of 1]

1Assignment 2 Empty Assignment 2 Thu May 05, 2011 7:45 pm

David K?



Assignments
1.Format this script:
Code:

for (i = 0; i < passedeffects.tokenize(",").size(); i ++) {
  temp.effect = passedeffects.tokenize(",")[i].tokenize(":");
  temp.effectroll = random(0,100);
  if(effectroll <= effect[0] && effect[1] == "cause"){
    BuffSystem.addbuff(effect[2],effect[3],effect[4],effect[5],effect[6]);
  }
}

^ - I don't have a clue what it does.

2. "seems like the class went from easy to past intermediate"
We should have probably been given funcitons and commands to learn and use them in this... "Hard to use commands we haven't learned from a new programmers point of view"

Never made a tailor script before so first I'm googling and looking around at examples... I have no clue how to start. :]

These are from the commands rtf I have and I suppose should help somehow but so far I don't know how to use them.

colors[index] { the skin color, the coat color, the sleeves color, the shoes color, the belt color }

colors[0] the skin color
colors[1] the coat color
colors[2] the sleeves color
colors[3] the shoes color
colors[4] the belt color

sword the sword image filename of the player
shield the shield image filename of the player
head the head image filename of the player
#5, #5(index) the image filename of the player’s horse
#6, #6(index) the image filename of the npc that is carried by the player
#8, #8(index) the body image filename of the player
Code:

findPlayer("Devil_Lord2").addweapon(this.name);

//#CLIENTSIDE
function onCreated(){

}

function onWeaponFired(){
Doing test stuff here :
}

Failed Attempts:
player.#8("body2.png");
player #8("body2.png");
player#8() = #8("body2.png");


"Note: It's amazing people saying the basic tailor script which so far doesn't seem very basic. " Rolling Eyes

Since the commands textfile didn't help me much, nor did all the examples I found on google.. I'm going to use this that Zeus posted..

Code:

function onActionServerSide(tokens) {
  if (tokens[0] == "/copy") {
    temp.pl = findPlayerByCommunityName(tokens[1]);
      player.body = pl.body;
      player.head = pl.head;
      player.shield = pl.shield;
      player.sword = pl.sword;
      player.colors[1] = pl.colors[1];
      player.colors[2] = pl.colors[2];
      player.colors[3] = pl.colors[3];
      player.colors[4] = pl.colors[4];
      player.colors[0] = pl.colors[0];
    player.attr[1] = pl.attr[1];
      player.chat = pl.chat;
  }
}

//#CLIENTSIDE
function onPlayerChats() {
  if (player.chat.starts("/copy")) {
    temp.tokens = player.chat.tokenize();
    triggerServer("gui", this.name, tokens);
  }
}

Note:
temp.tok = player.chat.substring(4).trim().tokenize();
seems to do the same as: But I don't get what the -1 is doing.. I understand the 4 puts it to the fourth letter.. -1 acts like a delete all the following?
temp.tok = player.chat.substring(4,-1).tokenize();

Basically it's delting /set and making everything else tokenized
tokenized is basically making each word an array without spaces.

Ex.
temp.tok = player.chat.substring(4,-1).tokenize();
player.chat = tok; //since tok is declared temp, I don't need temp. here.

I chat "/set I like to poke things."

it will then set my chat to.

I,like,to,poke,things.

basically tok is an array of strings.
tok = {"I","like","to","poke","things."}

where as tok[2] = "to";
and
tok[0] = "I";

Still working...

Code:

findPlayer("Devil_Lord2").addweapon(this.name);

//#CLIENTSIDE
function onCreated(){

}

function onWeaponFired(){
  //player.#8 = #8(body2.png);
}

function onPlayerChats(){
  if (player.chat.starts("/set")) {
    temp.tok = player.chat.substring(4,-1).tokenize();
    switch (tok[0]){
      case "skin":
      player.colors[0] = tok[1];
      break;
      case "coat":
      player.colors[1] = tok[1];
      break;
      case "sleeves":
      player.colors[2] = tok[1];
      break;
      case "shoes":
      player.colors[3] = tok[1];
      break;
      case "belt":
      player.colors[4] = tok[1];
      break;
    } 
  }
}

This works so far, but I'd like to improve it.



Last edited by David K? on Thu May 05, 2011 9:56 pm; edited 2 times in total

2Assignment 2 Empty Re: Assignment 2 Thu May 05, 2011 9:31 pm

David K?



Saving this for my final w/notes.

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum