Filter information

#1

From the town hall we were talking about, @FlameSoulis here is a general filter file I found, I don’t have a lot of time to dedicate to cleaning this up, so I apologize in advance for this being sloppy, but hopefully, it’s at least a little helpful. . They are just some notes I’ve gathered from use, searching around, and going through the C++ code. There will be better info coming, but feel free to ask any info here .

// Having (un)lock rights bypasses the filter unless it’s a physics result.

// If a function is given, but not found, it will reject all edits for those without lock rights

// Filters are a just a function that takes 3 parameters,
// properties: the properties coming in for the edit
// filtertype: What kind of event is being filtered. This is an enumeration, see the types below
// originalProperties: if the original properties were given(see notes below), then these are in this value

// Filter Types
var ADD = 0;
var EDIT = 1;
var PHYSICS = 2;
var DELETE = 3;

/*
Common properties

dimensions
velocity
visible
rotation
gravity
acceleration
damping
color
modelURL
text
lifespan
isEmitting
emitRate
userData
textures
locked
script
serverScripts

*/

// On the c++ side -> args :: inputValues, filterType, currentValues
// Js side -> aka properties, filterType, originalProperties

// A filter returns either false, true, or the properties to let into the edit
// return false; means you aren’t allowing these edits
// return properties; means you are allowing the incoming changes
function filter(properties, filterType, originalProperties) {
if (filterType === DELETE) {
return true;
}

if (filterType === ADD) {
    return true;
}

if (filterType === EDIT) {
    return properties;
}

if (filterType === PHYSICS) {
    return properties;
}

}

// PROPERTIES
// Besides creating the filter, there are some properties that define what gets filtered, and what properties get passed in

// Includes the properties before a change in the callback
// true will include all original properties
// false includes no properties at all
// empty string includes no properties at all
// a valid property in a string includes just that property
// an array of property strings will include those properties
// Note, if this is an Add or Delete, there will be no originalProperties
filter.wantsOriginalProperties = false; // default: false

// Same as the above but specific to zones
filter.wantsZoneProperties = false; // defaul: false

// Gets bounding box info. Assuming this is to see if an entity is within a zone’s volume?
filter.wantsZoneBoundingBox = true; // defaul: true

// The different types of filters
// Add - You are creating a new entity
// Edit - you are editing an entity that exists
// Physics - you are transforming the entity in world
// Delete - you are removing the entity
filter.wantsToFilterAdd = true; // default: true
filter.wantsToFilterEdit = true; // default: true
filter.wantsToFilterPhysics = true; // default: true
filter.wantsToFilterDelete = false; // default: false

// If reject all is true. Any of the filterType changes won’t go through
filter.rejectAll = false; // defaul: false

4 Likes

#2

Hmm… is this triggerred when physics are passed from one user to another on an entity? If so, this could be the holy grail of some people’s problems if this can be rejected.

0 Likes

#3

I believe it is triggered on anything that causes any kind of physics on an entity like gravity, position, acceleration etc… which is why even lock/unlock rights don’t matter

0 Likes