[Server] SkyChange: Change Skybox textures with commands.

Author Topic: [Server] SkyChange: Change Skybox textures with commands.  (Read 5097 times)

Download: https://mega.nz/#F!cp0y2ZqJ!n8M7H8vpEvACIY-OGc5AAA


This is my first add-on. After grinding and sleeping a little bit on the job, I managed to create something I can release to the Blockland public.

This is a very simple add-on, here is the usage.

/SkyChange "name of skybox.zip" (You don't need the quotes)

Ex.

/SkyChange Heat2 (You don't need the quotes)

And yes, you can load third-party add-ons and use them with this:

Here is an image of it working with Masterlegodude's TGE_BlueSky Skybox.



NOTE: Add-On is CASE SENSITIVE, so when creating or adding a third-party
skybox, please check to make sure that the .dml file has the same name as the
.zip file. I wasn't sure if TorqueScript includes a ignoreCase function, but this is what I made.

I really hope I didn't do too bad on my first Add-On as it is very simple.

Thanks for all the help bros.

Peace
« Last Edit: February 11, 2017, 11:38:10 AM by blockheadbro »



did you ever play blockland



did you ever play blockland

cant i do command line and gui? why not both?

GUI is faster and don't have to remember the names of the skyboxes. Although, could see some potential things coming out of this, such as changing skybox after X time or X effect. Not bad for first add on.

not bad for your first addon, but not really useful when you could just use the Environment GUI

I can't even download the file, it is blocked by chrome. Use a less stuffty host next time, or put it on blockland glass or something

I can't even download the file, it is blocked by chrome. Use a less stuffty host next time, or put it on blockland glass or something

https://mega.nz/#F!cp0y2ZqJ!n8M7H8vpEvACIY-OGc5AAA changed to mega, thanks for the heads up


Wow by looking through the comments...

Found it Useful somehow

Wow by looking through the comments...

Found it Useful somehow

Why'd you capitalize the 'U' in useful? That's not right...

Hey, at least he made a functioning mod.

I actually like this better than the GUI...

https://mega.nz/#F!cp0y2ZqJ!n8M7H8vpEvACIY-OGc5AAA changed to mega, thanks for the heads up

Ok, I went and checked the code:


$SkyChange::name = "SkyChange";

Did you want to do something with this? It's never used and you can just remove it.


package SkyChange
{
...
};
activatePackage(SkyChange);


It's not necessary to use a package here, just put the function normally.
You use packages if you want to extend a function that already exists, for example making players explode when they jump.


$path = "Add-Ons/Sky_" @ %filename @ "/" @ %filename @ ".dml";      
if(%cl.isSuperAdmin)
{
   
   if(!isFile($path))
   {
      messageClient(%cl, '', "\c5" @ "[SkyChange] " @ "\c2Skybox:\c0 '" @ %filename @ "' not found.");
   }
   else
   {
      setSkyBox($path);
      messageAll('', "\c5" @ "[SkyChange]" @ "\c2 changed skybox to \c5'" @ %filename @ "'");
   }
}


You should use a local variable (with %) here. Global variables (with $) are only for things you want to keep when the function exits.
They're also shared between all add-ons, so if another add-on uses the global "$path" there might be a problem.


function reloadMe()
{
   exec("Add-Ons/Server_SkyChange/server.cs");
}


You should remove things like that before you release an add-on.

Ok, I went and checked the code:


$SkyChange::name = "SkyChange";

Did you want to do something with this? It's never used and you can just remove it.


package SkyChange
{
...
};
activatePackage(SkyChange);


It's not necessary to use a package here, just put the function normally.
You use packages if you want to extend a function that already exists, for example making players explode when they jump.


$path = "Add-Ons/Sky_" @ %filename @ "/" @ %filename @ ".dml";      
if(%cl.isSuperAdmin)
{
   
   if(!isFile($path))
   {
      messageClient(%cl, '', "\c5" @ "[SkyChange] " @ "\c2Skybox:\c0 '" @ %filename @ "' not found.");
   }
   else
   {
      setSkyBox($path);
      messageAll('', "\c5" @ "[SkyChange]" @ "\c2 changed skybox to \c5'" @ %filename @ "'");
   }
}


You should use a local variable (with %) here. Global variables (with $) are only for things you want to keep when the function exits.
They're also shared between all add-ons, so if another add-on uses the global "$path" there might be a problem.


function reloadMe()
{
   exec("Add-Ons/Server_SkyChange/server.cs");
}


You should remove things like that before you release an add-on.

Just a question but why does the code have to look fancy or have to look a curtain way? does it take longer if it has unused stuff or longer commands in? I'm not being a richard about this I'm just asking.

If it works isn't that all that matters?
« Last Edit: February 11, 2017, 05:20:01 PM by Daniel.S »

If everyone follows a set style or similar style it is easy to find mistakes and figure out how things work.