Author Topic: execute("credits.cs")  (Read 1223 times)

Code: [Select]
package BLSonic
{
  function serverCmdcredits(%client)
  {
execute("credits.cs")
}
};
activatePackage(BLSonic);

Does this work if i put execute credits.cs to run it?

1. exec, not execute
2. You don't need it in a package unless you're modifying and already existing function
3. What does credits.cs do?

Message the client the credits of a project im working on (hence my thread in modification discussion)

EDIT:
new server.cs

credits.cs
« Last Edit: January 30, 2015, 10:05:23 AM by releasetheblocks2 »

If credits.cs contains direct messageclient, then yeah, it'll work, but... Why? It's needless fragmentation. Just put the messageclient calls in the servercmdcredits function

i wanted it to be seperated from the code tho.

No, you don't want that.
Creating a new file for seven lines of code is needless fragmentation that doesn't accomplish anything more than make the code harder to follow

you think differently than me and i think differently than you, so i just wanted to ask if that would work, then you responded with alot

you think differently than me and i think differently than you
We think differently because I'm a professional programmer and you're just starting




Yes, it will work. But just because something works doesn't mean it's a good idea. Splitting things into pieces is, in most cases, a good way to organize things and increase readability, but there's nothing to gain by splitting a <10 line function into multiple files. You're just giving yourself more files to look through and maintain
« Last Edit: January 30, 2015, 10:58:33 AM by Headcrab Zombie »

There are 4 things majorly wrong with doing it this way:
1. It creates confusion. Normally when executing things there are no local variables defined, so your code would do nothing. But for some reason when you're executing it inside a function local variables are carried over, as if it was just executing code inside a function.
2. It creates console spam. Every file you execute creates a line in the console, and if you're hosting a server where this function is going to be called frequently, anything you're trying to debug is going to be flooded out by execution messages.
3. It doesn't work in other languages: This is an important one. If you ever plan on programming in other languages, you can't do this kind of stuff. It's best not to do it at all since it's just bad programming practice in general
4. It's totally pointless. It needlessly splits up things into too many files, especially if you're doing this method of execution for more than one thing. Just make a function that does the exact same thing with an argument of %client. No unnecessary files, everything is still just as organized as it was before.

5. This function takes like 150 times longer to execute than the proper one.

5. This function takes like 150 times longer to execute than the proper one.
Also this. It could be used to mass spam your console and also freeze your blockland server.

Also, it would need to be ./Credits.cs to target something in the same folder.

Can someone give me a better explanation of my code please? Or just put it in a
Code: [Select]
thing?

We're saying to put
Code: [Select]
messageClient(%client, '', "\c6 - Credits -");
messageClient(%client, '', "\c5 ATails - Coding");
messageClient(%client, '', "\c6 [Empty Vol. Spot]");
messageClient(%client, '', "\c6 [Empty Vol. Spot]");
messageClient(%client, '', "\c6 [Empty Vol. Spot]");
messageClient(%client, '', "\c6 [Empty Vol. Spot]");
messageClient(%client, '', "\c6 [Empty Vol. Spot]");

into here:
Code: [Select]
package BLSonic
{
  function serverCmdcredits(%client)
  {
     //put code here
  }
};
activatePackage(BLSonic);