CloudSixteen/Clockwork — pull request #8 by SpencerSharkey (2013-07-11 19:59:33+00:00)
Title: DermaRequest Library

DermaRequest Library
=====
*A simple library that adds the ability for the server to easily request strings from the client. It can also be used to push Derma message boxes to players!*

## Usage
There are currently two simple functions in the DermaRequest.* library.
```RequestString(Player ply, String title, String question, String default, Func Callback)```
```Message(Player player, String message, String title, String buttontext)```

## Examples
The following example adds a command named FavoriteColor, which when ran will request from the player their favorite color using the DermaRequest library. Specifically, this example uses the ```RequestString```
```lua
local COMMAND = Clockwork.command:New("FavoriteColor");
COMMAND.tip = "Asks you a simple question!";
COMMAND.flags = CMD_DEFAULT;

-- Called when the command has been run.
function COMMAND:OnRun(player, entity)
Clockwork.dermaRequest:RequestString(player, "Title of DFrame", "What is your favorite color?", "", function(text)
Clockwork.player:Notify(player, "You told the server your favorite color is: "..text..".")
end)
end;

COMMAND:Register();
```

The next example makes it known to a player that flashlights are disabled. This uses the ```Message``` method.
```lua
-- Called when a player switches their flashlight on or off.
function Schema:PlayerSwitchFlashlight(player, on)
Clockwork.dermaRequest:Message(player, "Ouch! The light hurts... stop turning it on.", "No Flashlights.", "I'm Sorry")
return false;
end;
```