-
Notifications
You must be signed in to change notification settings - Fork 1
/
vending_clone.em
58 lines (45 loc) · 1.72 KB
/
vending_clone.em
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
(function() {
vendingTruckScript = @
function gimme(msg, sender) {
var numEntities = 1;
if('gimme' in msg)
numEntities = msg.gimme;
function script(args) {
system.onPresenceConnected(function(pres) {
if('orientation' in args)
pres.orientation = args.orientation;
else
pres.orientation = new util.Quaternion();
system.import('std/default.em');
{action: 'created'} >> system.createVisible(args.id) >> [];
});
}
var scale = 1;
if('scale' in msg)
scale = msg.scale;
for(var i = 0; i < numEntities; i++) {
var mesh = 'meerkat:///wmonroe4/icecream.dae/optimized/icecream.dae';
if('mesh' in msg)
mesh = msg.mesh;
var position;
if('position' in msg)
position = msg.position;
else
position = <system.self.position.x - 10 + Math.random() * 5,
system.self.position.y + Math.random() * 5,
system.self.position.z + Math.random() * 5>;
system.createEntityScript(position, script,
{id: sender.toString(),
orientation: msg.orientation},
system.self.getQueryAngle(), mesh,
scale);
}
}
gimme << {'action':'touch':};
gimme << {'gimme'::};
@;
if(simulator._selected)
{request: 'script', script: vendingTruckScript} >> simulator._selected >> [];
else
system.print('No presence selected!\n');
})();