/hide (rewritting to include welcome/farewell messages)

Re: /hide (rewritting to include welcome/farewell messages)

Postby Warren1001 » 04 Jun 2013, 06:14

HETAL wrote:If you do /cmdcreate hide it will put the coding of /hide into your source folder and you can edit the code from that

That doesn't help me, I already have the command made.
Just two little errors.
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: /hide (rewritting to include welcome/farewell messages)

Postby dzienny » 04 Jun 2013, 11:34

It wasn't that far from working. I made some changes to the code to make it work as intended
Spoiler:

Changelog:
Spoiler:

Anyway, I consider it a bug that the hide command doesn't take into consideration farewell and welcome messages. So, I will fix it in some of the next versions. But, the code still may be useful to others if they want to make their own changes to it.

And, I highly advise using Visual Studio C# Express Edition, which is free, for creating custom commands. It makes the process much easier.
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: /hide (rewritting to include welcome/farewell messages)

Postby ismellike » 04 Jun 2013, 15:02

But to remove it with Init, doesn't the command have to be loaded first?
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /hide (rewritting to include welcome/farewell messages)

Postby Conor » 04 Jun 2013, 15:51

ismellike wrote:But to remove it with Init, doesn't the command have to be loaded first?


I'm presuming the 'Init' method for the custom commands will be called before they are added to the Command.all list.

Therefore, it is possible to remove a previous command of the same name from the list, before the new one is added.

I'm not sure if this is the case but because you can do it, I'm guessing this is how.

So it might look like:

Code: Select all
// Some method called when a custom command is loaded using /cmdload.
// The Command passed through the method is the command which will be added.
public void LoadNewCustomCommand(Command cmd)
{
     cmd.Init();
     Command.all.Add(cmd);
}
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: /hide (rewritting to include welcome/farewell messages)

Postby ismellike » 04 Jun 2013, 16:26

nice didn't think about that, I would have a separate command for unloading every command I needed, and then to load them.
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /hide (rewritting to include welcome/farewell messages)

Postby Conor » 04 Jun 2013, 16:33

ismellike wrote:nice didn't think about that, I would have a separate command for unloading every command I needed, and then to load them.


That code isn't something to put in your command btw, it was my representation of what might go on in MCDzienny source when a custom command is added :P

So I don't think you need the seperate command to unload the old ones, if you put it in the Init() method then it will work fine :D
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Previous

Return to Help in Coding

Who is online

Users browsing this forum: No registered users and 6 guests

cron