Skip to content

05. Traits

RhettTR edited this page Jan 16, 2024 · 1 revision

Counters/cards have traits. Traits are the functionality of counters/cards. A trait may delete a counter. A trait may rotate a counter and so on. Some traits can be activated by selecting them in a right-click menu. Other traits give counters/cards intrinsic abilities, like marked when moved or restricted visibility.

Traits lie in the Luau part of the engine. They can be created by the module designer but but there are also pre-made traits that most (all) games use. The pre-made traits are in the Module but overlap with the Engine.

A trait is basically Lua tables with key/value pairs. Some keys are standard so that they can be recognized by the C++ part, like "menuname" which is the traits name in the right-click menu and "menuclick" which is the function called when clicking "menuname". Other keys and their corresponding values can be defined and used by the module designer.

Counter/cards are basically Lua table of many traits. The module designer may define what traits each counter/card has.

Counter/cards also need a representation in the C++ part of the engine because they must be distinguished from each other in GUI operations.

The C++ part must be designed in such a way that it can offer all GUI operations the module designer could need. This includes flipping cards/counters, rotating them, scaling them, deleting them and creating new ones. The C++ part should also offer a wide range of drawing and masking abilities.


The first simple implementation of a few common traits have been done. They show the role of the Luau and the C++ in the design. The goal is a great degree of flexibility for the module designer. The following figure shows how a counter is created and what happens when the user selects to delete a counter. There is a flow back and forth between the Luau part and the C++ part.

traits.jpg

Note that creation of a counter is initiated in the Luau script. The initiation of a delete action starts in the C++ part of the engine (when Delete is selected in the right-click menu). For a full understanding of how this works study the code.

Traits

A separate Counter Window has been created that holds all created counters. The implemented traits are Image ("Flip"), Rotate ("Rotate") and Delete ("Delete").

screen.jpg


CPLUS_INCLUDE_PATH=/usr/include/gtk-3.0:/usr/include/glib-2.0:/usr/lib/x86_64-linux-gnu/glib-2.0/include:/usr/include/pango-1.0:/usr/include/harfbuzz:/usr/include/cairo:/usr/include/gdk-pixbuf-2.0:/usr/include/atk-1.0:/usr/include/graphene-1.0:/usr/lib/x86_64-linux-gnu/graphene-1.0/include;export CPLUS_INCLUDE_PATH

LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu;export LD_LIBRARY_PATH

g++ -Wall -o main main.cpp luau.cpp window.cpp counter.cpp -I/home/me/luau/VM/include -I/home/me/luau/Compiler/include -I/home/me/Utvikling/Alben/grid -L/home/me/luau/build/release -lluauvm -lluaucompiler -lluauast -lisocline -lgtk-3 -lgdk-3 -lgio-2.0 -lgobject-2.0 -lgdk_pixbuf-2.0 -lglib-2.0 -lcairo

Clone this wiki locally