DOWNLOAD LATEST RELEASE HERE (v1.0)
Ever wanted to draw pictures in your Special Messages? Well, now you can.
NASH (named after Modernist painter and artist of the Great War, Paul Nash) creates a static canvas into which you can draw text and simple shapes. This canvas is rendered as an HTML IMG tag inside your Special Message.
- Download the latest release and unzip it.
- Copy the contents of the file
nash_min.lua
, paste it into the Lua Script Editor, and click RUN. - After a short pause, you should see the message, "NASH has been successfully installed!" This means that NASH has been installed persistently into your scenario, and you can now use it inside your scripts.
If you'd like to verify that NASH has been installed properly, open up the Lua Script Editor and type NASH_Test()
in the box. (Make sure you've created at least one side in the scenario.) When you click RUN, you should see a test page come up in a new Special Message.
-- create a new NASH canvas at 512x400 resolution
local canvas = NASH:New(512, 400)
-- define some commonly used colors
local color_black = RGB(0, 0, 0)
local color_white = RGB(255, 255, 255)
--render a nice horizontal gradient
for i=0, canvas.width-1 do
local intens = 255*i/(canvas.width-1)
local color = RGB(intens, 0, 255)
canvas:Line(i, 0, i, canvas.height-1, color)
end
--put a soft bump in the center
canvas:BlendMode(NASH.BLEND_ALPHA)
canvas:SoftCircleFill(256, 200, 200, RGBA(255, 255, 255, 127) )
-- now display some text inside a box for contrast
canvas:BlendMode(NASH.BLEND_NORMAL)
local text = "NASH v"..NASH.VERSION
local text_w, text_h = canvas:TextWidth(text)/2, canvas:TextHeight()
canvas:BoxFill(256-text_w, 198, 256+text_w, 200+text_h, color_black)
canvas:Print(text, 256, 200, color_white, NASH.ALIGN_CENTER)
text = "The graphics library for COMMAND: MODERN OPERATIONS"
text_w = canvas:TextWidth(text)/2
canvas:BoxFill(254-text_w, 348, 258+text_w, 350+text_h, color_black)
canvas:Print(text, 256, 350, color_white, NASH.ALIGN_CENTER )
--finally, render it to a special message (make sure you've created a side!)
ScenEdit_SpecialMessage("playerside", canvas:Render().."<br/>More HTML here is also okay." )
A full API reference of all available functions can be found here, and is also included as a PDF in the latest release.
NASH makes use of the display capabilities of the HTML renderer built into Command: Modern Operations. When rendered, the canvas is converted to a PNG image, then encoded to Base64 and injected into an IMG tag.
See instructions for building NASH from scratch below.
- Install the WSL
Open a new PowerShell window with Administrator privileges, and run the following command:
wsl --install
When complete, restart your computer.
- Install the prerequisites
From the Ubuntu Bash shell, run the following command:
sudo apt update && sudo apt-get install python3 npm && sudo npm install -g luamin
./build.sh
The compiled, minified Lua code will be placed in release/nash_min.lua
. This is suitable for adding to your scenario by pasting it into the Lua Code Editor and clicking RUN as the final step in the scenario creation process.
./build.sh debug
This will produce compiled but unminified Lua code in debug/nash_debug.lua
. This is mostly useful in development for debugging.
- LuaBit
- Lua base64 encoder/decoder
- lua-pngencoder
- @p01 (efficient triangle fill code)