Update the weed mod and a few other things

master
jordan4ibanez 2016-02-22 21:09:55 -05:00
parent 8c2154d81c
commit 84b6b211de
22 changed files with 0 additions and 495 deletions

View File

@ -1 +0,0 @@
0.0.2

View File

@ -1,3 +0,0 @@
default
farming

View File

@ -1,310 +0,0 @@
--[[
Weed mod (based on wheat and baking mods)
VERSION: 0.0.2
LICENSE: GPLv3
TODO:
]]
PLANTS_GROW_INTERVAL = 80 -- interval in ABMs for plants
PLANTS_GROW_CHANCE = 60 -- chance in ABMs for plants
PLANTS_VISUAL_SCALE = 1 -- visualscale for plants
local LIGHT = 5 -- amount of light neded to weed grow
-- ABMs
--[[
minetest.register_abm({
nodenames = {"weed:weed_1","weed:weed_2","weed:weed_3","weed:weed_4",
"weed:weed_5","weed:weed_6","weed:weed_7"},
interval = PLANTS_GROW_INTERVAL/3*2,
chance = PLANTS_GROW_CHANCE/2,
action = function(pos, node, _, __)
local l = minetest.env:get_node_light(pos, nil)
local p = pos
local rnd = math.random(1, 3)
p.y = p.y - 1 -- it will change pos too, that cause using p.y = p.y + 1
local under_node = minetest.env:get_node(p)
if (l >= LIGHT) and (under_node.name == "weed:dirt_bed") and (rnd == 1) then
local nname --= 'weed:weed_final'
if node.name == "weed:weed_1" then
nname = 'weed:weed_2'
elseif node.name == "weed:weed_2" then
nname = 'weed:weed_3'
elseif node.name == 'weed:weed_3' then
nname = 'weed:weed_4'
elseif node.name == 'weed:weed_4' then
nname = 'weed:weed_5'
elseif node.name == 'weed:weed_5' then
nname = 'weed:weed_6'
elseif node.name == 'weed:weed_6' then
nname = 'weed:weed_7'
else nname = 'weed:weed_final' end
p.y = p.y + 1
minetest.env:remove_node(pos)
minetest.env:add_node(pos, { name = nname })
end
end
})
minetest.register_abm({
nodenames = NODES_TO_DELETE_IF_THEY_ABOVE_AIR,
interval = 3,
chance = 1,
action = function(pos, node, _, __)
local p = {x = pos.x,y = pos.y -1,z = pos.z}
--p.y = p.y - 1 -- it will change pos too, that cause using p.y = p.y + 1
local under_node = minetest.env:get_node(p)
if (under_node.name == "air") then
--p.y = p.y + 1
minetest.env:remove_node(pos)
minetest.env:add_node(p, {name = node.name})
end
end
})
minetest.register_abm({
nodenames = "weed:dirt_bed",
interval = 40,
chance = 3,
action = function(pos, node, _, __)
local p = {x = pos.x,y = pos.y +1,z = pos.z}
local above_node = minetest.env:get_node(p)
for i, plant in ipairs(DIRT_BED_TO_GRASS) do
if (above_node.name == plant) then return; end
end
minetest.env:remove_node(pos)
minetest.env:add_node(pos, {name = "weed:dirt_bed"})
end
})-- ABMs end
]]--
-- nodes and abms
for i = 1,8 do
-- the more grown the higher chance of crop - level 8 always has crop
local rarity = (14 - (i*2)) + 1
if i < 4 then
max_items = 0
elseif i >= 4 and i < 7 then
max_items = 1
elseif i == 7 then
max_items = 2
elseif i == 8 then
max_items = 3
end
minetest.register_node("weed:weed_" .. i, {
description = "Weed State " .. i,
drawtype = "plantlike",
tile_images = {"weed_state_" .. i .. ".png"},
inventory_image = "weed_state_" .. i .. ".png",
paramtype = "light",
is_ground_content = true,
walkable = false,
groups = {snappy = 3,flammable = 2,flower = 1,flora = 1,attached_node = 1},
drop = {
max_items = max_items,
items = {
{
items = {},
rarity = rarity,
},
{
items = {'default:dirt'},
rarity = rarity,
}
}
},
wall_mounted = false,
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -0.4, 1/2},
},
})
-- Fuel
minetest.register_craft({
type = "fuel",
recipe = "weed:weed_" .. i,
burntime = 2,
})
end
minetest.register_node("weed:big_grass", {
drawtype = "plantlike",
paramtype = "facedir_simple",
tile_images = {"weed_weed_final.png"},
inventory_image = "weed_weed_final.png",
paramtype = "light",
is_ground_content = true,
walkable = false,
groups = {dig_immediate=3,choppy=3},
drop = {
max_items = 1,
items = {
{
items = {'weed:weed_nug'},
rarity = 10,
},
},
},
visual_scale = PLANTS_VISUAL_SCALE,
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -0.3, 1/2},
},
})
--spawn weed in the world
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:dirt_with_grass"},
sidelen = 16,
noise_params = {
offset = 0,
scale = 0.006,
spread = {x = 100, y = 100, z = 100},
seed = 329,
octaves = 3,
persist = 0.6
},
y_min = min,
y_max = max,
decoration = "weed:weed_8",
--spawn_by = spawnby,
--num_spawn_by = num,
})
-- Nodes end
minetest.register_node("weed:wild_grass", {
drawtype = "plantlike",
paramtype = "facedir_simple",
tile_images = {"weed_weed_4.png"},
inventory_image = "weed_weed_4.png",
paramtype = "light",
is_ground_content = true,
walkable = false,
groups = {dig_immediate=3,choppy=3},
drop = {
max_items = 1,
items = {
{
items = {'weed:weed_nug'},
rarity = 10,
},
},
},
visual_scale = PLANTS_VISUAL_SCALE,
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -0.3, 1/2},
},
})
------
minetest.register_craftitem("weed:flour", {
image = "weed_flour.png",
on_place = minetest.item_place
})
minetest.register_craftitem("weed:seeds", {
description = "Weed Seeds",
image = "weed_seeds.png",
on_place = minetest.item_place,
on_use = minetest.item_eat(-1)
})
minetest.register_craftitem("weed:brownie", {
description = "Weed Brownie",
image = "weed_brownie.png",
on_place = minetest.item_place,
on_use = minetest.item_eat(9)
})
minetest.register_craftitem("weed:weed_cigarette", {
image = "cigarette.png",
on_place = minetest.item_place,
on_use = minetest.item_eat(1)
})
minetest.register_craftitem("weed:brownie_dough", {
image = "weed_brownie_dough.png",
on_place = minetest.item_place,
})
minetest.register_craft({
output = 'weed:flour 1',
recipe = {
{'weed:weed_nug', 'weed:weed_nug'},
{'weed:weed_nug', 'weed:weed_nug'},
}
})
minetest.register_craft({
output = 'weed:brownie_dough 1',
recipe = {
{'weed:flour', 'weed:flour', 'weed:flour'},
{'weed:flour', 'weed:weed_form_water', 'weed:flour'},
{'weed:flour', 'weed:flour', 'weed:flour'},
}
})
minetest.register_craft({
output = 'weed:weed_form_empty 1',
recipe = {
{'default:wood', '', 'default:wood'},
{'', 'default:wood', ''},
}
})
minetest.register_craft({
output = 'weed:weed_cigarette',
recipe = {
{'default:paper'},
{'weed:weed_nug'},
}
})
minetest.register_craft({
type = "cooking",
output = "weed:brownie",
recipe = "weed:brownie_dough",
cooktime = 10,
replacements = {
{"weed:brownie_dough", "weed:weed_form_empty"}, --- this is not work!!!
},
})
minetest.register_node("weed:poop", {
description = "Weed poop",
drawtype = "plantlike",
tile_images = {"weed_state_1.png"},
inventory_image = "weed_state_1.png",
})
print("[weed mod] Loaded!")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

