So like in c++, set your flags up like so.
- Code: Select all
BIT_Walk = 1 << 0;
BIT_Swim = 1 << 1;
BIT_Door = 1 << 2;
then set the flags like so:
- Code: Select all
polyflag=BIT_Walk | BIT_Door
--or
polyflag=1<<0 | 1<<2
then you can use functions like this example from the navmesh editor being developed to add or remove the bitflag from the variable:
- Code: Select all
function setAreaPolyFlag(_area, _flag, _state)
if(_state == true)then
props_area.AreaTypes[_area].polyflag = props_area.AreaTypes[_area].polyflag | _flag;
elseif(_state == false)then
props_area.AreaTypes[_area].polyflag = props_area.AreaTypes[_area].polyflag & ~_flag;
end
navmesh.areaTool.setAreaBuildPolyFlags(_area-1, props_area.AreaTypes[_area].polyflag)-- -1 to start from zero for c++
end
You can even do bit tests in lua:
- Code: Select all
if( (currentAreaProps.polyflag & BIT_Walk) == BIT_Walk)then
end
Just wanted to share the cool new way of coding in lua