[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  A plugin that adds snow to the screen.

A plugin that adds snow to the screen.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Sun 26 Dec 2021 09:21 AM (UTC)

Amended on Sun 26 Dec 2021 09:29 AM (UTC) by Fiendish

Message
It should be self-explanatory, but this plugin makes it snow. Just a little fun for the holidays.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="Snow"
   author="Fiendish"
   id="7b3ec26a0b1a9c9b1798adc2"
   language="Lua"
   purpose="Makes snow"
   date_written="2021-12-25 10:30:00"
   requires="5.06"
   version="1.0"
   save_state="n"
>
</plugin>
<script>
<![CDATA[
require "wait"
win = GetPluginID()

function OnPluginClose()
    WindowDelete(win)
end

function OnPluginDisable()
    WindowRectOp(win, 2, 0,0,0,0, 0)
    map = {}
    next_map = {}
end

width = GetInfo(264)
height = GetInfo(263)
WindowCreate(win, 0, 0, width, height, miniwin.pos_center_all, miniwin.create_transparent + miniwin.create_ignore_mouse, 0)
WindowSetZOrder(win, 100000000)
WindowShow(win)
math.randomseed(os.time())
map = {}
next_map = {}

wait.make(
    function ()
        while true do
            for x = 1,width do
                if math.random() > 0.999 then
                    table.insert(map, {x,0})
                end
            end
            next_map = {}
            WindowRectOp(win, 2, 0,0,0,0, 0)
            for _,flake in ipairs(map) do
                local x = flake[1]
                local y = flake[2]
                if y < height then
                    if math.random() <= 0.95 then
                        flake[2] = y + math.random(6,10)
                    end
                    if math.random() > 0.4 then
                        flake[1] = x + math.random(-4,4)
                    end
                    table.insert(next_map, flake)
                end
                local left, top, right, bottom = x-2, y-2, x+2, y+2
                if left > 0 and right > 0 and top > 0 and bottom > 0 then
                    WindowCircleOp (
                        win, 1, left, top, right, bottom,
                        ColourNameToRGB("white"), 0, 1, ColourNameToRGB("white"), 0
                    )
                end
            end
            map = next_map
            Redraw()
            wait.time(0.01)
        end
    end
)

]]>
</script>
</muclient>

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (22,985 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 26 Dec 2021 10:52 PM (UTC)
Message
Very cute!

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


5,311 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]