Sprache Deutsch Language English

Script Dokumentation LS 2015 - OilPump (Patch 1.3)

Script Dokumentation Übersicht

scripts/objects/OilPump.lua

Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1--[[ OilPump class
2 OilPumps pump oil!
3 Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.
4--]]
5
6OilPump = {}
7
8local OilPump_mt = Class(OilPump);
9
10function OilPump:onCreate(id)
11 g_currentMission:addUpdateable(OilPump:new(id));
12 --print("created OilPump, id: ", id);
13end;
14
15function OilPump:new(name)
16 local self = {};
17 setmetatable(self, OilPump_mt);
18
19 self.axisTable = {0, 0, 0};
20 self.me = name;
21
22 self.head = getChildAt(self.me, 1);
23 self.cylinders = getChildAt(self.me, 2);
24 self.innerCylinders = getChildAt(self.cylinders, 0);
25
26 self.speed = 0.0012;
27 self.zRotationMin = 0;
28 self.zRotationMax = Utils.degToRad(40);
29 self.timer = math.random() * 2 * math.pi;
30
31 return self;
32end;
33
34function OilPump:delete()
35
36end;
37
38function OilPump:update(dt)
39 self.timer = self.timer + dt * 0.001;
40 if self.timer >= 2 * math.pi then self.timer = 0; end;
41 local sinValue = (math.sin(self.timer) + 1) / 2; -- renders a number that goes from 0 to 1 and back
42 local zRotation = self.zRotationMax * sinValue;
43 local fakeValue = 2.105 - 1.977 / math.cos(zRotation - self.zRotationMax / 2);
44 local xRotation = Utils.degToRad(-fakeValue * 15);
45 local yScale = 1 + 0.5 * sinValue;
46 setRotation(self.head, 0, 0, zRotation);
47 setRotation(self.cylinders, 0, 0, xRotation);
48 setScale(self.innerCylinders, 1, yScale, 1);
49end;
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
Script Dokumentation Übersicht