Add Sofas and stuff
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
local function get_velocity(v, yaw, y)
|
||||
local x = -math.sin(yaw) * v
|
||||
local z = math.cos(yaw) * v
|
||||
return {x = x * 8, y = y * 8, z = z * 8}
|
||||
return {x = x, y = y, z = z}
|
||||
end
|
||||
|
||||
local function get_v(v)
|
||||
return math.sqrt(v.x ^ 2 + v.z ^ 2)
|
||||
local function get_v(v, speed)
|
||||
return math.sqrt(v.x ^ 2 + v.z ^ 2) * speed
|
||||
end
|
||||
|
||||
local class = {
|
||||
@@ -16,6 +16,7 @@ local class = {
|
||||
last_v = 0,
|
||||
removed = false,
|
||||
auto = false,
|
||||
speed = 1
|
||||
}
|
||||
|
||||
function class:on_rightclick(clicker)
|
||||
@@ -90,7 +91,7 @@ function class:on_punch(puncher)
|
||||
end
|
||||
|
||||
function class:on_step(dtime)
|
||||
self.v = get_v(self.object:get_velocity()) * math.sign(self.v)
|
||||
self.v = get_v(self.object:get_velocity(), self.speed) * math.sign(self.v)
|
||||
if self.driver then
|
||||
local driver_objref = core.get_player_by_name(self.driver)
|
||||
if driver_objref then
|
||||
@@ -149,15 +150,16 @@ function class:on_step(dtime)
|
||||
if y >= 5 then
|
||||
y = 5
|
||||
end
|
||||
new_velo = get_velocity(self.v, self.object:get_yaw(), y)
|
||||
new_velo = get_velocity(self.v, self.object:get_yaw(), y, self.speed)
|
||||
self.object:set_pos(self.object:get_pos())
|
||||
self.object:set_velocity(new_velo)
|
||||
self.object:set_acceleration(new_acce)
|
||||
end
|
||||
|
||||
PyuTest.create_vehicle = function(name, desc, properties, image, craft)
|
||||
PyuTest.create_vehicle = function(name, desc, speed, properties, image, craft)
|
||||
local options = setmetatable(properties, { __index = class})
|
||||
options.name = name
|
||||
options.speed = speed
|
||||
|
||||
core.register_entity(name, properties)
|
||||
|
||||
|
@@ -2,7 +2,7 @@ local modpath = core.get_modpath(core.get_current_modname())
|
||||
|
||||
dofile(modpath .. "/api.lua")
|
||||
|
||||
PyuTest.create_vehicle("pyutest_vehicles:test", "Test Vehicle", {
|
||||
PyuTest.create_vehicle("pyutest_vehicles:test", "Test Vehicle", 1.2, {
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collisionbox = PyuTest.NODEBOX_DEFAULT.fixed,
|
||||
|
Reference in New Issue
Block a user