v2 release
This commit is contained in:
parent
6d02daf9b3
commit
87ae80bf5c
11
README.md
11
README.md
|
@ -1,7 +1,7 @@
|
|||
minetest-technology
|
||||
===================
|
||||
|
||||
A minetest mod which provide some hi-tech stuff : flat screen, bronze structures, concrete, ...
|
||||
A minetest mod which provide some hi-tech stuff : flat screen, elevators, aircrafts, bronze structures, concrete, ...
|
||||
|
||||
Install
|
||||
=======
|
||||
|
@ -11,4 +11,11 @@ As other minetest mod : extract the zip file as "technology" in the games/minete
|
|||
Other
|
||||
=====
|
||||
|
||||
See documentation.txt to learn more (about crafting for exemple).
|
||||
See documentation.txt to learn more (about crafting for exemple).
|
||||
|
||||
Copyright
|
||||
=========
|
||||
author: jimy byerley (jimy.byerley@gmail.com)
|
||||
All the source code, models, textures, sounds are under Creative Common Share Alike, except the following files:
|
||||
sounds/elevator_close.wav by joedeshon (freesound.org)
|
||||
sounds/elevator_loop.wav by marcel_farres (freesound.org)
|
||||
|
|
337
aircraft.lua
337
aircraft.lua
|
@ -1,21 +1,5 @@
|
|||
|
||||
local function get_sign(i)
|
||||
if i == 0 then
|
||||
return 0
|
||||
else
|
||||
return i/math.abs(i)
|
||||
end
|
||||
end
|
||||
|
||||
local function get_velocity(v, yaw, y)
|
||||
local x = math.cos(yaw)*v
|
||||
local z = math.sin(yaw)*v
|
||||
return {x=x, y=y, z=z}
|
||||
end
|
||||
|
||||
local function get_v(v)
|
||||
return math.sqrt(v.x^2+v.z^2)
|
||||
end
|
||||
--[[
|
||||
minetest.register_abm({
|
||||
nodenames = {"air"},
|
||||
|
@ -27,143 +11,269 @@ minetest.register_abm({
|
|||
})
|
||||
]]
|
||||
|
||||
local hunter = {
|
||||
hp_max = 100,
|
||||
|
||||
--[[
|
||||
Exportation des animations depuis blender:
|
||||
il faut avoir la config suivante:
|
||||
+ export normals
|
||||
+ flip normals
|
||||
+ export UV coords
|
||||
+ export skin weight
|
||||
- apply modifier
|
||||
+ export armature bones
|
||||
+ export rest animation
|
||||
+ export animations
|
||||
+ include frame rate
|
||||
]]
|
||||
|
||||
local patroller = {
|
||||
hp_max = 400,
|
||||
physical = true,
|
||||
collisionbox = {-2.5,-7,-2.5, 2.5,4,2.5},
|
||||
visual = "mesh",
|
||||
mesh = "patrouilleur.x",
|
||||
textures = {"patrouilleur.png"},
|
||||
automatic_rotate = true,
|
||||
makes_footstep_sound = true,
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = true,
|
||||
mesh = "patroller.x",
|
||||
textures = {"technology_patroller.png"},
|
||||
--automatic_rotate = true,
|
||||
--makes_footstep_sound = true,
|
||||
--spritediv = {x=1, y=1},
|
||||
--initial_sprite_basepos = {x=0, y=0},
|
||||
--is_visible = true,
|
||||
can_punch = true,
|
||||
|
||||
driver = nil,
|
||||
v = 0,
|
||||
z = 0,
|
||||
front_vel_target = 0, -- 0 is no speed, 1 is maximum speed
|
||||
vert_vel_target = 0,
|
||||
|
||||
max_front_vel = 10,
|
||||
max_vert_vel = 7,
|
||||
}
|
||||
|
||||
function hunter:on_rightclick(clicker)
|
||||
local FPS = 15 -- frame per second for animations
|
||||
local WEAPONS = minetest.get_modpath("firearms_guns") or false -- auto enable weapon support
|
||||
|
||||
function patroller:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
|
||||
if self.driver and puncher == self.driver then
|
||||
self:fire(self.driver:get_look_dir())
|
||||
end
|
||||
--[[
|
||||
self.object:remove()
|
||||
if puncher and puncher:is_player() then
|
||||
puncher:get_inventory():add_item("main", "technology:patroller")
|
||||
end
|
||||
]]
|
||||
end
|
||||
|
||||
function patroller:fire(direction)
|
||||
if WEAPONS then
|
||||
local p = self.object:getpos()
|
||||
p.y = p.y-7
|
||||
firearmslib.fire("technology:air_canon", p, direction)
|
||||
end
|
||||
end
|
||||
|
||||
if WEAPONS then
|
||||
--[[
|
||||
firearmslib.register_bullet("technology:air_canon_ammo", {
|
||||
description = "5mm air canon amunition";
|
||||
inventory_image = "firearms_bullet_556.png";
|
||||
damage = 12;
|
||||
power = 5;
|
||||
gravity = 0;
|
||||
});
|
||||
|
||||
firearmslib.register_firearm("technology:air_canon", {
|
||||
description = "5mm air canon";
|
||||
inventory_image = "firearms_m4.png";
|
||||
bullets = "technology:air_canon_ammo";
|
||||
clip_size = 42;
|
||||
spread = 0.035;
|
||||
burst = 3;
|
||||
burst_interval = 0.15;
|
||||
wield_scale = {x=2,y=2,z=2};
|
||||
crosshair_image = "firearms_crosshair_rifle.png";
|
||||
hud_image = "firearms_m4_hud.png";
|
||||
sounds = {
|
||||
shoot = "firearms_m4_shot";
|
||||
empty = "firearms_default_empty";
|
||||
reload = "firearms_rifle_reload";
|
||||
};
|
||||
});
|
||||
]]
|
||||
|
||||
firearmslib.register_bullet("technology:air_canon_ammo", {
|
||||
description = "Rocket";
|
||||
inventory_image = "firearms_rocket.png";
|
||||
texture = "firearms_rocket_entity.png";
|
||||
damage = 10;
|
||||
power = 5;
|
||||
speed = 25;
|
||||
gravity = 0;
|
||||
explosion_range = 2.5;
|
||||
explosion_damage = 6;
|
||||
leaves_smoke = true;
|
||||
on_destroy = firearmslib.on_destroy_explode;
|
||||
});
|
||||
|
||||
firearmslib.register_firearm("technology:air_canon", {
|
||||
description = "Bazooka";
|
||||
inventory_image = "firearms_bazooka.png";
|
||||
bullets = "technology:air_canon_ammo";
|
||||
clip_size = 5;
|
||||
spread = 0.035;
|
||||
wield_scale = {x=3,y=3,z=3};
|
||||
crosshair_image = "firearms_crosshair_rlauncher.png";
|
||||
hud_image = "firearms_bazooka_hud.png";
|
||||
sounds = {
|
||||
shoot = "firearms_m79_shot"; -- TODO: Find a better sound
|
||||
empty = "firearms_default_empty";
|
||||
--reload = "firearms_default_reload";
|
||||
};
|
||||
});
|
||||
end
|
||||
|
||||
function patroller:on_rightclick(clicker)
|
||||
if not clicker or not clicker:is_player() then
|
||||
return
|
||||
end
|
||||
if self.driver and clicker == self.driver then
|
||||
self.driver = nil
|
||||
self.object:set_animation({x=50, y=55}, 15, 1)
|
||||
local p = get_velocity(3, self.object:getyaw(), 3)
|
||||
self.object:set_animation({x=54, y=54}, FPS, 0)
|
||||
local pos = self.object:getpos()
|
||||
pos.x = pos.x-p.x
|
||||
pos.y = pos.y-p.y
|
||||
pos.z = pos.z-p.z
|
||||
local yaw = self.object:getyaw()
|
||||
pos.x = pos.x - 4*math.cos(yaw)
|
||||
pos.y = pos.y - 3
|
||||
pos.z = pos.z - 4*math.sin(yaw)
|
||||
clicker:set_detach()
|
||||
clicker:setpos(pos)
|
||||
self.object:setvelocity({x=0, y=0, z=0})
|
||||
default.player_set_animation(clicker, "stand" , 30)
|
||||
minetest.after(0.2, function()
|
||||
clicker:setpos(pos)
|
||||
end)
|
||||
--self.object:setvelocity({x=0, y=0, z=0})
|
||||
self.front_vel_target = 0
|
||||
self.vert_vel_target = 0
|
||||
elseif not self.driver then
|
||||
self.driver = clicker
|
||||
clicker:set_attach(self.object, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
|
||||
self.object:set_animation({x=55, y=60}, 15, 1)
|
||||
clicker:set_attach(self.object, "", {x=0,y=0,z=10}, {x=0,y=0,z=-10})
|
||||
default.player_set_animation(clicker, "sit" , 30)
|
||||
self.object:set_animation({x=60, y=60}, FPS, 0)
|
||||
end
|
||||
end
|
||||
|
||||
function hunter:on_activate(staticdata, dtime_s)
|
||||
function patroller:on_activate(staticdata, dtime_s)
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
--[[
|
||||
if staticdata then
|
||||
self.v = tonumber(staticdata)
|
||||
end
|
||||
]]
|
||||
end
|
||||
|
||||
function hunter:get_staticdata()
|
||||
return tostring(v)
|
||||
|
||||
function patroller:get_staticdata()
|
||||
return "" --tostring(v)
|
||||
end
|
||||
|
||||
function hunter:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
|
||||
self.object:remove()
|
||||
if puncher and puncher:is_player() then
|
||||
puncher:get_inventory():add_item("main", "technology:hunter")
|
||||
end
|
||||
end
|
||||
|
||||
function hunter:on_step(dtime)
|
||||
|
||||
local command_increment = 0.05
|
||||
hunter_step_tick = 0
|
||||
|
||||
function patroller:on_step(dtime)
|
||||
-- make fire if damages are over 50%
|
||||
if self.object:get_hp() < 50 then
|
||||
print("hunter is burning")
|
||||
local pos = self.object:getpos()
|
||||
pos.x = pos.x + math.random(-2,2)
|
||||
pos.y = pos.y + math.random(-2,2)
|
||||
pos.z = pos.z + math.random(-2,2)
|
||||
minetest.env:set_node(pos, {name="fire:basic_flame"})
|
||||
self.z = self.z - 0.1
|
||||
end
|
||||
-- explode when hp is under 5
|
||||
hunter_step_tick = hunter_step_tick+dtime
|
||||
if self.object:get_hp() < 5 then
|
||||
explosion(self.object:getpos(), 30)
|
||||
end
|
||||
local velocity = self.object:getvelocity()
|
||||
-- have user commands
|
||||
self.v = get_v(velocity)*get_sign(self.v)
|
||||
|
||||
local command = false
|
||||
--[[
|
||||
if math.random(1,10) == 1 then
|
||||
local yaw = self.object:getyaw()
|
||||
local dir = {
|
||||
x = math.cos(yaw),
|
||||
y = 0,
|
||||
z = math.sin(yaw),
|
||||
}
|
||||
self:fire(dir)
|
||||
end
|
||||
]]
|
||||
|
||||
if self.driver then
|
||||
local ctrl = self.driver:get_player_control()
|
||||
if ctrl.up then
|
||||
self.v = self.v+0.4
|
||||
end
|
||||
if ctrl.down then
|
||||
self.v = self.v-0.4
|
||||
if hunter_step_tick > 0.1 then
|
||||
hunter_step_tick = 0
|
||||
-- have user commands
|
||||
if ctrl.up and self.front_vel_target < 1 then
|
||||
self.front_vel_target = self.front_vel_target + command_increment
|
||||
command = true
|
||||
elseif ctrl.down and self.front_vel_target > -0.05 then
|
||||
self.front_vel_target = self.front_vel_target - command_increment
|
||||
command = true
|
||||
end
|
||||
if ctrl.jump and self.vert_vel_target < 1 then
|
||||
self.vert_vel_target = self.vert_vel_target + command_increment
|
||||
command = true
|
||||
elseif ctrl.sneak and self.vert_vel_target > -1 then
|
||||
self.vert_vel_target = self.vert_vel_target - command_increment
|
||||
command = true
|
||||
end
|
||||
end
|
||||
if ctrl.left then
|
||||
self.object:setyaw(self.object:getyaw()+math.pi/120+dtime*math.pi/120)
|
||||
--self.object:set_animation({x=5, y=5}, 1, 0)
|
||||
end
|
||||
if ctrl.right then
|
||||
self.object:set_animation({x=5, y=5}, FPS, 0)
|
||||
command = true
|
||||
elseif ctrl.right then
|
||||
self.object:setyaw(self.object:getyaw()-math.pi/120-dtime*math.pi/120)
|
||||
--self.object:set_animation({x=15, y=15}, 1, 0)
|
||||
self.object:set_animation({x=10, y=10}, FPS, 0)
|
||||
command = true
|
||||
else
|
||||
--self.object:set_animation({x=60, y=60}, FPS, 0)
|
||||
end
|
||||
if ctrl.jump then
|
||||
self.z = self.z+0.15
|
||||
end
|
||||
if ctrl.sneak then
|
||||
self.z = self.z-0.15
|
||||
end
|
||||
end
|
||||
local z = get_sign(self.z)
|
||||
self.z = self.z - 0.02*z
|
||||
if z ~= get_sign(self.z) then
|
||||
self.object:setvelocity({x=0,y=0,z=0})
|
||||
self.z = 0
|
||||
return
|
||||
end
|
||||
if math.abs(self.z) > 4.5 then
|
||||
self.z = 4.5*get_sign(self.z)
|
||||
else
|
||||
self.front_vel_target = 0
|
||||
self.vert_vel_target = 0
|
||||
--command = true
|
||||
self.object:setvelocity({x=0, y=0, z=0})
|
||||
self.object:set_animation({x=54, y=54}, FPS, 0)
|
||||
end
|
||||
|
||||
local s = get_sign(self.v)
|
||||
self.v = self.v - 0.02*s
|
||||
if s ~= get_sign(self.v) then
|
||||
self.object:setvelocity({x=0, y=0, z=0})
|
||||
self.v = 0
|
||||
return
|
||||
end
|
||||
if math.abs(self.v) > 6 then
|
||||
self.v = 6*get_sign(self.v)
|
||||
end
|
||||
|
||||
self.object:setacceleration({x=0, y=0, z=0})
|
||||
if math.abs(self.object:getvelocity().y) < 0.01 then
|
||||
local pos = self.object:getpos()
|
||||
pos.y = math.floor(pos.y)+0
|
||||
self.object:setpos(pos)
|
||||
self.object:setvelocity(get_velocity(self.v, self.object:getyaw(), self.z))
|
||||
else
|
||||
self.object:setvelocity(get_velocity(self.v, self.object:getyaw(), self.z))
|
||||
if command then
|
||||
local yaw = self.object:getyaw()
|
||||
self.object:setvelocity({
|
||||
x = self.front_vel_target * self.max_front_vel * math.cos(yaw),
|
||||
y = self.vert_vel_target * self.max_vert_vel,
|
||||
z = self.front_vel_target * self.max_front_vel * math.sin(yaw),
|
||||
})
|
||||
if self.vert_vel_target < 0 then
|
||||
local frame = 40-5*self.vert_vel_target + 0.5
|
||||
self.object:set_animation({x=frame, y=frame}, FPS, 0)
|
||||
else
|
||||
local frame = 30+5*self.vert_vel_target - 0.5
|
||||
self.object:set_animation({x=frame, y=frame}, FPS, 0)
|
||||
end
|
||||
end
|
||||
--[[
|
||||
local Kf = 3.1
|
||||
local Kv = 3.1
|
||||
local v = self.object:getvelocity()
|
||||
local yaw = self.object:getyaw()
|
||||
local front_vel = v.x * -math.sin(yaw) + v.z * math.cos(yaw)
|
||||
local vert_vel = v.y
|
||||
local front_acc = Kf*(self.max_front_vel*self.front_vel_target - front_vel)
|
||||
local vert_acc = Kv*(self.max_vert_vel*self.vert_vel_target - vert_vel)
|
||||
self.object:setacceleration({x=-front_acc*math.sin(yaw), y=vert_acc, z=front_acc*math.cos(yaw)})
|
||||
]]
|
||||
--print("command "..self.front_vel_target.." "..self.vert_vel_target)
|
||||
--print("command "..front_acc.." "..vert_acc)
|
||||
|
||||
end
|
||||
|
||||
minetest.register_entity("technology:hunter", hunter)
|
||||
minetest.register_entity("technology:patroller", patroller)
|
||||
|
||||
|
||||
minetest.register_craftitem("technology:hunter", {
|
||||
description = "hunter flying",
|
||||
minetest.register_craftitem("technology:patroller", {
|
||||
description = "patroller flying",
|
||||
inventory_image = "hunter_inv.png",
|
||||
wield_image = "hunter_inv.png",
|
||||
wield_scale = {x=2, y=2, z=1},
|
||||
|
@ -173,11 +283,22 @@ minetest.register_craftitem("technology:hunter", {
|
|||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
print("hunter added !!!")
|
||||
print("patroller added !!!")
|
||||
pointed_thing.under.y = pointed_thing.under.y+2
|
||||
minetest.env:add_entity(pointed_thing.under, "technology:hunter")
|
||||
minetest.env:add_entity(pointed_thing.under, "technology:patroller")
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
technology.register_plan("PATROLLER", "technology:patroller", "technology_plan_patroller.png", {
|
||||
"technic:hv_transformer",
|
||||
"technic:mv_transformer",
|
||||
"technic:motor 8",
|
||||
"technology:wire 10",
|
||||
"default:steel_ingot 6",
|
||||
"default:silver_ingot 1",
|
||||
"default:mese 1",
|
||||
"firearms:shell_12 1",
|
||||
})
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
default
|
||||
moreores
|
||||
mesecons
|
||||
mesecons
|
||||
technic
|
||||
|
|
250
elevator.lua
Normal file
250
elevator.lua
Normal file
|
@ -0,0 +1,250 @@
|
|||
local elevator = {
|
||||
hp_max = 400,
|
||||
can_punch = true,
|
||||
physical = true,
|
||||
collisionbox = {-1, -0.5, -1, 1, 2.5, 1},
|
||||
visual = "mesh",
|
||||
mesh = "elevator.x",
|
||||
textures = {"technology_elevator.png"},
|
||||
|
||||
item = "technology:elevator",
|
||||
|
||||
marks = {}, -- list of floors to stop to
|
||||
passengers = {}, -- list of current passengers
|
||||
direction = 0,
|
||||
direction_change = false, -- enable for step to take the direction change in count
|
||||
target = 0, -- altitude to reach
|
||||
}
|
||||
|
||||
local elevator_radius = 1
|
||||
local elevator_speed = 3
|
||||
local elevator_rail = "technology:elevator_rail"
|
||||
local elevator_mark = "default:sign_wall_steel"
|
||||
local elevator_entity = "technology:elevator_entity"
|
||||
|
||||
|
||||
function yaw(object)
|
||||
if object:is_player() then return object:get_look_horizontal()
|
||||
else return object:getyaw()
|
||||
end
|
||||
end
|
||||
|
||||
function elevator:is_player_inside(player)
|
||||
print(player:get_player_name().." enter an elevator as passenger n°"..#self.passengers.."")
|
||||
for i,passenger in pairs(self.passengers) do
|
||||
if player == passenger then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function elevator:set_direction(direction)
|
||||
print("elevator take direction "..direction.." to target "..self.target)
|
||||
self.direction = direction
|
||||
self.direction_change = true
|
||||
if self.sound_loop then minetest.sound_stop(self.sound_loop) end
|
||||
if direction==0 then
|
||||
self.sound_loop = minetest.sound_play("elevator_close", {object=self.object, max_hear_distance = 10, loop=false})
|
||||
self.target = 0
|
||||
else
|
||||
if self.sound_loop then minetest.sound_stop(self.sound_loop) end
|
||||
self.sound_loop = minetest.sound_play("elevator_loop", {object=self.object, max_hear_distance = 10, loop=true})
|
||||
end
|
||||
end
|
||||
|
||||
function elevator:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
|
||||
if self:is_player_inside(puncher) then -- punch an elevator to go up or down
|
||||
if self.direction == 0 then
|
||||
local look = puncher:get_look_vertical()
|
||||
local p = self.object:getpos()
|
||||
self:regenerate_marks() -- search for a mark, that can haven't been already searched
|
||||
if #self.marks == 0 then return end
|
||||
if look < 0 then -- look up
|
||||
local i=1
|
||||
while i<=#self.marks and self.marks[i]<=p.y do i = i+1 end
|
||||
if self.marks[i] == p.y then return end
|
||||
self.target = self.marks[i]
|
||||
self:set_direction(1)
|
||||
else -- look down
|
||||
local i=#self.marks
|
||||
while i>0 and self.marks[i]>=p.y do i = i-1 end
|
||||
if self.marks[i] == p.y then return end
|
||||
self.target = self.marks[i]
|
||||
self:set_direction(-1)
|
||||
end
|
||||
else self:set_direction(0) -- uncomment it if elevators mustn't be stopped from the interior
|
||||
end
|
||||
elseif puncher:get_wielded_item():get_name() == "technology:wrench" then
|
||||
puncher:get_inventory():add_item("technology:elevator", 1)
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function elevator:on_rightclick(clicker)
|
||||
if self:is_player_inside(clicker) then -- the passenger exits
|
||||
local y = yaw(clicker)
|
||||
local pos = self.object:getpos()
|
||||
local p = {
|
||||
x=pos.x + -(elevator_radius+0.5)*math.sin(y),
|
||||
y=pos.y+0.5,
|
||||
z=pos.z + -(elevator_radius+0.5)*-math.cos(y)
|
||||
}
|
||||
if (not minetest.get_node({x=p.x, y=pos.y, z=p.z}).walkable) and
|
||||
(not minetest.get_node({x=p.x, y=pos.y+1, z=p.z}).walkable) then
|
||||
|
||||
clicker:setpos(p)
|
||||
clicker:set_detach(self.object)
|
||||
for i,passenger in pairs(self.passengers) do if passenger==clicker then break end end
|
||||
table.remove(self.passengers, i)
|
||||
minetest.after(0.2, function()
|
||||
clicker:setpos(p)
|
||||
end)
|
||||
else
|
||||
minetest.chat_send_player(clicker:get_player_name(), "area is too small to bail out")
|
||||
end
|
||||
else -- the player enter the elevator
|
||||
-- the program comes here if the clicker is not a passenger
|
||||
-- make it become one
|
||||
table.insert(self.passengers, clicker)
|
||||
clicker:set_attach(self.object, "", {x=0,y=0,z=10}, {x=0,y=0,z=-10})
|
||||
end
|
||||
end
|
||||
|
||||
function elevator:on_step(dtime)
|
||||
-- check up for direction change
|
||||
if self.direction_change then
|
||||
self.object:set_velocity({x=0,y=self.direction*elevator_speed,z=0})
|
||||
self.direction_change = false
|
||||
else
|
||||
-- wait for a stop
|
||||
local p = self.object:getpos()
|
||||
if self.direction > 0 and p.y+elevator_speed*dtime >= self.target then
|
||||
self.object:setpos({x=p.x, y=self.target, z=p.z})
|
||||
self.object:set_velocity({x=0, y=0, z=0})
|
||||
self:set_direction(0)
|
||||
elseif self.direction < 0 and p.y-elevator_speed*dtime <= self.target then
|
||||
self.object:setpos({x=p.x, y=self.target, z=p.z})
|
||||
self.object:set_velocity({x=0, y=0, z=0})
|
||||
self:set_direction(0)
|
||||
end
|
||||
end
|
||||
|
||||
if self.object:get_hp() <= 5 then
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local r = elevator_radius+0.7
|
||||
local elevator_marks_slots = { {r,-0.5},{r,0.5}, {-0.5,r},{0.5,r}, {-r,-0.5},{-r,0.5}, {-0.5,-r},{0.5,-r} }
|
||||
local elevator_mark_height = 1.5
|
||||
|
||||
function elevator:regenerate_marks()
|
||||
local y = self.object:getyaw()
|
||||
local p = self.object:getpos()
|
||||
rail_x = p.x + (elevator_radius+1) * math.cos(y) -- rail on the side
|
||||
rail_z = p.z + (elevator_radius+1) * math.sin(y)
|
||||
rail_y = p.y+elevator_mark_height+1
|
||||
while minetest.get_node({x=rail_x, y=rail_y, z=rail_z}).name == elevator_rail do
|
||||
for i,place in pairs(elevator_marks_slots) do
|
||||
if minetest.get_node({x=p.x + place[1], y=rail_y, z=p.z + place[2]}).name == elevator_mark then
|
||||
table.insert(self.marks, rail_y-elevator_mark_height)
|
||||
break
|
||||
end
|
||||
end
|
||||
rail_y = rail_y+1
|
||||
end
|
||||
rail_y = p.y+elevator_mark_height-1
|
||||
while minetest.get_node({x=rail_x, y=rail_y, z=rail_z}).name == elevator_rail do
|
||||
for i,place in pairs(elevator_marks_slots) do
|
||||
if minetest.get_node({x=p.x + place[1], y=rail_y, z=p.z + place[2]}).name == elevator_mark then
|
||||
table.insert(self.marks, 1, rail_y-elevator_mark_height)
|
||||
break
|
||||
end
|
||||
end
|
||||
rail_y = rail_y-1
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_entity(elevator_entity, elevator)
|
||||
|
||||
minetest.register_craftitem("technology:elevator", {
|
||||
description = "Elevator",
|
||||
inventory_image="technology_elevator.png",
|
||||
wield_image = "technology_elevator.png",
|
||||
wield_scale = {x=6, y=6, z=2},
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local p = pointed_thing.under
|
||||
local y = yaw(placer)
|
||||
-- select direction to place to
|
||||
print(y)
|
||||
local o = 0
|
||||
if 7*math.pi/4 < y or y <= math.pi/4 then o = 0
|
||||
elseif math.pi/4 < y and y <= 3*math.pi/4 then o = math.pi/2
|
||||
elseif 3*math.pi/4 < y and y <= 5*math.pi/4 then o = math.pi
|
||||
else o = 3*math.pi/2
|
||||
end
|
||||
p.y = p.y + 0.5
|
||||
p.x = p.x + 1.5*math.sin(o) + 0.5*math.cos(o)
|
||||
p.z = p.z - 1.5*math.cos(o) + 0.5*math.sin(o)
|
||||
local obj = minetest.add_entity(p, elevator_entity)
|
||||
obj:setyaw(o)
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
|
||||
local ec = 0.05 -- size of electric cables
|
||||
local sc = 0.1 -- size of support cables
|
||||
local zmin = -0.5
|
||||
local zmax = 0.5
|
||||
minetest.register_node("technology:elevator_rail", {
|
||||
description = "Vertical rail for elevator",
|
||||
--inventory_image = "technology_elevator_rail.png",
|
||||
--wield_image = "technology_elevator_rail.png",
|
||||
node_placement_prediction = "",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drawtype = "nodebox",
|
||||
node_box = {type = "fixed", fixed = {
|
||||
{ -0.05, zmin, 0.2, 0.05, zmax, 0.5 }, -- guidance rail
|
||||
{ -0.1, zmin, 0.45, 0.1, zmax, 0.5 }, -- guidance rail part 2
|
||||
{ 0.4, zmin, -0.1, 0.4+sc, zmax, -0.1+sc }, -- support cable
|
||||
{ -0.3, zmin, 0.4, -0.3+ec, zmax, 0.4+ec }, -- electric cable
|
||||
{ -0.4, zmin, 0.4, -0.4+ec, zmax, 0.4+ec }, -- electric cable
|
||||
}},
|
||||
selection_box = {type = "fixed", fixed = {
|
||||
{-0.5, zmin, 0.2, 0.5, zmax, 0.5},
|
||||
}},
|
||||
tiles = {
|
||||
"technology_elevator_rail_front.png", --top
|
||||
"technology_elevator_rail_front.png", --bottom
|
||||
"technology_elevator_rail_right.png", --right
|
||||
"technology_elevator_rail_left.png", --left
|
||||
"technology_elevator_rail_back.png", --back
|
||||
"technology_elevator_rail_front.png" --front
|
||||
},
|
||||
walkable = true,
|
||||
groups = {mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
})
|
||||
|
||||
technology.register_plan("ELEVATOR", "technology:elevator", nil, {
|
||||
"technic:hv_transformer",
|
||||
"technic:motor 1",
|
||||
"technology:wire 2",
|
||||
"default:bronze_ingot 6",
|
||||
})
|
||||
|
||||
technology.register_plan("ELEVATOR_RAIL", "technology:elevator_rail", nil, {
|
||||
"technology:wire 1",
|
||||
"default:steel_ingot 1",
|
||||
})
|
17
init.lua
17
init.lua
|
@ -16,12 +16,11 @@ minetest.register_craftitem("technology:plastic", {
|
|||
inventory_image = "plastic_item.png",
|
||||
})
|
||||
|
||||
dofile(minetest.get_modpath("technology").."/tools.lua")
|
||||
|
||||
dofile(minetest.get_modpath("technology").."/structures.lua")
|
||||
|
||||
dofile(minetest.get_modpath("technology").."/electric_nodes.lua")
|
||||
|
||||
dofile(minetest.get_modpath("technology").."/aircraft.lua")
|
||||
|
||||
dofile(minetest.get_modpath("technology").."/screen.lua")
|
||||
local technology_path = minetest.get_modpath("technology")
|
||||
dofile(technology_path.."/plans.lua")
|
||||
dofile(technology_path.."/tools.lua")
|
||||
dofile(technology_path.."/structures.lua")
|
||||
dofile(technology_path.."/electric_nodes.lua")
|
||||
dofile(technology_path.."/aircraft.lua")
|
||||
dofile(technology_path.."/elevator.lua")
|
||||
dofile(technology_path.."/screen.lua")
|
||||
|
|
51
plans.lua
Normal file
51
plans.lua
Normal file
|
@ -0,0 +1,51 @@
|
|||
|
||||
|
||||
technology.registered_plans = {}
|
||||
|
||||
technology.register_plan = function (machine_name, machine_item, sketch_image, components)
|
||||
local item_name = "technology:plan_"..machine_name
|
||||
local sketch = sketch_image or "technology_plan_default.png"
|
||||
|
||||
minetest.register_node(":"..item_name, {
|
||||
description = "overall plan for "..machine_name,
|
||||
drawtype = "signlike",
|
||||
tile_images = {sketch},
|
||||
inventory_image = sketch,
|
||||
wield_image = sketch,
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
metadata_name = "sign",
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
--wall_top = <default>
|
||||
--wall_bottom = <default>
|
||||
--wall_side = <default>
|
||||
},
|
||||
groups = {choppy=2,dig_immediate=2,flammable=2},
|
||||
legacy_wallmounted = true,
|
||||
--sounds = default.node_sound_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec", "field[text;;${text}]")
|
||||
meta:set_string("infotext", machine_name)
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
fields.text = fields.text or ""
|
||||
meta:set_string("text", fields.text)
|
||||
meta:set_string("infotext", machine_name..' ['..fields.text..']')
|
||||
end,
|
||||
})
|
||||
|
||||
components[#components+1] = item_name
|
||||
minetest.register_craft({
|
||||
output = machine_item,
|
||||
type = "shapeless",
|
||||
recipe = components,
|
||||
})
|
||||
|
||||
technology.registered_plans[machine_name] = {item_name, machine_item, components}
|
||||
end
|
||||
|
31
screen.lua
31
screen.lua
|
@ -3,6 +3,7 @@ local screens = {
|
|||
"technology:flat_screen_on",
|
||||
"technology:flat_screen_text",
|
||||
"technology:flat_screen_compiling",
|
||||
"technology:flat_screen_design",
|
||||
}
|
||||
|
||||
-- crafting
|
||||
|
@ -135,6 +136,36 @@ minetest.register_node("technology:flat_screen_compiling", {
|
|||
drop = 'technology:flat_screen_off',
|
||||
})
|
||||
|
||||
minetest.register_node("technology:flat_screen_design", {
|
||||
description = "modern screen",
|
||||
node_placement_prediction = "",
|
||||
paramtype = "light",
|
||||
light_source = 3,
|
||||
paramtype2 = "facedir",
|
||||
drawtype = "nodebox",
|
||||
node_box = {type = "fixed", fixed = {
|
||||
{-0.45, -0.4, 0.3, 0.45, 0.3, 0.25},
|
||||
{-0.35, -0.35, 0.3, 0.35, 0.25, 0.4},
|
||||
}},
|
||||
selection_box = {type = "fixed", fixed = {
|
||||
{-0.45, -0.4, 0.3, 0.45, 0.3, 0.25},
|
||||
{-0.35, -0.35, 0.3, 0.35, 0.25, 0.4},
|
||||
}},
|
||||
tiles = {"screen_flat_top.png", "screen_flat_bottom.png", "screen_flat_left.png",
|
||||
"screen_flat_right.png", "screen_flat_back.png", {
|
||||
image="screen_flat_animated_design.png",
|
||||
backface_culling=false,
|
||||
animation={type="vertical_frames", aspect_w=128, aspect_h=128, length=5}
|
||||
}},
|
||||
walkable = true,
|
||||
groups = {choppy=2, dig_immediate=2},
|
||||
on_punch = function(pos, node, puncher)
|
||||
node.name = "technology:flat_screen_off"
|
||||
minetest.set_node(pos, node)
|
||||
end,
|
||||
drop = 'technology:flat_screen_off',
|
||||
})
|
||||
|
||||
|
||||
local old_screens = {"technology:flat_screen_smalltext",
|
||||
"technology:flat_screen_bigtext", "technology:flat_screen_2columns", "technology:flat_screen_map",
|
||||
|
|
|
@ -93,7 +93,7 @@ minetest.register_node("technology:armature_h", {
|
|||
}},
|
||||
tiles = {"steel_armature_top.png", "steel_armature_top.png", "steel_armature_top.png", "steel_armature_top.png", "steel_armature_h_side.png", "steel_armature_h_side.png"},
|
||||
walkable = true,
|
||||
groups = {mecanic=1},
|
||||
groups = {mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
})
|
||||
|
@ -117,7 +117,7 @@ minetest.register_node("technology:armature_v", {
|
|||
}},
|
||||
tiles = {"steel_armature_top.png", "steel_armature_top.png", "steel_armature_top.png", "steel_armature_top.png", "steel_armature_v_side.png", "steel_armature_v_side.png"},
|
||||
walkable = true,
|
||||
groups = {mecanic=1},
|
||||
groups = {mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
})
|
||||
|
@ -140,7 +140,7 @@ minetest.register_node("technology:grid_v", {
|
|||
}},
|
||||
tiles = {"bronze_grid_side.png", "bronze_grid_side.png", "bronze_grid_side.png", "bronze_grid_side.png", "bronze_grid_front.png", "steel_grid_front.png"},
|
||||
walkable = true,
|
||||
groups = {paffy=2},
|
||||
groups = {mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
})
|
||||
|
@ -163,7 +163,7 @@ minetest.register_node("technology:grid_h", {
|
|||
}},
|
||||
tiles = {"bronze_grid_side.png", "bronze_grid_front.png", "bronze_grid_side.png", "bronze_grid_front.png", "bronze_grid_side.png", "steel_grid_side.png"},
|
||||
walkable = true,
|
||||
groups = {paffy=2},
|
||||
groups = {mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
})
|
||||
|
@ -243,7 +243,7 @@ minetest.register_node("technology:floor", {
|
|||
}},
|
||||
tiles = {"floor_top.png", "floor_bottom.png", "floor_side.png", "floor_side.png", "floor_side.png", "floor_side.png"},
|
||||
walkable = true,
|
||||
groups = {paffly=2, mecanic=1},
|
||||
groups = {paffly=2, mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
})
|
||||
|
@ -274,7 +274,7 @@ minetest.register_node("technology:stairs", {
|
|||
}},
|
||||
tiles = {"floor_top.png", "floor_bottom.png", "floor_side.png", "floor_side.png", "floor_side.png", "floor_side.png"},
|
||||
walkable = true,
|
||||
groups = {paffly=2, mecanic=1},
|
||||
groups = {paffly=2, mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
})
|
||||
|
@ -296,7 +296,7 @@ minetest.register_node("technology:edge", {
|
|||
}},
|
||||
tiles = {"edge_side.png", "edge_side.png", "edge_side.png", "edge_side.png", "edge_side.png", "edge_side.png"},
|
||||
walkable = true,
|
||||
groups = {paffly=2, mecanic=1},
|
||||
groups = {paffly=2, mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
})
|
||||
|
@ -322,7 +322,7 @@ minetest.register_node("technology:edge_angle", {
|
|||
}},
|
||||
tiles = {"edge_side.png", "edge_side.png", "edge_side.png", "edge_side.png", "edge_side.png", "edge_side.png"},
|
||||
walkable = true,
|
||||
groups = {paffly=2, mecanic=1},
|
||||
groups = {paffly=2, mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
drop = "technology:edge",
|
||||
|
@ -344,7 +344,7 @@ minetest.register_node("technology:triangle", {
|
|||
}},
|
||||
tiles = {"triangle_side.png", "triangle_side.png", "triangle_right.png", "triangle_left.png", "triangle_side.png", "triangle_side.png"},
|
||||
walkable = true,
|
||||
groups = {paffly=2, mecanic=1},
|
||||
groups = {paffly=2, mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
})
|
||||
|
@ -379,7 +379,7 @@ minetest.register_node("technology:ladder", {
|
|||
tiles = {"technology_ladder.png", "technology_ladder.png", "technology_ladder.png", "technology_ladder.png", "technology_ladder.png", "technology_ladder.png"},
|
||||
walkable = true,
|
||||
climbable = true,
|
||||
groups = {paffly=2, mecanic=1},
|
||||
groups = {paffly=2, mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
})
|
||||
|
@ -422,7 +422,7 @@ minetest.register_node("technology:ladder_closed", {
|
|||
tiles = {"technology_ladder.png", "technology_ladder.png", "technology_ladder.png", "technology_ladder.png", "technology_ladder.png", "technology_ladder.png"},
|
||||
walkable = true,
|
||||
climbable = true,
|
||||
groups = {paffly=2, mecanic=1},
|
||||
groups = {paffly=2, mecanic=1, oddly_breakable_by_hand=1},
|
||||
on_punch = metal_punch,
|
||||
sounds = metal_footstep,
|
||||
})
|
||||
|
|
|
@ -27,7 +27,7 @@ minetest.register_craft({
|
|||
{'', '', 'technology:plastic'},
|
||||
}
|
||||
})
|
||||
|
||||
--[[
|
||||
minetest.register_tool("technology:jackhammer", {
|
||||
description = "Jackhammer",
|
||||
inventory_image = "jackhammer.png",
|
||||
|
@ -38,7 +38,7 @@ minetest.register_tool("technology:jackhammer", {
|
|||
}
|
||||
},
|
||||
})
|
||||
|
||||
]]
|
||||
minetest.register_node("technology:jackhammer", {
|
||||
description = "Jackhammer",
|
||||
inventory_image = "jackhammer.png",
|
||||
|
|
Loading…
Reference in New Issue
Block a user