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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Plugins
➜ miniwindow tetris
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Thu 16 Jun 2011 06:29 PM (UTC) Amended on Thu 16 Jun 2011 06:30 PM (UTC) by Fiendish
|
Message
| After a chat with Nick the other night, I threw this together based on an old test room prog I made for Aardwolf a long time ago. It's tetris in a miniwindow. I think the only thing it's really missing is a box showing the next piece, but I kind of like the suspense of not knowing.
https://aardwolfclientpackage.googlecode.com/svn/trunk/experimental/miniwindow_Tetris.xml |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 16 Jun 2011 11:38 PM (UTC) |
Message
| Very nice Fiendish! It doesn't work if you don't have any accelerators. Change OnPluginInstall to read:
function OnPluginInstall()
-- set up temporary key accelerators
acc_list = AcceleratorList() or {}
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #2 on Fri 17 Jun 2011 12:17 AM (UTC) Amended on Fri 17 Jun 2011 12:21 AM (UTC) by Nick Gammon
|
Message
| This needs reworking:
function OnPluginClose()
-- reset all temporary accelerators
AcceleratorTo("Ctrl+Left", leftAcc or "", sendto.script)
AcceleratorTo("Ctrl+Right", rightAcc or "", sendto.script)
AcceleratorTo("Ctrl+Up", upAcc or "", sendto.script)
AcceleratorTo("Ctrl+Down", downAcc or "", sendto.script)
end
Check out AcceleratorList description.
You need to grab the send-to location from inside square brackets at the end of the line, and use that to decide where to send to when putting the old accelerator back.
eg. This is what you get:
tprint (AcceleratorList ())
Gives:
1="Ctrl+Left = CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'left') [12]"
2="Ctrl+Up = CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'rotate') [12]"
3="Ctrl+Right = CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'right') [12]"
4="Ctrl+Down = CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'drop') [12]"
The keys are not the accelerator keys even, they are numeric. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Fri 17 Jun 2011 01:05 AM (UTC) Amended on Fri 17 Jun 2011 04:53 AM (UTC) by Nick Gammon
|
Message
| Example of extracting accelerator keys:
accels = AcceleratorList ()
if accels then
for _, v in ipairs (accels) do
local keystroke, what, where = string.match (v, "^(%S+) = (.*)%[(%d-)%]$")
if where then
where = tonumber (where)
else
keystroke, what = string.match (v, "^(%S+) = (.*)$")
where = sendto.execute
end -- if
print ("keystroke =", keystroke)
print ("what =", what)
print ("where =", where)
end -- for
end -- if
Gives:
keystroke = Ctrl+Left
what = CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'left')
where = 12
keystroke = Ctrl+Up
what = CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'rotate')
where = 12
keystroke = Ctrl+Right
what = CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'right')
where = 12
keystroke = Ctrl+Down
what = CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'drop')
where = 12
keystroke = Ctrl+B
what = foo
where = 10
keystroke = Ctrl+D
what = CallPlugin ('04d9e64f835452b045b427a7', 'CopyScript', '')
where = 12
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #4 on Fri 17 Jun 2011 03:06 AM (UTC) |
Message
| Game looks like this:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #5 on Fri 17 Jun 2011 04:42 AM (UTC) |
Message
|
Nick Gammon said:
Very nice Fiendish! It doesn't work if you don't have any accelerators. Change OnPluginInstall to read:
function OnPluginInstall()
-- set up temporary key accelerators
acc_list = AcceleratorList() or {}
Thanks, but why is this? I figured it would already return an empty list (i.e {}) instead of nil or otherwise. What is "IsEmpty"?
Quote: You need to grab the send-to location Ack! This is what happens when I make assumptions! |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #6 on Fri 17 Jun 2011 04:43 AM (UTC) |
Message
|
Nick Gammon said:
Game looks like this:
Really, Nick? 0 points? :) |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #7 on Fri 17 Jun 2011 04:49 AM (UTC) |
Message
|
Nick Gammon said: The keys are not the accelerator keys even, they are numeric.
Hmm. That's awkward. Can it be changed? Nevermind, I'll just use your example. I think it should be added to the acceleratorlist docs. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #8 on Fri 17 Jun 2011 04:49 AM (UTC) Amended on Fri 17 Jun 2011 04:50 AM (UTC) by Nick Gammon
|
Message
|
Fiendish said:
Thanks, but why is this? I figured it would already return an empty list (i.e {}) instead of nil or otherwise. What is "IsEmpty"?
It's a VBscript variant value that indicates that the variant is empty. Translated into Lua, that means nil (no variable).
It's a bit of a throwback to the way the glue routines were implemented to take values from the COM objects (themselves generally returning Variants) and turning them into Lua values.
Quote:
Really, Nick? 0 points? :)
I said the game was good, not my playing. ;)
But OK, here is another attempt:
BTW the game needs a "pause" action. If someone pages you, or you get into a fight, you don't want to lose your Tetris game because you can't pause it. (The tall stack was when Lasher was chatting with me).
Oh, and I like the use of coroutines, makes it look nice and clean. Although I await the graphical blocks.
[EDIT] And the music. And the background image. ;P |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #9 on Fri 17 Jun 2011 04:51 AM (UTC) |
Message
|
Fiendish said:
Hmm. That's awkward. Can it be changed? Nevermind, I'll just use your example. I think it should be added to the acceleratorlist docs.
It has been. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #10 on Fri 17 Jun 2011 04:53 AM (UTC) |
Message
|
Quote: And the music. And the background image. ;P
I'll record a wav of me singing "Doo, doo-doo-doo, doo-doo-doo, doo-doo-doo, doo-doo-doo...do-doo, doo, doo doo dooooooo. Doooooo do doooo do do doooooo do doooo doo doo dooo do do-dooo do doo dooo dooo." :D |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #11 on Fri 17 Jun 2011 04:57 AM (UTC) |
Message
| Here is an improved accelerator-list extractor:
local accels = AcceleratorList ()
local taccels = {}
if accels then
for _, v in ipairs (accels) do
local keystroke, what, where = string.match (v, "^(%S+) = (.*)%[(%d-)%]$")
if where then
where = tonumber (where)
else
keystroke, what = string.match (v, "^(%S+) = (.*)$")
where = sendto.execute
end -- if
taccels [keystroke] = { send = what, where = where }
end -- for
end -- if
tprint (taccels)
Output:
"Ctrl+B":
"send"="foo"
"where"=10
"Ctrl+D":
"send"="CallPlugin ('04d9e64f835452b045b427a7', 'CopyScript', '') "
"where"=12
"Ctrl+Down":
"send"="CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'drop') "
"where"=12
"Ctrl+Left":
"send"="CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'left') "
"where"=12
"Ctrl+Up":
"send"="CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'rotate') "
"where"=12
"Ctrl+Right":
"send"="CallPlugin('db6e9ed958c05658b5d7d5ea', 'do_command', 'right') "
"where"=12
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #12 on Fri 17 Jun 2011 05:52 AM (UTC) |
Message
| I think accelerator remembering should be fixed now. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Fiendish
USA (2,534 posts) Bio
Global Moderator |
Date
| Reply #13 on Fri 17 Jun 2011 06:09 AM (UTC) |
Message
| And now, if you put the following file (or another of the same name) in the same directory as the plugin it will play music. :}
https://aardwolfclientpackage.googlecode.com/svn/trunk/experimental/Tetris_theme.wav |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #14 on Fri 17 Jun 2011 10:24 AM (UTC) |
Message
|
wget http://aardwolfclientpackage.googlecode.com/svn/trunk/experimental/Tetris_theme.wav
HTTP request sent, awaiting response... 502 Bad Gateway
2011-06-17 19:23:30 ERROR 502: Bad Gateway.
|
- 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.
36,910 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top