Hello OTLanders,
Today I was a little bored and wanted to practice my "coding skills" by creating something unique, at least for me.
I coded an simple "Arrows Minigame" (only client-side), click on video below to see "what is this".
GIF, for better FPS - click here to watch it in video format.
Today I was a little bored and wanted to practice my "coding skills" by creating something unique, at least for me.
I coded an simple "Arrows Minigame" (only client-side), click on video below to see "what is this".
GIF, for better FPS - click here to watch it in video format.
This is standalone module tested and worked as intended on Mehah client, however, it can works on v8 client too, but needs to expose function calledintersects
(fromrect.h
) to Lua.
Disclaimer
What "useful" things can I learn from this?I want to share it because I consider that someone can find it useful or want to learn something, or, whatever.
Remember - this is only client-side code (module), if you want to use it on your server you need to adapt this module, rewrite certain functions to fit your requirements and logic, handle it by server, etc, etc.
However, I think - its an "enough base" for "start".
Any config or instructions..
- Simply "animations";
- Base usage of
intersects
function that checks if certain widgetA is in range of rectangle of certain widgetB;- Base usage of events;
- Base usage of keyBindings inside certain Widget;
- Just to see "how something can be done" and maybe to inspire someone ;
InstallationJust simply openarrowgame.lua
and at the top of the document, edit the variables in the START_GAME_CONFIG table.
For instructions, I've left a few comments insidearrowgame.lua
for better understanding.
And of course, if you want to learn or understand something from it, you'll unfortunately need to read the entire code.
I haven't cleaned up the code too much, so a little bit of rewriting could be done, but I think it's a small amount.
Download & unpack the .rar from attached file, then, drag it into yourclient/modules/
folder ormods
or whatever you use to store modules in your client.
It hasautoload: true
in .otmod file, so it should be loaded properly upon client start, for testing purposes.
You don't need any additional files, UI images required and used by this module are already in pack and I not used any other extra stuff here.
How to make it work on OTClient V8?
You need to "expose" few functions from C++ client source code to .Lua, so..
1) in
2) in
3) I think that's all, however if not - just try to read everything about
1) in
uiwidget.h
needs to be added:
C++:
bool intersects(const Rect rect) { return m_rect.intersects(rect); }
2) in
luafunctions.cpp
in <UIWidget> objects list, needs to be added:
C++:
g_lua.bindClassMemberFunction<UIWidget>("intersects", &UIWidget::intersects);
3) I think that's all, however if not - just try to read everything about
intersects
function from Mehah repository [rect.h](Click) and adapt the code from sources into your V8.Enjoy,
Have a good day!
Have a good day!
Attachments
-
client_arrowgame.rar27.2 KB · Views: 21 · VirusTotal
Last edited: