add prototype engine
This commit is contained in:
parent
2e84494120
commit
41af49583c
BIN
blend_files/farlands_engine_cart.blend
Normal file
BIN
blend_files/farlands_engine_cart.blend
Normal file
Binary file not shown.
BIN
blend_files/farlands_train_engine.blend
Normal file
BIN
blend_files/farlands_train_engine.blend
Normal file
Binary file not shown.
BIN
blend_files/farlands_train_engine.blend1
Normal file
BIN
blend_files/farlands_train_engine.blend1
Normal file
Binary file not shown.
108
mods/fl_trains/engine.lua
Normal file
108
mods/fl_trains/engine.lua
Normal file
@ -0,0 +1,108 @@
|
||||
local function speed_check(vec, limit)
|
||||
local v = vector.apply(vec, math.abs)
|
||||
local l = limit
|
||||
if v.x >= l then return false
|
||||
elseif v.y >= l then return false
|
||||
elseif v.z >= l then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_entity("fl_trains:train_engine", {
|
||||
--mte object properties
|
||||
initial_properties = {
|
||||
physical = true,
|
||||
--stepheight = 0.4,
|
||||
collide_with_objects = true,
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
visual = "mesh",
|
||||
mesh = "farlands_train_engine.obj",
|
||||
textures = {
|
||||
"farlands_train_engine.png",
|
||||
},
|
||||
backface_culling = false,
|
||||
visual_size = {x=10, y=10, z=10},
|
||||
static_save = true,
|
||||
damage_texture_modifier = "^[colorize:#FF000040"
|
||||
},
|
||||
|
||||
--on_step = mobkit.stepfunc, --this is required
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
--load memory
|
||||
local sdata = minetest.deserialize(staticdata)
|
||||
if sdata then
|
||||
for k,v in pairs(sdata) do
|
||||
self[k] = v
|
||||
end
|
||||
end
|
||||
if not self.memory then self.memory = {} end
|
||||
--other stuff
|
||||
end,
|
||||
get_staticdata = function(self)
|
||||
local tmp = {memory = self.memory}
|
||||
return minetest.serialize(tmp)
|
||||
end,
|
||||
on_step = function(self, dtime, moveresult)
|
||||
local yaw = tonumber(string.format("%.2f", self.object:get_yaw()))
|
||||
local dir = vector.round(minetest.yaw_to_dir(yaw))
|
||||
local pos = self.object:get_pos()
|
||||
local pos2 = vector.add(dir, pos)
|
||||
local node = minetest.get_node_or_nil(pos2)
|
||||
if not node then self.object:set_velocity(vector.new(0,0,0)) return end
|
||||
if node.name ~= "fl_trains:straight_track" then
|
||||
self.object:set_velocity(vector.new(0,0,0))
|
||||
return
|
||||
end
|
||||
|
||||
local vel = self.object:get_velocity()
|
||||
local player
|
||||
if self.memory.driver then player = minetest.get_player_by_name(self.memory.driver) end
|
||||
if not player then return end
|
||||
if player:get_player_control().up and speed_check(vel, 5) then
|
||||
self.object:add_velocity(vector.multiply(dir, 0.2))
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
self.object:remove()
|
||||
end,
|
||||
|
||||
on_rightclick=function(self, clicker)
|
||||
if #self.object:get_children() > 0 then
|
||||
for _, obj in pairs(self.object:get_children()) do
|
||||
if obj:is_player() and obj:get_player_name() == self.memory.driver then
|
||||
obj:set_detach()
|
||||
obj:set_properties({visual_size = vector.new(1,1,1)})
|
||||
fl_player.ignore[obj:get_player_name()] = nil
|
||||
obj:set_eye_offset(vector.new(0,0,0), vector.new(0,0,0))
|
||||
self.memory.driver = nil
|
||||
end
|
||||
end
|
||||
else
|
||||
clicker:set_attach(self.object, "", vector.new(0,-0.49,0.45), vector.new(0,0,0), true)
|
||||
clicker:set_properties({visual_size = vector.new(.075,.075,.075)})
|
||||
fl_player.ignore[clicker:get_player_name()] = true
|
||||
clicker:set_animation(fl_player.animations["sit"], 15)
|
||||
clicker:set_eye_offset(vector.new(0,-13,5.5), vector.new(0,-13,5.5))
|
||||
self.memory.driver = clicker:get_player_name()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("fl_trains:train_engine", {
|
||||
description = "train_engine",
|
||||
inventory_image = "farlands_cart_item.png",
|
||||
wield_image = "farlands_cart_item.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then return end
|
||||
local node = minetest.get_node_or_nil(pointed_thing.under)
|
||||
if string.find(node.name, "fl_trains") then
|
||||
local ent = minetest.add_entity(pointed_thing.under, "fl_trains:train_engine")
|
||||
if node.name == "fl_trains:straight_track" and node.param2%2 ~= 0 then
|
||||
ent:set_rotation(vector.new(0,90*(math.pi/180),0))
|
||||
minetest.chat_send_all(ent:get_yaw())
|
||||
end
|
||||
end
|
||||
end,
|
||||
--groups = {not_in_creative_inventory = 1}
|
||||
})
|
@ -1,3 +1,4 @@
|
||||
local modpath = minetest.get_modpath("fl_trains")
|
||||
dofile(modpath .. "/track.lua")
|
||||
dofile(modpath .. "/cart.lua")
|
||||
dofile(modpath .. "/cart.lua")
|
||||
dofile(modpath .. "/engine.lua")
|
153
mods/fl_trains/models/farlands_train_engine.obj
Normal file
153
mods/fl_trains/models/farlands_train_engine.obj
Normal file
@ -0,0 +1,153 @@
|
||||
# Blender v2.93.3 OBJ File: ''
|
||||
# www.blender.org
|
||||
o Cube_Cube.006
|
||||
v 0.050000 0.400000 -0.650000
|
||||
v 0.050000 0.500000 -0.650000
|
||||
v 0.050000 0.400000 -0.750000
|
||||
v 0.050000 0.500000 -0.750000
|
||||
v 0.150000 0.400000 -0.650000
|
||||
v 0.150000 0.500000 -0.650000
|
||||
v 0.150000 0.400000 -0.750000
|
||||
v 0.150000 0.500000 -0.750000
|
||||
v -0.250000 0.400000 0.250000
|
||||
v 0.250000 0.400000 0.250000
|
||||
v -0.250000 0.400000 -0.897500
|
||||
v 0.250000 0.400000 -0.897500
|
||||
v 0.495000 -0.250000 -0.995000
|
||||
v 0.495000 -0.500000 -0.995000
|
||||
v 0.495000 -0.250000 0.995000
|
||||
v 0.495000 -0.500000 0.995000
|
||||
v -0.495000 -0.250000 -0.995000
|
||||
v -0.495000 -0.500000 -0.995000
|
||||
v -0.495000 -0.250000 0.995000
|
||||
v -0.495000 -0.500000 0.995000
|
||||
v -0.495000 -0.250000 0.995000
|
||||
v -0.495000 0.500000 0.995000
|
||||
v -0.495000 -0.250000 0.245000
|
||||
v -0.495000 0.500000 0.245000
|
||||
v 0.495000 -0.250000 0.995000
|
||||
v 0.495000 0.500000 0.995000
|
||||
v 0.495000 -0.250000 0.245000
|
||||
v 0.495000 0.500000 0.245000
|
||||
v 0.395000 -0.250000 -0.895000
|
||||
v 0.395000 -0.250000 0.245000
|
||||
v 0.250000 0.400000 0.250000
|
||||
v 0.250000 0.400000 -0.900000
|
||||
v -0.395000 -0.250000 -0.895000
|
||||
v -0.395000 -0.250000 0.245000
|
||||
v -0.250000 0.400000 0.250000
|
||||
v -0.250000 0.400000 -0.900000
|
||||
vt 0.265625 0.562500
|
||||
vt 0.234375 0.562500
|
||||
vt 0.234375 0.531250
|
||||
vt 0.265625 0.531250
|
||||
vt 0.234375 0.562500
|
||||
vt 0.203125 0.562500
|
||||
vt 0.203125 0.531250
|
||||
vt 0.234375 0.531250
|
||||
vt 0.593750 0.296875
|
||||
vt 0.562500 0.296875
|
||||
vt 0.562500 0.265625
|
||||
vt 0.593750 0.265625
|
||||
vt 0.562500 0.265625
|
||||
vt 0.562500 0.296875
|
||||
vt 0.531250 0.296875
|
||||
vt 0.531250 0.265625
|
||||
vt 0.531250 0.296875
|
||||
vt 0.562500 0.296875
|
||||
vt 0.562500 0.328125
|
||||
vt 0.531250 0.328125
|
||||
vt 0.859375 0.312500
|
||||
vt 0.734375 0.312500
|
||||
vt 0.734375 0.000000
|
||||
vt 0.859375 0.000000
|
||||
vt 0.468750 0.640625
|
||||
vt 0.531250 0.640625
|
||||
vt 0.531250 0.906250
|
||||
vt 0.468750 0.906250
|
||||
vt 0.937500 0.531250
|
||||
vt 0.875000 0.531250
|
||||
vt 0.875000 0.000000
|
||||
vt 0.937500 0.000000
|
||||
vt 0.000000 0.000000
|
||||
vt 0.265625 0.000000
|
||||
vt 0.265625 0.531250
|
||||
vt 0.000000 0.531250
|
||||
vt 1.000000 0.531250
|
||||
vt 0.937500 0.531250
|
||||
vt 0.937500 0.000000
|
||||
vt 1.000000 0.000000
|
||||
vt 0.531250 0.640625
|
||||
vt 0.593750 0.640625
|
||||
vt 0.593750 0.906250
|
||||
vt 0.531250 0.906250
|
||||
vt 0.265625 0.640625
|
||||
vt 0.468750 0.640625
|
||||
vt 0.468750 0.843750
|
||||
vt 0.265625 0.843750
|
||||
vt 0.625000 0.328125
|
||||
vt 0.812500 0.328125
|
||||
vt 0.812500 0.593750
|
||||
vt 0.625000 0.593750
|
||||
vt 0.812500 0.796875
|
||||
vt 0.625000 0.796875
|
||||
vt 0.531250 0.000000
|
||||
vt 0.734375 0.000000
|
||||
vt 0.734375 0.265625
|
||||
vt 0.531250 0.265625
|
||||
vt 0.000000 0.796875
|
||||
vt 0.000000 0.531250
|
||||
vt 0.203125 0.531250
|
||||
vt 0.203125 0.796875
|
||||
vt 0.437500 0.328125
|
||||
vt 0.437500 0.640625
|
||||
vt 0.265625 0.640625
|
||||
vt 0.265625 0.328125
|
||||
vt 0.609375 0.328125
|
||||
vt 0.609375 0.640625
|
||||
vt 0.437500 0.640625
|
||||
vt 0.437500 0.328125
|
||||
vt 1.000000 0.765625
|
||||
vt 0.812500 0.812500
|
||||
vt 0.812500 0.593750
|
||||
vt 1.000000 0.640625
|
||||
vt 0.531250 0.000000
|
||||
vt 0.500000 0.031250
|
||||
vt 0.296875 0.031250
|
||||
vt 0.265625 0.000000
|
||||
vt 0.531250 0.328125
|
||||
vt 0.500000 0.328125
|
||||
vt 0.296875 0.328125
|
||||
vt 0.265625 0.328125
|
||||
vn -1.0000 0.0000 0.0000
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
vn 1.0000 0.0000 0.0000
|
||||
vn 0.0000 0.0000 1.0000
|
||||
vn 0.0000 1.0000 0.0000
|
||||
vn 0.0000 -1.0000 0.0000
|
||||
vn 0.9760 0.2177 0.0000
|
||||
vn -0.9760 0.2177 0.0000
|
||||
vn 0.0000 -0.0077 -1.0000
|
||||
s off
|
||||
f 1/1/1 2/2/1 4/3/1 3/4/1
|
||||
f 3/5/2 4/6/2 8/7/2 7/8/2
|
||||
f 7/9/3 8/10/3 6/11/3 5/12/3
|
||||
f 5/13/4 6/14/4 2/15/4 1/16/4
|
||||
f 8/17/5 4/18/5 2/19/5 6/20/5
|
||||
f 9/21/5 10/22/5 12/23/5 11/24/5
|
||||
f 16/25/4 15/26/4 19/27/4 20/28/4
|
||||
f 20/29/1 19/30/1 17/31/1 18/32/1
|
||||
f 18/33/6 14/34/6 16/35/6 20/36/6
|
||||
f 14/37/3 13/38/3 15/39/3 16/40/3
|
||||
f 18/41/2 17/42/2 13/43/2 14/44/2
|
||||
f 21/45/1 22/46/1 24/47/1 23/48/1
|
||||
f 23/49/2 24/50/2 28/51/2 27/52/2
|
||||
f 27/52/3 28/51/3 26/53/3 25/54/3
|
||||
f 25/55/4 26/56/4 22/57/4 21/58/4
|
||||
f 28/59/5 24/60/5 22/61/5 26/62/5
|
||||
f 32/63/7 31/64/7 30/65/7 29/66/7
|
||||
f 35/67/8 36/68/8 33/69/8 34/70/8
|
||||
f 32/71/9 29/72/9 33/73/9 36/74/9
|
||||
f 17/75/5 33/76/5 29/77/5 13/78/5
|
||||
f 33/76/5 17/75/5 23/79/5 34/80/5
|
||||
f 29/77/5 30/81/5 27/82/5 13/78/5
|
BIN
mods/fl_trains/textures/farlands_train_engine.png
Normal file
BIN
mods/fl_trains/textures/farlands_train_engine.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
BIN
mods/fl_trains/textures/farlands_train_engine.png~
Normal file
BIN
mods/fl_trains/textures/farlands_train_engine.png~
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
@ -5,7 +5,7 @@ minetest.register_node("fl_trains:straight_track", {
|
||||
drawtype = "mesh",
|
||||
mesh = "farlands_straight.obj",
|
||||
tiles = {"farlands_rail.png", "farlands_ties.png"},
|
||||
groups = {oddly_breakable_by_hand = 3, not_in_creative_inventory = 1},
|
||||
groups = {oddly_breakable_by_hand = 3},--, not_in_creative_inventory = 1},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5,-0.5,-0.5,0.5,-0.475,0.5},
|
||||
|
Loading…
x
Reference in New Issue
Block a user