diff --git a/mopackd.conf b/mopackd.conf new file mode 100644 index 0000000..2967c34 --- /dev/null +++ b/mopackd.conf @@ -0,0 +1,16 @@ +name = space +description = Space + + + + + + + + + + + + + + diff --git a/space/init.lua b/space/init.lua new file mode 100644 index 0000000..d1de912 --- /dev/null +++ b/space/init.lua @@ -0,0 +1,83 @@ +space={timer=0,player={},y=2000,y2=4000} +dofile(minetest.get_modpath("space") .. "/mapgen.lua") +space.setgrav=function(player,grav) + player:set_physics_override({gravity=grav}) + local aa= 1 - ((1-grav)*0.4) + player:set_physics_override({jump=aa}) +end + +minetest.register_globalstep(function(dtime) + space.timer=space.timer+dtime + if space.timer<5 then return end + space.timer=0 + local pos + local name + for i, player in pairs(minetest.get_connected_players()) do + pos=player:getpos().y + name=player:get_player_name() + if posspace.y2 and space.player[name]~=2 then + space.toggle(player) + end + end +end) + +space.toggle=function(player) + local name=player:get_player_name() + local pos=player:getpos().y + if posspace.y2 then + space.player[name]=2 + space.setgrav(player,0.1) + minetest.after(0.1,function() + player:set_sky({r=0, g=0, b=0},"skybox",{"space_sky.png","space_sky.png","space_sky.png","space_sky.png","space_sky.png","space_sky.png"}) + player:set_clouds({density=0,speed=0}) + end) + end +end +minetest.register_on_respawnplayer(function(player) + minetest.after(0.1,function() + space.toggle(player) + end) +end) +minetest.register_on_leaveplayer(function(player) + local name=player:get_player_name() + space.player[name]=nil +end) +minetest.register_on_joinplayer(function(player) + local name=player:get_player_name() + space.player[name]=0 + minetest.after(0.1,function() + space.toggle(player) + end) +end) + +minetest.register_craft({ + output = "space:water", + recipe = { + {"default:ice"}, + } +}) diff --git a/space/mapgen.lua b/space/mapgen.lua new file mode 100644 index 0000000..489596b --- /dev/null +++ b/space/mapgen.lua @@ -0,0 +1,136 @@ +minetest.register_node("space:air", { + description = "Air", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + post_effect_color = {a = 20, r = 220, g = 200, b = 100}, + groups = {msa=1,not_in_creative_inventory=0}, + paramtype = "light", + sunlight_propagates =true, + drawtype = "glasslike", + tiles = {"default_cloud.png^[colorize:#E0E0E033"}, + alpha = 0.1, +}) + +minetest.register_node("space:water", { + description = "Space water", + drawtype = "liquid", + tiles = {"default_water.png"}, + alpha = 160, + paramtype = "light", + walkable = false, + liquid_viscosity = 1, + liquidtype = "source", + liquid_alternative_flowing="space:water", + liquid_alternative_source="space:water", + liquid_renewable = false, + liquid_range = 0, + drowning = 1, + sunlight_propagates = true, + post_effect_color = {a = 103, r = 30, g = 60, b = 90}, + groups = {water = 3, liquid = 3, puts_out_fire = 1,crumbly = 3}, +}) + +minetest.register_node("space:astroid_spawner", { + description = "Astroid spawner", + drawtype="airlike", + groups = {not_in_creative_inventory=1} +}) + +minetest.register_node("space:ore_pawner", { + description = "Ore spawner", + drawtype="airlike", + groups = {not_in_creative_inventory=1} +}) + +minetest.register_node("space:moon_stone", { + description = "Moon stone", + tiles = {"default_gravel.png^[colorize:#ffffff22"}, + groups = {spacestuff=1,cracky = 2}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("space:stone", { + description = "Stone", + tiles = {"default_stone.png"}, + groups = {cracky = 1,stone=1,spacestuff=1}, + sounds = default.node_sound_stone_defaults(), + drop="default:cobble" +}) + +minetest.register_lbm({ + name="space:astroid_spawners", + nodenames = {"space:astroid_spawner"}, + run_at_every_load = true, + action = function(pos, node) + minetest.set_node(pos, {name = "default:stone"}) + if minetest.find_node_near(pos, 10,{"group:spacestuff"}) then return end + local r=math.random(1,10) + if r>5 then r=math.random(1,10) end + if r>6 then r=math.random(1,10) end + local t=minetest.get_modpath("space").."/schematics/space_astroid" .. r .. ".mts" + minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z}, t,"random",nil,false) + end, +}) + +minetest.register_lbm({ + name="space:ore_pawners", + nodenames = {"space:ore_pawner"}, + run_at_every_load = true, + action = function(pos, node) + local r=math.random(1,8) + if space.ores[r].scarcity==6 then r=math.random(1,8) end + minetest.set_node(pos, {name = space.ores[r].ore}) + end, +}) + +minetest.register_ore({ + ore_type = "scatter", + ore = "default:stone", + wherein = "air", + clust_scarcity = 80 * 80 * 80, + clust_num_ores = 1, + clust_size = 1, + y_min = space.y, + y_max = 31000, +}) + +space.ores={ +{scarcity=6,ore="space:water"}, +{scarcity=6,ore="default:ice"}, +{scarcity=6,ore="default:stone_with_diamond"}, +{scarcity=6,ore="default:stone_with_mese"}, +{scarcity=6,ore="default:stone_with_gold"}, +{scarcity=5,ore="default:stone_with_copper"}, +{scarcity=4,ore="default:stone_with_iron"}, +{scarcity=2,ore="default:stone_with_coal"}, +{scarcity=1,ore="space:astroid_spawner"}, +} + +for i, ore in pairs(space.ores) do +minetest.register_ore({ + ore_type = "scatter", + ore = ore.ore, + wherein = "default:stone", + clust_scarcity = ore.scarcity * ore.scarcity * ore.scarcity, + clust_num_ores = 1, + clust_size = 1, + y_min = space.y, + y_max =31000, +}) +if ore.scarcity~=1 then + minetest.register_ore({ + ore_type = "scatter", + ore = ore.ore, + wherein = "space:stone", + clust_scarcity = (ore.scarcity*3) * (ore.scarcity*3) * (ore.scarcity*3), + clust_num_ores = 1, + clust_size = 1, + y_min = space.y, + y_max = 31000, + }) +end +end + +space.ores[8]={scarcity=2,ore="default:stone"} \ No newline at end of file diff --git a/space/mod.conf b/space/mod.conf new file mode 100644 index 0000000..80326bd --- /dev/null +++ b/space/mod.conf @@ -0,0 +1,3 @@ +name = space +description = Space + depends = default \ No newline at end of file diff --git a/space/schematics/space_astroid1.mts b/space/schematics/space_astroid1.mts new file mode 100644 index 0000000..01b9950 Binary files /dev/null and b/space/schematics/space_astroid1.mts differ diff --git a/space/schematics/space_astroid10.mts b/space/schematics/space_astroid10.mts new file mode 100644 index 0000000..079035a Binary files /dev/null and b/space/schematics/space_astroid10.mts differ diff --git a/space/schematics/space_astroid2.mts b/space/schematics/space_astroid2.mts new file mode 100644 index 0000000..9cc8df8 Binary files /dev/null and b/space/schematics/space_astroid2.mts differ diff --git a/space/schematics/space_astroid3.mts b/space/schematics/space_astroid3.mts new file mode 100644 index 0000000..3a7c4f0 Binary files /dev/null and b/space/schematics/space_astroid3.mts differ diff --git a/space/schematics/space_astroid4.mts b/space/schematics/space_astroid4.mts new file mode 100644 index 0000000..08853ad Binary files /dev/null and b/space/schematics/space_astroid4.mts differ diff --git a/space/schematics/space_astroid5.mts b/space/schematics/space_astroid5.mts new file mode 100644 index 0000000..bfb43c8 Binary files /dev/null and b/space/schematics/space_astroid5.mts differ diff --git a/space/schematics/space_astroid6.mts b/space/schematics/space_astroid6.mts new file mode 100644 index 0000000..134462b Binary files /dev/null and b/space/schematics/space_astroid6.mts differ diff --git a/space/schematics/space_astroid7.mts b/space/schematics/space_astroid7.mts new file mode 100644 index 0000000..beda49a Binary files /dev/null and b/space/schematics/space_astroid7.mts differ diff --git a/space/schematics/space_astroid8.mts b/space/schematics/space_astroid8.mts new file mode 100644 index 0000000..d598c04 Binary files /dev/null and b/space/schematics/space_astroid8.mts differ diff --git a/space/schematics/space_astroid9.mts b/space/schematics/space_astroid9.mts new file mode 100644 index 0000000..5b04647 Binary files /dev/null and b/space/schematics/space_astroid9.mts differ diff --git a/space/schematics/space_lightfix.mts b/space/schematics/space_lightfix.mts new file mode 100644 index 0000000..bc80cd1 Binary files /dev/null and b/space/schematics/space_lightfix.mts differ diff --git a/space/schematics/space_moon.mts b/space/schematics/space_moon.mts new file mode 100644 index 0000000..334cdcc Binary files /dev/null and b/space/schematics/space_moon.mts differ diff --git a/space/schematics/space_plant.mts b/space/schematics/space_plant.mts new file mode 100644 index 0000000..607e5cd Binary files /dev/null and b/space/schematics/space_plant.mts differ diff --git a/space/textures/space_sky.png b/space/textures/space_sky.png new file mode 100644 index 0000000..8c73108 Binary files /dev/null and b/space/textures/space_sky.png differ diff --git a/space/textures/space_sky2.png b/space/textures/space_sky2.png new file mode 100644 index 0000000..a83ac22 Binary files /dev/null and b/space/textures/space_sky2.png differ diff --git a/space_moon/init.lua b/space_moon/init.lua new file mode 100644 index 0000000..02e5b73 --- /dev/null +++ b/space_moon/init.lua @@ -0,0 +1,10 @@ +minetest.after(1,function() + local pos={x=0,y=space.y+500,z=0} + local n=minetest.get_node(pos) + if n and n.name=="ignore" then + minetest.set_node(pos, {name = "default:stone"}) + local t=minetest.get_modpath("space").."/schematics/space_moon.mts" + minetest.place_schematic(pos, t) + minetest.log("Space: Moon spawned") + end +end) \ No newline at end of file diff --git a/space_moon/mod.conf b/space_moon/mod.conf new file mode 100644 index 0000000..e1cdcb2 --- /dev/null +++ b/space_moon/mod.conf @@ -0,0 +1,3 @@ +name = space_moon +description = Moon + depends = space \ No newline at end of file diff --git a/space_planets/init.lua b/space_planets/init.lua new file mode 100644 index 0000000..9f44e90 --- /dev/null +++ b/space_planets/init.lua @@ -0,0 +1,204 @@ +space.planet_last={x=0,y=0,z=0} + +minetest.register_ore({ + ore_type = "scatter", + ore = "space_planets:planet_spawner", + wherein = "default:stone", + clust_scarcity = 3 * 3 * 3, + clust_num_ores = 1, + clust_size = 1, + y_min = space.y2+100, + y_max = 31000, +}) + +minetest.register_node("space_planets:planet_earthlike", { + description = "Planet earthlike", + drawtype="airlike", + sunlight_propagates =true, +}) +minetest.register_node("space_planets:planet_desert", { + description = "Planet desert", + drawtype="airlike", + sunlight_propagates =true, +}) +minetest.register_node("space_planets:planet_cool", { + description = "Planet cool", + drawtype="airlike", + sunlight_propagates =true, +}) +minetest.register_node("space_planets:planet_rnd", { + description = "Planet rnd", + drawtype="airlike", + sunlight_propagates =true, +}) +minetest.register_node("space_planets:planet_dryearth", { + description = "Planet dryearth", + drawtype="airlike", + sunlight_propagates =true, +}) + +minetest.register_node("space_planets:planet_spawner", { + description = "Planet spawner", + tiles = {"default_cloud.png^[colorize:#19ffd655"}, + paramtype = "light", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-1,-1,-1,1,1,1}, + } + }, +}) + +minetest.register_abm({ + nodenames = {"space_planets:planet_spawner"}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + minetest.set_node(pos, {name = "air"}) + local rs=vector.distance(pos,space.planet_last) + print("distance to last planet: " .. rs) + if rs < 1000 or minetest.find_node_near(pos, 200,{"group:spacestuff"}) then print("planet spawning failed") return end + print("planet is spawning") + space.planet_last=pos + local r=math.random(1,5) + local c=math.random(1,17) + local planet={} + local t=minetest.get_modpath("space").."/schematics/space_plant.mts" + planet[1]={grass="default:dirt_with_grass",dirt="default:dirt",deco="space_planets:planet_earthlike",stone="space:stone"} + planet[2]={grass="default:desert_sand",dirt="default:desert_sand",deco="space_planets:planet_desert",stone="default:desert_stone"} + planet[3]={grass="default:snowblock",dirt="default:snowblock",deco="space_planets:planet_cool",stone="space:stone"} + planet[4]={grass="",dirt="",deco="space_planets:planet_rnd",stone="space:stone"} + planet[5]={grass="default:dirt_with_dry_grass",dirt="default:dirt",deco="space_planets:planet_dryearth",stone="space:stone"} + + planet=planet[r] + + if r==4 then + local stuff={"default:cobble","default:dirt_with_dry_grass","default:stone","default:dirt_with_grass","default:cactus","default:ice","default:clay","default:gravel","default:desert_sand","default:sand","default:obsidian","default:sandstone","default:desert_cobble","space:moon_stone"} + planet.dirt=stuff[math.random(1,14)] + planet.grass=stuff[math.random(1,14)] + end + + local elemets={["space:stone"]=planet.stone,["default:cobble"]=planet.grass,["default:wood"]=planet.dirt,["default:junglewood"]=planet.deco} + + minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z}, t,"0",elemets,true) + + minetest.after(1,function(elemets,t,pos) + minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z-170}, t,"90",elemets,true) + end,elemets,t,pos) + minetest.after(2,function(elemets,t,pos) + minetest.place_schematic({x=pos.x-170,y=pos.y,z=pos.z-170}, t,"180",elemets,true) + end,elemets,t,pos) + minetest.after(3,function(elemets,t,pos) + minetest.place_schematic({x=pos.x-170,y=pos.y,z=pos.z}, t,"270",elemets,true) + end,elemets,t,pos) + for i, ob in pairs(minetest.get_objects_inside_radius(pos, 50)) do + local p=ob:getpos() + p.y=pos.y+75 + ob:moveto(p) + end + end, +}) + +minetest.register_abm({ + nodenames = {"space_planets:planet_earthlike"}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local r=math.random(1,19) + local stuff={ + "default:grass_3", + "default:junglesapling", + "default:sapling", + "default:aspen_sapling", + "default:junglesapling", + "default:sapling", + "default:aspen_sapling", + "default:junglegrass", + "default:grass_3", + "flowers:mushroom_brown", + "flowers:mushroom_red", + "flowers:rose", + "flowers:tulip", + "flowers:dandelion_yellow", + "flowers:geranium", + "flowers:viola", + "flowers:dandelion_white", + "farming:wheat_" .. math.random(4,8), + "farming:cotton_" .. math.random(4,8), + ""} + minetest.set_node(pos, {name = stuff[r]}) + local t=minetest.get_modpath("space").."/schematics/space_lightfix.mts" + minetest.place_schematic(pos, t,"random",nil,false) + end, +}) + +minetest.register_abm({ + nodenames = {"space_planets:planet_desert"}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local r=math.random(1,3) + local stuff={ + "default:cactus", + "default:dry_shrub", + "default:desert_stone", + ""} + minetest.set_node(pos, {name = stuff[r]}) + local t=minetest.get_modpath("space").."/schematics/space_lightfix.mts" + minetest.place_schematic(pos, t,"random",nil,false) + end, +}) + +minetest.register_abm({ + nodenames = {"space_planets:planet_dryearth"}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local r=math.random(1,4) + local stuff={ + "default:cactus", + "default:acacia_sapling", + "default:dry_shrub", + "default:desert_stone", + ""} + if r==1 then + minetest.set_node({x=pos.x,y=pos.y-1,z=pos.z}, {name = "default:sand"}) + end + minetest.set_node(pos, {name = stuff[r]}) + local t=minetest.get_modpath("space").."/schematics/space_lightfix.mts" + minetest.place_schematic(pos, t,"random",nil,false) + end, +}) + + + + +minetest.register_abm({ + nodenames = {"space_planets:planet_cool"}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local r=math.random(1,3) + local stuff={ + "default:snow", + "default:ice", + "default:dirt_with_snow", + "default:pine_sapling", + ""} + minetest.set_node(pos, {name = stuff[r]}) + local t=minetest.get_modpath("space").."/schematics/space_lightfix.mts" + minetest.place_schematic(pos, t,"random",nil,false) + end, +}) + +minetest.register_abm({ + nodenames = {"space_planets:planet_rnd"}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + minetest.set_node(pos, {name = "air"}) + local t=minetest.get_modpath("space").."/schematics/space_lightfix.mts" + minetest.place_schematic(pos, t,"random",nil,false) + end, +}) \ No newline at end of file diff --git a/space_planets/mod.conf b/space_planets/mod.conf new file mode 100644 index 0000000..08c8699 --- /dev/null +++ b/space_planets/mod.conf @@ -0,0 +1,3 @@ +name = space_planets +description = Moon + depends = space \ No newline at end of file diff --git a/spacesuit/craft.lua b/spacesuit/craft.lua new file mode 100644 index 0000000..11159cc --- /dev/null +++ b/spacesuit/craft.lua @@ -0,0 +1,52 @@ + +minetest.register_craft({ + output = "spacesuit:door1_1 2", + recipe = { + {"","spacesuit:shieldblock",""}, + {"","spacesuit:shieldblock", ""}, + {"","spacesuit:shieldblock", ""}, + } +}) + +minetest.register_craft({ + output = "spacesuit:airgen5", + recipe = { + {"spacesuit:shieldblock","spacesuit:air_gassbotte","spacesuit:shieldblock"}, + {"spacesuit:shieldblock","spacesuit:oxogen", "spacesuit:shieldblock"}, + } +}) + +minetest.register_craft({ + output = "spacesuit:air_gassbotte 2", + recipe = { + {"default:steel_ingot","spacesuit:oxogen","default:steel_ingot"}, + } +}) + +minetest.register_craft({ + output = "spacesuit:sp", + recipe = { + {"spacesuit:sp","spacesuit:air_gassbotte",""} + + } +}) + +minetest.register_craft({ + output = "spacesuit:steelwallblock 8", + recipe = { + {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, + {"default:steel_ingot","", "default:steel_ingot"}, + {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, + } +}) + +minetest.register_craft({ + output = "spacesuit:shieldblock 4", + recipe = { + {"default:steel_ingot","default:steel_ingot","default:iron_lump"}, + {"default:steel_ingot","default:steel_ingot", ""}, + } +}) + + + diff --git a/spacesuit/craft2.jpg b/spacesuit/craft2.jpg new file mode 100644 index 0000000..225a7c1 Binary files /dev/null and b/spacesuit/craft2.jpg differ diff --git a/spacesuit/functions.lua b/spacesuit/functions.lua new file mode 100644 index 0000000..f96cbe1 --- /dev/null +++ b/spacesuit/functions.lua @@ -0,0 +1,86 @@ +minetest.register_on_leaveplayer(function(player) + spacesuit.player_sp[player:get_player_name()]=nil +end) + +-- place air2 if near to it (or it will messup with corrently) +minetest.register_on_dignode(function(pos, oldnode, digger) + if pos.yspace.y then + local user = spacesuit.player_sp[player:get_player_name()] + local n = minetest.get_node({x=l.x,y=l.y+2,z=l.z}).name + local inv = player:get_inventory() + + if user.sp==1 then +--(have spacesuit) + if n=="space:air" and inv:get_stack("main", 1):get_name()=="spacesuit:sp" and inv:get_stack("main", 1):get_wear()>0 then + local w=inv:get_stack("main", 1):get_wear()- (65534/20) + if w<0 then w=0 end + inv:set_stack("main", 1,ItemStack({name="spacesuit:sp",wear=w})) + elseif n~="space:air" and inv:get_stack("main", 1):get_name()=="spacesuit:sp" then + if inv:get_stack("main", 1):get_name()~="" and inv:get_stack("main", 1):get_wear()<65533 then + player:set_breath(11) + local w=inv:get_stack("main", 1):get_wear()+ (65534/900) + if w>65533 then w=65533 end + inv:set_stack("main", 1,ItemStack({name="spacesuit:sp",wear=w})) + elseif inv:get_stack("main", 1):get_name()=="spacesuit:sp" and inv:get_stack("main", 1):get_wear()>=65533 then + local have_more=0 + for i=0,32,1 do + if inv:get_stack("main", i):get_name()=="spacesuit:air_gassbotte" then + local c=inv:get_stack("main", i):get_count()-1 + inv:set_stack("main", i,ItemStack({name="spacesuit:air_gassbotte",count=c})) + inv:set_stack("main", 1,ItemStack({name="spacesuit:sp",wear=0})) + minetest.sound_play("spacesuit_pff", {pos=pos, gain = 1, max_hear_distance = 8,}) + have_more=1 + if c<4 and c>1 then minetest.chat_send_player(player:get_player_name(), "Warning: Gassbottes left: " .. c) end + if c==0 then minetest.chat_send_player(player:get_player_name(), "Warning: Gassbottes are over!") end + break + end + end + if have_more==0 then + user.sp=0 + minetest.chat_send_player(player:get_player_name(), "Warning: You are out of air!") + end + end + end + elseif user.sp==0 and inv:get_stack("main", 1):get_name()=="spacesuit:sp" and inv:get_stack("main", 1):get_wear()<65533 then +--(set up spacesuit) + user.sp=1 + spacesuit.tmpuser=player + local m=minetest.add_entity(player:get_pos(), "spacesuit:sp1") + m:set_attach(player, "", {x=0,y=-3,z=0}, {x=0,y=0,z=0}) + user.skin=player:get_properties().textures + player:set_properties({visual = "mesh",textures = {"spacesuit_sp2.png"},visual_size = {x=1, y=1}}) + elseif n=="air" and n~="ignore" then +--(no spacesuit and in default air: lose 8 hp) + player:set_hp(player:get_hp()-8) + elseif n~="space:air" and n~="ignore" then +--(no spacesuit and inside something else: lose 1 hp) + player:set_hp(player:get_hp()-1) + elseif user.sp==0 and n=="space:air" and inv:get_stack("main", 1):get_name()=="spacesuit:sp" and inv:get_stack("main", 1):get_wear()>=65533 then +--(set up spacesuit inair but empty) + user.sp=1 + end + end + end +end) \ No newline at end of file diff --git a/spacesuit/init.lua b/spacesuit/init.lua new file mode 100644 index 0000000..1a5bdb6 --- /dev/null +++ b/spacesuit/init.lua @@ -0,0 +1,71 @@ +spacesuit={ + breath_timer=0, + player_sp={}, + air=21, + player_space={}, + itemdroptime=tonumber(minetest.settings:get("item_entity_ttl")), +} + +spacesuit.itemdroptime = spacesuit.itemdroptime and spacesuit.itemdroptime - 20 or 880 + +dofile(minetest.get_modpath("spacesuit") .. "/nodes.lua") +dofile(minetest.get_modpath("spacesuit") .. "/craft.lua") +dofile(minetest.get_modpath("spacesuit") .. "/functions.lua") + +minetest.register_tool("spacesuit:sp", { + description = "Spacesuit (wear slot 1, works in space only)", + inventory_image = "spacesuit_sp.png", +}) + +minetest.register_on_joinplayer(function(player) + spacesuit.player_sp[player:get_player_name()]={sp=0,skin={}} +end) + +minetest.register_entity("spacesuit:sp1",{ + hp_max = 100, + physical = false, + weight = 0, + collisionbox = {-0.1,-0.1,-0.1, 0.1,0.1,0.1}, + visual = "cube", + visual_size = {x=0.5, y=0.5}, + textures = {"spacesuit_air.png","spacesuit_air.png","spacesuit_air.png","spacesuit_air.png","spacesuit_air.png","spacesuit_air.png"}, + spritediv = {x=1, y=1}, + is_visible = true, + makes_footstep_sound = false, + automatic_rotate = false, + timer=0, + on_activate=function(self, staticdata) + if spacesuit.tmpuser then + self.user=spacesuit.tmpuser + spacesuit.tmpuser=nil + self.hud=self.user:hud_add({ + hud_elem_type = "image", + text ="spacesuit_scene.png", + name = "spacesuit_sky", + scale = {x=-100, y=-100}, + position = {x=0, y=0}, + alignment = {x=1, y=1}, + }) + else + self.object:remove() + end + end, + on_step= function(self, dtime) + self.timer=self.timer+dtime + if self.timer<2 then return end + self.timer=0 + local p = spacesuit.player_sp[self.user:get_player_name()] + if not (self.user:get_pos() or p) then + self.object:remove() + return self + elseif self.user:get_inventory():get_stack("main", 1):get_name()~="spacesuit:sp" then + self.object:set_detach() + self.user:set_properties({mesh = "character.b3d",textures = p.skin}) + p.skin={} + p.sp=0 + self.user:hud_remove(self.hud) + self.object:remove() + return self + end + end +}) \ No newline at end of file diff --git a/spacesuit/mod.conf b/spacesuit/mod.conf new file mode 100644 index 0000000..ef7d923 --- /dev/null +++ b/spacesuit/mod.conf @@ -0,0 +1,3 @@ +name = spacesuit +description = Spacesuit + depends = space,default diff --git a/spacesuit/nodes.lua b/spacesuit/nodes.lua new file mode 100644 index 0000000..1cb645f --- /dev/null +++ b/spacesuit/nodes.lua @@ -0,0 +1,303 @@ + +minetest.register_node("spacesuit:door2_1", { + description = "Door", + drop="spacesuit:door2_1", + drawtype = "nodebox", + paramtype = "light", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.125, 0.5, 0.5, 0.125}, + } + }, + tiles = {"spacesuit_warntape.png","spacesuit_warntape.png","spacesuit_door2.png","spacesuit_warntape.png","spacesuit_door2.png","spacesuit_door2_2.png",}, + groups = {cracky = 1, level = 2, not_in_creative_inventory=0}, + sounds = default.node_sound_stone_defaults(), + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + is_ground_content = false, +after_place_node = function(pos, placer, itemstack, pointed_thing) + local p={x=pos.x,y=pos.y+1,z=pos.z} + if minetest.registered_nodes[minetest.get_node(p).name].walkable then + return false + else + minetest.set_node(p, {name = "spacesuit:door2_2",param2=minetest.get_node(pos).param2}) + end + end, +on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local p={x=pos.x,y=pos.y+1,z=pos.z} + minetest.swap_node(p, {name="spacesuit:door2_open_2", param2=minetest.get_node(pos).param2}) + minetest.swap_node(pos, {name="spacesuit:door2_open_1", param2=minetest.get_node(pos).param2}) + minetest.sound_play("spacesuit_door2", {pos=pos, gain = 1, max_hear_distance = 5}) + minetest.after(2, function(pos,p) + if minetest.get_node(pos).name=="spacesuit:door2_open_1" then + minetest.sound_play("spacesuit_door2", {pos=pos, gain = 1, max_hear_distance = 5}) + minetest.swap_node(p, {name="spacesuit:door2_2", param2=minetest.get_node(pos).param2}) + minetest.swap_node(pos, {name="spacesuit:door2_1", param2=minetest.get_node(pos).param2}) + end + end, pos,p) + end, +after_dig_node = function (pos, name, digger) + spacesuit_replacenode({x=pos.x,y=pos.y+1,z=pos.z}) + end, +}) + +minetest.register_node("spacesuit:door2_2", { + description = "Door 2-1", + drawtype = "nodebox", + drop="spacesuit:door2_1", + paramtype = "light", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.125, 0.5, 0.5, 0.125}, + } + }, + tiles = {"spacesuit_warntape.png","spacesuit_warntape.png","spacesuit_door2.png","spacesuit_warntape.png","spacesuit_door2.png","spacesuit_door2_2.png",}, + groups = {cracky = 1, level = 2, not_in_creative_inventory=1}, + sounds = default.node_sound_wood_defaults(), + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + is_ground_content = false, +on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local p={x=pos.x,y=pos.y-1,z=pos.z} + minetest.swap_node(p, {name="spacesuit:door2_open_1", param2=minetest.get_node(pos).param2}) + minetest.swap_node(pos, {name="spacesuit:door2_open_2", param2=minetest.get_node(pos).param2}) + minetest.sound_play("spacesuit_door2", {pos=pos, gain = 1, max_hear_distance = 5}) + minetest.after(2, function(pos,p) + if minetest.get_node(pos).name=="spacesuit:door2_open_2" then + minetest.sound_play("spacesuit_door2", {pos=pos, gain = 1, max_hear_distance = 5}) + minetest.swap_node(p, {name="spacesuit:door2_1", param2=minetest.get_node(pos).param2}) + minetest.swap_node(pos, {name="spacesuit:door2_2", param2=minetest.get_node(pos).param2}) + end + end, pos,p) + end, +after_dig_node = function (pos, name, digger) + spacesuit_replacenode({x=pos.x,y=pos.y-1,z=pos.z}) + end, +}) + +minetest.register_node("spacesuit:door2_open_1", { + description = "Door (open) 2-o-1", + drop="spacesuit:door2_1", + drawtype = "nodebox", + paramtype = "light", + node_box = { + type = "fixed", + fixed = { + {0.41, -0.5, -0.124, 1.41, 0.5, 0.125}, + } + }, + tiles = {"spacesuit_warntape.png","spacesuit_warntape.png","spacesuit_door2_open.png","spacesuit_warntape.png","spacesuit_door2_open.png","spacesuit_door2_2_open.png",}, + groups = {cracky = 1, level = 2, not_in_creative_inventory=1}, + sounds = default.node_sound_wood_defaults(), + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + is_ground_content = false, +after_dig_node = function (pos, name, digger) + spacesuit_replacenode({x=pos.x,y=pos.y+1,z=pos.z}) + end, +on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local p={x=pos.x,y=pos.y+1,z=pos.z} + minetest.sound_play("spacesuit_door2", {pos=pos, gain = 1, max_hear_distance = 5}) + minetest.swap_node(p, {name="spacesuit:door2_2", param2=minetest.get_node(pos).param2}) + minetest.swap_node(pos, {name="spacesuit:door2_1", param2=minetest.get_node(pos).param2}) + end, +}) + +minetest.register_node("spacesuit:door2_open_2", { + description = "Door (open) 2-o-1", + drawtype = "nodebox", + drop="spacesuit:door2_1", + paramtype = "light", + node_box = { + type = "fixed", + fixed = { + {0.41, -0.5, -0.124, 1.41, 0.5, 0.125}, + } + }, + tiles = {"spacesuit_warntape.png","spacesuit_warntape.png","spacesuit_door2_open.png","spacesuit_warntape.png","spacesuit_door2_open.png","spacesuit_door2_2_open.png",}, + groups = {cracky = 1, level = 2, not_in_creative_inventory=1}, + sounds = default.node_sound_wood_defaults(), + paramtype = "light", + paramtype2 = "facedir", + sunlight_propagates = true, + is_ground_content = false, +after_dig_node = function (pos, name, digger) + spacesuit_replacenode({x=pos.x,y=pos.y-1,z=pos.z}) + end, +on_rightclick = function(pos, node, player, itemstack, pointed_thing) + local p={x=pos.x,y=pos.y-1,z=pos.z} + minetest.sound_play("spacesuit_door2", {pos=pos, gain = 1, max_hear_distance = 5}) + minetest.swap_node(p, {name="spacesuit:door2_1", param2=minetest.get_node(pos).param2}) + minetest.swap_node(pos, {name="spacesuit:door2_2", param2=minetest.get_node(pos).param2}) + end, +}) + + +-- checks if the area is too big or if its outside in 14 directions +local airgen_tmpn=1 +for i=0,5,1 do +if i==5 then airgen_tmpn=0 end +minetest.register_node("spacesuit:airgen" .. i, { + description = "Air Generator " .. i*20 .."% power", + tiles = {"spacesuit_shieldblock.png^default_obsidian_glass.png","spacesuit_gen" .. i ..".png"}, + groups = {dig_immediate=3,not_in_creative_inventory=airgen_tmpn}, + sounds = default.node_sound_stone_defaults(), +on_construct = function(pos) + minetest.get_meta(pos):set_string("infotext", "Air Generater " .. i*20 .."% power") + end, +on_rightclick = function(pos, node, player, itemstack, pointed_thing) + if pos.y0 then + minetest.get_meta(pos):set_string("infotext", "Air Generater " .. i*20 .."% power [This area is too big (max " .. spacesuit.air-1 .. ") you have to rebuild]") + return + end + local done=0 + for ii=1,17,1 do + minetest.get_meta(pos):set_int("prl",0) + local np=minetest.find_node_near(pos,1,{"air"}) + if np~=nil then + minetest.set_node(np, {name = "spacesuit:air"}) + minetest.get_meta(np):set_int("prl",1) + done=1 + else + break + end + end + if done==1 then + minetest.swap_node(pos, {name = "spacesuit:airgen" .. (i-1)}) + minetest.get_meta(pos):set_string("infotext", "Air Generater " .. (i-1)*20 .."% power") + minetest.sound_play("spacesuit_pff", {pos=pos, gain = 1, max_hear_distance = 8,}) + end + end + end, +}) +end + + +minetest.register_node("spacesuit:air", { + description = "Air (unstabile)", + walkable = false, + pointable = false, + diggable = false, + buildable_to = true, + drawtype = "glasslike", + post_effect_color = {a = 180, r = 120, g = 120, b = 120}, + alpha = 20, + tiles = {"default_cloud.png^[colorize:#E0E0E099"}, + groups = {msa=1,not_in_creative_inventory=0}, + paramtype = "light", + sunlight_propagates =true, + on_construct = function(pos) + minetest.get_node_timer(pos):start(30) + end, + on_timer = function (pos, elapsed) + minetest.set_node(pos, {name = "space:air"}) + end +}) + +minetest.register_node("spacesuit:shieldblock", { + description = "Shieldblock", + tiles = {"spacesuit_shieldblock.png"}, + groups = {cracky = 1}, + sounds = default.node_sound_stone_defaults(), +}) +minetest.register_node("spacesuit:steelwallblock", { + description = "Steel wallblock", + tiles = {"spacesuit_wall.png"}, + groups = {cracky = 1}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("spacesuit:oxogen", { + description = "Oxygen block", + tiles = {"spacesuit_oxogen.png"}, + drawtype="glasslike", + groups = {crumbly = 2}, + paramtype = "light", + sunlight_propagates = true, + alpha = 50, + sounds = default.node_sound_glass_defaults(), +}) + +minetest.register_node("spacesuit:air_gassbotte", { + description = "Air gassbotte", + tiles = {"default_steel_block.png"}, + --inventory_image = "default_steel_block.png", + drawtype = "nodebox", + groups = {dig_immediate=3}, + sounds = default.node_sound_stone_defaults(), + is_ground_content = false, + --paramtype2 = "facedir", + paramtype = "light", + node_box = { + type="fixed", + fixed={-0.1,-0.5,-0.1,0.1,0.3,0.1}}, +}) + +-- spread air gass in a level system +minetest.register_abm({ + nodenames = {"air"}, + neighbors = {"spacesuit:air"}, + interval = 3, + chance = 1, + action = function(pos) + local np=minetest.find_node_near(pos, 1,{"spacesuit:air"}) + local n + if np~=nil then n=minetest.get_node(np) end + if n and n.name=="spacesuit:air" then + local r=minetest.get_meta(np):get_int("prl") + if r>0 and r