From 40b2d8ccb61143bf724db73ea0a4ef1d181923b3 Mon Sep 17 00:00:00 2001 From: D00Med Date: Fri, 3 Feb 2017 10:41:50 +1000 Subject: [PATCH] Lightcycle and api changes --- api.lua | 31 +++++++ init.lua | 126 ++++++++++++++++++++++++++ models/lightcycle.b3d | Bin 0 -> 5639 bytes readme.txt | 13 +++ textures/vehicles_lightblock.png | Bin 0 -> 154 bytes textures/vehicles_lightblock2.png | Bin 0 -> 157 bytes textures/vehicles_lightcycle.png | Bin 0 -> 428 bytes textures/vehicles_lightcycle2.png | Bin 0 -> 449 bytes textures/vehicles_lightcycle_inv.png | Bin 0 -> 302 bytes textures/vehicles_lightcycle_inv2.png | Bin 0 -> 319 bytes 10 files changed, 170 insertions(+) create mode 100644 models/lightcycle.b3d create mode 100644 textures/vehicles_lightblock.png create mode 100644 textures/vehicles_lightblock2.png create mode 100644 textures/vehicles_lightcycle.png create mode 100644 textures/vehicles_lightcycle2.png create mode 100644 textures/vehicles_lightcycle_inv.png create mode 100644 textures/vehicles_lightcycle_inv2.png diff --git a/api.lua b/api.lua index 5903fc6..44edec5 100644 --- a/api.lua +++ b/api.lua @@ -135,6 +135,11 @@ function vehicles.object_drive(entity, dtime, def) local driving_sound = def.driving_sound or nil local sound_duration = def.sound_duration or 5 local extra_yaw = def.extra_yaw or 0 + local death_node = def.death_node or nil + local destroy_node = def.destroy_node or nil + local place_node = def.place_node or nil + local place_chance = def.place_chance or 1 + local place_trigger = def.place_trigger or nil local moving_anim = def.moving_anim local stand_anim = def.stand_anim @@ -197,6 +202,32 @@ function vehicles.object_drive(entity, dtime, def) end) end + --death_node + if death_node ~= nil and node == death_node then + if entity.driver then + vehicles.object_detach(entity, entity.driver, {x=1, y=0, z=1}) + end + vehicles.explodinate(entity, 5) + entity.object:remove() + return + end + + --place node + if place_node ~= nil and node == "air" or place_node ~= nil and node == "default:snow" or place_node ~= nil and minetest.get_item_group(node, "flora") ~= 0 then + if place_trigger == nil and math.random(1, place_chance) == 1 then + minetest.set_node(pos, {name=place_node}) + end + if place_trigger ~= nil and ctrl.sneak then + minetest.set_node(pos, {name=place_node}) + end + end + + --destroy node + if destroy_node ~= nil and node == destroy_node then + minetest.remove_node(pos) + end + + --lava explode if node == "default:lava_source" or node == "default:lava_flowing" then if entity.driver then vehicles.object_detach(entity, entity.driver, {x=1, y=0, z=1}) diff --git a/init.lua b/init.lua index b258466..02701c8 100644 --- a/init.lua +++ b/init.lua @@ -1324,6 +1324,82 @@ minetest.register_entity("vehicles:pooshe2", { vehicles.register_spawner("vehicles:pooshe2", S("Pooshe (yellow)"), "vehicles_pooshe_inv2.png") +minetest.register_entity("vehicles:lightcycle", { + visual = "mesh", + mesh = "lightcycle.b3d", + textures = {"vehicles_lightcycle.png"}, + velocity = 15, + acceleration = -5, + stepheight = step, + hp_max = 200, + physical = true, + collisionbox = {-1, 0, -1, 1.3, 1, 1}, + on_rightclick = function(self, clicker) + if self.driver and clicker == self.driver then + vehicles.object_detach(self, clicker, {x=1, y=0, z=1}) + elseif not self.driver then + vehicles.object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4}) + self.sound_ready = true + end + end, + on_activate = function(self) + self.nitro = true + end, + on_punch = vehicles.on_punch, + on_step = function(self, dtime) + return vehicles.on_step(self, dtime, { + speed = 22, + decell = 0.85, + boost = true, + boost_duration = 4, + boost_effect = "vehicles_nitro.png", + place_node = "vehicles:light_barrier", + place_trigger = true, + death_node = "vehicles:light_barrier2", + }) + end, +}) + +vehicles.register_spawner("vehicles:lightcycle", S("Lightcycle"), "vehicles_lightcycle_inv.png") + +minetest.register_entity("vehicles:lightcycle2", { + visual = "mesh", + mesh = "lightcycle.b3d", + textures = {"vehicles_lightcycle2.png"}, + velocity = 15, + acceleration = -5, + stepheight = step, + hp_max = 200, + physical = true, + collisionbox = {-1, 0, -1, 1.3, 1, 1}, + on_rightclick = function(self, clicker) + if self.driver and clicker == self.driver then + vehicles.object_detach(self, clicker, {x=1, y=0, z=1}) + elseif not self.driver then + vehicles.object_attach(self, clicker, {x=0, y=5, z=4}, false, {x=0, y=2, z=4}) + self.sound_ready = true + end + end, + on_activate = function(self) + self.nitro = true + end, + on_punch = vehicles.on_punch, + on_step = function(self, dtime) + return vehicles.on_step(self, dtime, { + speed = 22, + decell = 0.85, + boost = true, + boost_duration = 4, + boost_effect = "vehicles_nitro.png", + place_node = "vehicles:light_barrier2", + place_trigger = true, + death_node = "vehicles:light_barrier", + }) + end, +}) + +vehicles.register_spawner("vehicles:lightcycle2", S("Lightcycle 2"), "vehicles_lightcycle_inv2.png") + minetest.register_entity("vehicles:boat", { visual = "mesh", mesh = "boat.b3d", @@ -2287,6 +2363,56 @@ minetest.register_node("vehicles:tyres", { }, groups = {cracky=1, falling_node=1}, }) + +minetest.register_node("vehicles:light_barrier", { + description = S("Light Barrier"), + tiles = {"vehicles_lightblock.png",}, + use_texture_alpha = true, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + walkable = false, + light_source = 9, + is_ground_content = true, + groups = {cracky=3,dig_immediate=3,not_in_creative_inventory=1}, + on_construct = function(pos, node) + minetest.after(4, function() + if pos ~= nil then + minetest:remove_node(pos) + end + end) + end, +}) + +minetest.register_node("vehicles:light_barrier2", { + description = S("Light Barrier 2"), + tiles = {"vehicles_lightblock2.png",}, + use_texture_alpha = true, + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + walkable = false, + light_source = 9, + is_ground_content = true, + groups = {cracky=3,dig_immediate=3,not_in_creative_inventory=1}, + on_construct = function(pos, node) + minetest.after(4, function() + if pos ~= nil then + minetest:remove_node(pos) + end + end) + end, +}) + +minetest.register_abm({ + nodenames = {"vehicles:light_barrier", "vehicles:light_barrier2"}, + interval = 4, + chance = 1, + action = function(pos, node) + minetest.remove_node(pos) + end +}) + end--if minetest.setting_get("vehicles_nodes") then end--if enable_built_in then diff --git a/models/lightcycle.b3d b/models/lightcycle.b3d new file mode 100644 index 0000000000000000000000000000000000000000..b5cfd3357f80447f6277086499cf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