// Cellscript.mjs install('@/lib', files('lib/personlib.mjs'));// main.mjsimport { Person } from "personlib";var player = new Person("player","player.rss",false); // similar arguments to CreatePerson()player.on_update = function() { this .attachInput() .attachCamera(); var adjacent = this.getAdjacentObstructions(5); // where 5 is the offset in pixels var rand_r = Math.floor(Math.random()); var rand_g = Math.floor(Math.random()); var rand_b = Math.floor(Math.random()); var rand_a = Math.floor(Math.random()); this.setMask(new Color(rand_r, rand_g, rand_b, rand_a)); // setMask detects if the parameter is a miniSphere color object or a 1.x color object, and getMask allows you specify which one you want if(adjacent.north.tile > -1 || adjacent.north.person != "") Sphere.abort("You are ded. RIP in pieces."); else this.queueCommand(COMMAND_MOVE_NORTH, true); return true;}
const { Person } = require('personlib');var someone = new Person("some guy", 'guy.rss', false);// etc...
// at top of fileimport { Person } from 'personlib';
Tip: If using ES6 with Cell:Code: (javascript) [Select]const { Person } = require('personlib');var someone = new Person("some guy", 'guy.rss', false);// etc...Or .mjs module syntax:Code: (javascript) [Select]// at top of fileimport { Person } from 'personlib';
This looks really useful! The adjacent stuff can be useful for stuff like platform movement too.
function oldToNew(o) { alpha = 1; if(o.alpha) alpha = o.alpha; return new Color( Math.round(o.red * 100) / 100, Math.round(o.green * 100) / 100, Math.round(o.blue * 100) / 100, Math.round(alpha * 100) / 100 );}function newToOld(n) { var alpha = 255; if(n.a) alpha = o.a; return CreateColor( Math.floor(n.r * 255), Math.floor(n.g * 255), Math.floor(n.g * 255), Math.floor(alpha * 255); );}
v2Color = new Color(v1c.red / 255, v1c.green / 255, v1c.blue / 255, v1c.alpha / 255);v1Color = CreateColor(v2c.r * 255, v2c.g * 255, v2c.b * 255, v2c.a * 255);