View File

@ -1,181 +0,0 @@
--try to mimic node collision boxes by creating multiple entities attached in an entity with no collision box
bvav_settings = {}
bvav_settings.attach_scaling = 30
bvav_settings.scaling = 0.667
bvav_settings.ship_size = 5
function bvav_settings.set(list)
local set = {}
for _, l in ipairs(list) do set[l] = true end
return set
end
bvav_settings.node_table = bvav_settings.set{"default:wood","default:tree","default:glass"}
minetest.register_entity("bvav:bvav_element", {
initial_properties = {
physical = true,
collide_with_objects = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
visual = "wielditem",
textures = {},
automatic_face_movement_dir = 0.0,
},
node = {},
set_node = function(self, node)
self.node = node
local prop = {
is_visible = true,
textures = {node.name},
}
self.object:set_properties(prop)
end,
get_staticdata = function(self)
return self.node.name
end,
on_activate = function(self, staticdata)
self.object:set_armor_groups({immortal=1})
if staticdata then
self:set_node({name=staticdata})
end
minetest.after(0,function()
if self.parent ~= nil and self.relative ~= nil then
self.object:set_attach(self.parent, "", {x=self.relative.x,y=self.relative.y,z=self.relative.z}, {x=0,y=0,z=0})
self.object:set_properties({visual_size = {x=bvav_settings.scaling*3, y=bvav_settings.scaling*3}})
else
--this fixes issues with scaling
self.object:set_properties({visual_size = {x=bvav_settings.scaling, y=bvav_settings.scaling}})
end
end)
end,
-- maybe have cannons, anchors, trolling lines, etc
on_step = function(self, dtime)
--remove old vessels for now
if self.controller == nil and self.parent == nil then
self.object:remove()
end
if self.parent ~= nil then
else
--self.object:setvelocity({x=math.random(-1,1)*math.random(),y=0,z=math.random(-1,1)*math.random()})
--let player control vessel
if self.controller then
if minetest.get_player_by_name(self.controller):get_attach() ~= nil then
local control = minetest.get_player_by_name(self.controller):get_player_control()
if control.jump == true or control.sneak == true or control.up == true then
local vel = {}
if control.jump == true then
vel.y = 3
elseif control.sneak == true then
vel.y = -3
else
vel.y = 0
end
if control.up == true then
local dir = minetest.get_player_by_name(self.controller):get_look_dir()
vel.x = dir.x * 2
vel.z = dir.z * 2
else
vel.x = 0
vel.z = 0
end
self.object:setvelocity(vel)
end
else
self.object:setvelocity({x=0,y=0,z=0})
end
end
end
end,
on_rightclick = function(self, clicker)
if clicker:get_player_name() == self.controller then
clicker:set_detach()
end
end,
--
})
function spawn_bvav_element(p, node)
local obj = core.add_entity(p, "bvav:bvav_element")
obj:get_luaentity():set_node(node)
return obj
end
function bvav_create_vessel(pos,param2)
local parent = spawn_bvav_element(pos, {name="bvav:control_node"})
local basepos = parent:getpos()
local range = bvav_settings.ship_size
local min = {x=pos.x-range,y=pos.y-range,z=pos.z-range}
local max = {x=pos.x+range,y=pos.y+range,z=pos.z+range}
local vm = minetest.get_voxel_manip()
local emin, emax = vm:read_from_map(min,max)
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
local data = vm:get_data()
local air = minetest.get_content_id("air")
--build the vessel
for x = range*-1,range do
for y = range*-1,range do
for z = range*-1,range do
local pos = {x=basepos.x+x,y=basepos.y+y,z=basepos.z+z}
--entities for the vessel
local node = vm:get_node_at(pos).name
if bvav_settings.node_table[node] then
local child = spawn_bvav_element(pos, {name=node})
child:get_luaentity().parent = parent
if param2 == 0 then
child:get_luaentity().relative = {x=z * bvav_settings.attach_scaling,y=y * bvav_settings.attach_scaling,z=x * bvav_settings.attach_scaling}
elseif param2 == 1 then
child:get_luaentity().relative = {x=x * bvav_settings.attach_scaling,y=y * bvav_settings.attach_scaling,z=z * bvav_settings.attach_scaling}
elseif param2 == 2 then
child:get_luaentity().relative = {x=z * bvav_settings.attach_scaling*-1,y=y * bvav_settings.attach_scaling,z=x * bvav_settings.attach_scaling}
elseif param2 == 3 then
child:get_luaentity().relative = {x=x * bvav_settings.attach_scaling*-1,y=y * bvav_settings.attach_scaling,z=z * bvav_settings.attach_scaling}
end
end
--delete the nodes added to the vessel
local p_pos = area:index(pos.x, pos.y, pos.z)
data[p_pos] = air
end
end
end
vm:set_data(data)
vm:calc_lighting()
vm:write_to_map()
vm:update_map()
return(parent)
end
minetest.register_node("bvav:control_node", {
description = "Control Node",
tiles = {"default_stone.png"},
groups = {cracky=3, stone=1},
paramtype2 = "facedir",
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
print(node.param2)
local vessel = bvav_create_vessel(pos,node.param2)
player:set_attach(vessel, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
vessel:get_luaentity().controller = player:get_player_name()
end,
})