Random script snippets


#1

Recording here some scripts we’ve used to do some content management tasks. Feel free to ask for an explanation on what these do.

Not comprehensive, but did catch two instances - I used the above to find speeches where Frogatto was talking without an emote animation;
transient_speech_dialog’s don’t count, as in those frogatto is probably walking around anyway.

To find what npcs are currently being used


#2

Here’s my little utils file. Certainly generally less useful than yours, marcavis, but someone might find it useful.

[code]= Useful Utilities =

Universal Animation Modifier:
This adds a little base tag to every cube trains object which sets its scale.
./game --utility=query modules/cube_trains ‘map(filter(visit_objects(doc), value.animation != null), set(value.animation, [{"@base": true, scale: 1}] + if(is_list(value.animation), value.animation, [value.animation])))’

Search the commit logs for a word, for a given file.
git log --grep=word – whatever/path

Log Frogatto’s console output to a file.
./game --level module-manager.cfg 2>&1 | tee log.txt

Log objects outside the level dimensions.
./game --utility=query modules/cube_trains “
if(is_list(doc.dimensions),
map(filter(visit_objects(doc),
//value.type in [‘coin_gold_big’,‘coin_gold_enormous’,‘coin_silver’,‘gold_berry’]), ‘obj’, //Alternative check, useful for Frogatto, for coins.
value.type and value.x and value.label), ‘obj’,
if(not point_in_rect([obj.x, obj.y], doc.dimensions),
debug(’${doc.id} has a ${obj.type}, ${obj.label}, out-of-bounds at ${[obj.x, obj.y]}.’))
)) where point_in_rect = def(point, rect) (rect[0] < point[0] and point[0] < rect[2] and //Cloned this function from functions-geometry.cfg sans safety.
rect[1] < point[1] and point[1] < rect[3])”

Compile Frogatto with shaders:
export CXXFLAGS=-DUSE_GLES2 && make clean && make

Or not:
unset CXXFLAGS && make clean && make

Chart Events Fired:
debug_chart(‘events’, performance().nevents),

Chart all metrics:
debug_chart(‘fps’, constrain(0, performance().fps, 100)),
debug_chart(‘cycles_per_second’, constrain(0, performance().cycles_per_second, 100)),
debug_chart(‘delay’, constrain(0, performance().delay, 100)),
debug_chart(‘draw’, constrain(0, performance().draw, 100)),
debug_chart(‘process’, constrain(0, performance().process, 100)),
debug_chart(‘flip’, constrain(0, performance().flip, 100)),
debug_chart(‘nevents’, constrain(0, performance().nevent, 100)),
debug_chart(‘time’, time()%100),

List authors in git:
git shortlog -sn

Offset an entire Cube Trains map by x/y/z:
set(ctm, )
ctm + {‘map’: map(ctm[‘map’], list_replace_elements(value, 1, [list_add(value[1], offset)] ) )} where offset = [0,0,1][/code]