Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Plugins ➜ 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 page


Posted by Fiendish   USA  (2,533 posts)  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
Top

Posted by Nick Gammon   Australia  (23,102 posts)  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
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.


6,436 views.

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

Go to topic:           Search the forum


[Go to top] top

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