first commit
|
@ -0,0 +1,53 @@
|
|||
The main game for the Minetest game engine [minetest_game]
|
||||
==========================================================
|
||||
|
||||
To build the wholeness of the Minetest project, insert this repository as
|
||||
/games/minetest_game
|
||||
in the Minetest Engine.
|
||||
|
||||
The Minetest Engine can be found in:
|
||||
https://github.com/minetest/minetest/
|
||||
|
||||
Compatibility
|
||||
--------------
|
||||
The minetest_game github master HEAD is generally compatible with the github
|
||||
master HEAD of minetest.
|
||||
|
||||
Additionally, when the minetest engine is tagged to be a certain version (eg.
|
||||
0.4.dev-20120326), minetest_game is tagged with the version too.
|
||||
|
||||
When stable releases are made, minetest_game is packaged and made available in
|
||||
http://minetest.net/download.php
|
||||
and in case the repository has grown too much, it may be reset. In that sense,
|
||||
this is not a "real" git repository. (Package maintainers please note!)
|
||||
|
||||
License of source code
|
||||
----------------------
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
See README.txt in each mod directory for information about other authors.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
See README.txt in each mod directory for information about other authors.
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
License of menu/header.png
|
||||
Copyright (C) 2013 BlockMen CC BY-3.0
|
||||
|
After Width: | Height: | Size: 152 KiB |
After Width: | Height: | Size: 2.5 KiB |
|
@ -0,0 +1,54 @@
|
|||
Affects
|
||||
|
||||
This adds an API to easily affect players in various ways, both positive and negative.
|
||||
|
||||
Depends: whoison ( https://github.com/bremaweb/whoison )
|
||||
License: WTFPL
|
||||
|
||||
Functions
|
||||
|
||||
affects.registerAffect( {affect definition} )
|
||||
affects.affectPlayer(name,affectid)
|
||||
affects.removeAffect(name,affectid)
|
||||
|
||||
Affect Definition
|
||||
|
||||
affect = {
|
||||
affectid = <unique string id for this affect>,
|
||||
name = <string name for this affect>,
|
||||
stages = { {stage definition}, {stage definition}, .. },
|
||||
onremove = function(name,player,affectid) -- optional function that is ran when the affect is removed
|
||||
}
|
||||
|
||||
|
||||
Stage Definition
|
||||
This is where the magic happens. You can define as many stages for an affect as you want. This can be used to gradually decrease the affect or make the affect change over time. The sky is the limit
|
||||
|
||||
{
|
||||
time = <number of seconds this stage lasts>,
|
||||
|
||||
physics = { ... },
|
||||
optional this is a table as used by set_physics_override ( https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1787 ) to change the physics for a player during this stage
|
||||
|
||||
emote = { chance = <Number 1-100>, action = <string> }
|
||||
optional chance is the chance out of 100 that action will be displayed in chat as if the affected player had used /me <action>
|
||||
|
||||
place = { chance = <number 1-100>, node = <string node that will be placed> },
|
||||
optional, chance is the chance out of 100 the player with place the node defined at their current position, node would be a string like "default:dirt"
|
||||
|
||||
damage = { chance = <number 1-100>, amount = <number> }
|
||||
optional, chance the player will be dealt the amount defined in damage, this could be a negative number and actually result in healing instead of damage
|
||||
|
||||
custom { func = function(name, player, affectid), chance = <number 1-100>, runonce = <true/false> }
|
||||
optional, a function that you can write to do whatever you want. runonce tells whether this function should only be ran once or not
|
||||
|
||||
}
|
||||
|
||||
|
||||
When a player is affected they start at the first stage. The function to apply the affects runs every 30 seconds. Each time it runs it uses what you defined a chance to determine if it should execute that item of the stage. The custom function has a runonce variable, if true the custom function will only run one time for the whole time that stage is in affect. After the player has been online longer than the time in your stage definition they are moved to the next stage, and the affect is applied. After they pass the last stage of the affect the onremove function is called, and the physics are reset, and the affect is removed.
|
||||
|
||||
It is up to you to write the code to initially apply an affect to a player. That can be done by using an item, digging a node, or executing a chat command.
|
||||
|
||||
This depends on the whoison mod for the whoison.getTimeOnline(name) function to know how long a player has been online, to advance the stages after the right amount of time.
|
||||
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
|
||||
local antig = {
|
||||
affectid="antig",
|
||||
name="Anti Gravity",
|
||||
stages={
|
||||
{
|
||||
time=60,
|
||||
physics = { gravity = .3 }
|
||||
},
|
||||
{
|
||||
time=60,
|
||||
physics = { gravity = .5 }
|
||||
},
|
||||
{
|
||||
time=60,
|
||||
physics = { gravity = .9 }
|
||||
}
|
||||
},
|
||||
onremove = function(name, player, affectid)
|
||||
minetest.chat_send_player(name,"You no longer have anti gravity!",false)
|
||||
end
|
||||
}
|
||||
|
||||
affects.registerAffect(antig)
|
||||
|
||||
local combust = {
|
||||
affectid="combust",
|
||||
name="Spontaneous Combustion",
|
||||
stages={
|
||||
{
|
||||
time=300,
|
||||
emote = { chance=40, action = "thinks it's getting hot in here" },
|
||||
place = { chance=70, node = "fire:basic_flame" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
affects.registerAffect(combust)
|
||||
|
||||
local fly = {
|
||||
affectid = "fly",
|
||||
name="Temporary Fly",
|
||||
stages = {
|
||||
{
|
||||
time=45,
|
||||
custom = { chance=100, func = function(name, player, affectid)
|
||||
local pPrivs = minetest.get_player_privs(name)
|
||||
pPrivs["fly"] = true
|
||||
minetest.set_player_privs(name,pPrivs)
|
||||
end, runonce=true }
|
||||
}
|
||||
},
|
||||
onremove = function(name, player, affectid)
|
||||
local pPrivs = minetest.get_player_privs(name)
|
||||
pPrivs["fly"] = nil
|
||||
minetest.set_player_privs(name,pPrivs)
|
||||
minetest.chat_send_player(name,"You can no longer fly!",false)
|
||||
end
|
||||
}
|
||||
|
||||
affects.registerAffect(fly)
|
|
@ -0,0 +1,69 @@
|
|||
function affects.registerAffect( aDef )
|
||||
-- Here we validate some values and add it to the affects._affects table
|
||||
minetest.log("action","Registering affect: "..aDef.name)
|
||||
|
||||
if ( aDef.affectid == nil ) then
|
||||
return false
|
||||
end
|
||||
|
||||
if ( #aDef.stages < 1 ) then
|
||||
return false
|
||||
end
|
||||
|
||||
-- TODO add more checks here to ensure the affect definition won't crash the server
|
||||
|
||||
affects._affects[aDef.affectid] = aDef
|
||||
|
||||
end
|
||||
|
||||
function affects.removeAffect(name, affectid)
|
||||
if ( affects._affectedPlayers[name] ~= nil ) then
|
||||
if ( affectid == nil ) then
|
||||
return false
|
||||
else
|
||||
affects._affectedPlayers[name][affectid] = nil;
|
||||
if ( affects._affects[affectid].onremove ~= nil ) then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
--player:set_physics_override({ speed=1, jump=1,gravity=1,sneak=true }) -- reset their physics
|
||||
affects._affects[affectid].onremove(name,player,affectid)
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function affects.affectPlayer(name, affectid)
|
||||
if ( affects._affectedPlayers[name] == nil ) then
|
||||
affects._affectedPlayers[name] = {}
|
||||
end
|
||||
|
||||
if ( affects._affectedPlayers[name][affectid] == nil ) then
|
||||
if ( affects._affects[affectid] ~= nil ) then
|
||||
whoison.updateStats(name)
|
||||
local ns = ( whoison.getTimeOnline(name) + affects._affects[affectid].stages[1].time )
|
||||
affects._affectedPlayers[name][affectid] = { stage = 0, nextStage = 0, ran=false }
|
||||
applyAffect(name,affectid)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function affects.default_on_use(itemstack,player,pointed_thing)
|
||||
local affectid = itemstack:get_definition().affectid
|
||||
local name = player:get_player_name()
|
||||
if pointed_thing.type == "object" then
|
||||
if pointed_thing.ref:is_player() then
|
||||
-- affect the player they are pointing at
|
||||
name = pointed_thing.ref:get_player_name()
|
||||
end
|
||||
end
|
||||
|
||||
if ( affects.affectPlayer(name,affectid) ) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
minetest.register_chatcommand("affect",{
|
||||
params = "<name> <affectid>",
|
||||
description = "Applies an affect to a player",
|
||||
privs = {affects=true},
|
||||
func = function (name, param)
|
||||
local aname, affectid = string.match(param, "([^ ]+) (.+)")
|
||||
if ( affects.affectPlayer(aname,affectid) ) then
|
||||
minetest.chat_send_player(name,aname.." has been affected by "..affects._affects[affectid].name)
|
||||
else
|
||||
minetest.chat_send_player(name,"Unable to affect "..aname.." with "..affectid)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("removeaffect",{
|
||||
params = "<name> [affectid]",
|
||||
description = "Removes and affect or all affects from a player",
|
||||
privs = {affects=true},
|
||||
func = function (name, param)
|
||||
local aname, affectid = string.match(param, "([^ ]+) (.+)")
|
||||
if ( affects.removeAffect(aname,affectid) ) then
|
||||
minetest.chat_send_player(name,"Affect removed from "..aname)
|
||||
else
|
||||
minetest.chat_send_player(name,"Unable to remove affects")
|
||||
end
|
||||
end
|
||||
})
|
|
@ -0,0 +1,2 @@
|
|||
whoison
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
function applyAffect(name,affectid)
|
||||
minetest.log("action","Applying affect "..affectid.." on "..name)
|
||||
whoison.updateStats(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local oStage = affects._affectedPlayers[name][affectid].stage
|
||||
local stageChange = false
|
||||
-- see if they need advanced into the next stage
|
||||
if ( affects._affectedPlayers[name][affectid].nextStage < whoison.getTimeOnline(name) ) then
|
||||
local nextStageNum = affects._affectedPlayers[name][affectid].stage + 1
|
||||
affects._affectedPlayers[name][affectid].stage = nextStageNum
|
||||
affects._affectedPlayers[name][affectid].ran = false
|
||||
minetest.log("action","Advancing "..affectid.." to the next stage for "..name)
|
||||
if ( #affects._affects[affectid].stages < nextStageNum ) then
|
||||
minetest.log("action","Affect "..affectid.." has worn off of "..name)
|
||||
affects.removeAffect(name,affectid)
|
||||
return
|
||||
end
|
||||
affects._affectedPlayers[name][affectid].nextStage = (whoison.getTimeOnline(name) + affects._affects[affectid].stages[nextStageNum].time)
|
||||
-- apply physics on stage changes
|
||||
stageChange = true
|
||||
end
|
||||
|
||||
local iStage = affects._affectedPlayers[name][affectid].stage
|
||||
local stage = affects._affects[affectid].stages[iStage]
|
||||
local oPhysics = stage.physics
|
||||
|
||||
if stageChange == true then
|
||||
if ( oPhysics ~= nil ) then
|
||||
physics.adjust_physics(player,oPhysics)
|
||||
end
|
||||
end
|
||||
|
||||
if ( stage.damage ~= nil ) then
|
||||
if ( randomChance(stage.damage.chance) ) then
|
||||
player:set_hp( player:get_hp() - stage.damage.amount )
|
||||
end
|
||||
end
|
||||
|
||||
if ( stage.emote ~= nil ) then
|
||||
if ( randomChance(stage.emote.chance) ) then
|
||||
minetest.chat_send_all(name.." "..stage.emote.action)
|
||||
end
|
||||
end
|
||||
|
||||
if ( stage.place ~= nil ) then
|
||||
if ( randomChance(stage.place.chance) ) then
|
||||
minetest.place_node(player:getpos(),{name=stage.place.node, param1=0, param2=0})
|
||||
end
|
||||
end
|
||||
|
||||
if ( stage.custom ~= nil ) then
|
||||
if ( stage.custom.runonce == true and affects._affectedPlayers[name][affectid].ran == true ) then
|
||||
return
|
||||
end
|
||||
if ( randomChance(stage.custom.chance) ) then
|
||||
affects._affectedPlayers[name][affectid].ran = true
|
||||
stage.custom.func(name,player,affectid)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function randomChance (percent)
|
||||
math.randomseed( os.time() )
|
||||
return percent >= math.random(1, 100)
|
||||
end
|
|
@ -0,0 +1,26 @@
|
|||
affects = {}
|
||||
|
||||
affects.affectTime = 15 -- how often, in seconds, should runAffects be called
|
||||
|
||||
affectsPath = minetest.get_modpath("affects")
|
||||
affectsFile = minetest.get_worldpath().."/affects.txt"
|
||||
|
||||
affects._affects = {}
|
||||
affects._affectedPlayers = {}
|
||||
|
||||
dofile(affectsPath.."/functions.lua")
|
||||
dofile(affectsPath.."/api.lua")
|
||||
dofile(affectsPath.."/loops.lua")
|
||||
dofile(affectsPath.."/chatcommands.lua")
|
||||
dofile(affectsPath.."/persistance.lua")
|
||||
|
||||
affects.loadAffects()
|
||||
|
||||
minetest.register_privilege("affects", "Player can use the affects chat commands.")
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
affects.saveAffects()
|
||||
end
|
||||
)
|
||||
|
||||
-- TODO on join player apply physics from affects they are affected by
|
|
@ -0,0 +1,14 @@
|
|||
local function runAffects()
|
||||
for _,player in ipairs( minetest.get_connected_players() ) do
|
||||
local name = player:get_player_name()
|
||||
if ( affects._affectedPlayers[name] ) ~= nil then
|
||||
for affectid,a in pairs(affects._affectedPlayers[name]) do
|
||||
applyAffect(name,affectid)
|
||||
end
|
||||
end
|
||||
end
|
||||
affects.saveAffects()
|
||||
minetest.after(affects.affectTime, runAffects)
|
||||
end
|
||||
|
||||
minetest.after(affects.affectTime, runAffects)
|
|
@ -0,0 +1,19 @@
|
|||
function affects.saveAffects()
|
||||
minetest.log("action","Saving player affects")
|
||||
local f = io.open(affectsFile,"w")
|
||||
f:write(minetest.serialize(affects._affectedPlayers))
|
||||
f:close()
|
||||
end
|
||||
|
||||
function affects.loadAffects()
|
||||
minetest.log("action","Loading player affects")
|
||||
local f = io.open(affectsFile,"r")
|
||||
if ( f ~= nil ) then
|
||||
local af = f:read("*all")
|
||||
f:close()
|
||||
if ( af ~= nil and af ~= "" ) then
|
||||
affects._affectedPlayers = minetest.deserialize(af)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 70de26b4519d9c790454d43d40ce2920720e716a
|
|
@ -0,0 +1,4 @@
|
|||
[Dolphin]
|
||||
Timestamp=2014,3,16,0,21,44
|
||||
Version=3
|
||||
ViewMode=1
|
|
@ -0,0 +1,156 @@
|
|||
-- each user can create one arena at a time, arena setups are index by the person who started it's name
|
||||
-- this allows multiple arenas to be going on at one time
|
||||
|
||||
|
||||
-- commands
|
||||
-- /arena create <pos> <fee> <pos> the position the participants should meet at, <fee> if there is an entrace fee, winner gets the majority of the fee
|
||||
-- /arena cancel cancels arena
|
||||
-- /arena start starts the arena match
|
||||
-- /arena join <name> where player name is the player that started the arena, a player can only join one arena at a time
|
||||
-- /arena leave leaves the arena before it has started, this is not an option after it has started
|
||||
-- /arena bet <name> <participant> <amount> places a bet on participant
|
||||
-- /arena list shows a list of the active arenas
|
||||
|
||||
-- Maybe this should be done with a formspec? Then arena blocks could be placed near arenas and the blocks location could be used as the pos in create
|
||||
|
||||
|
||||
arena = {}
|
||||
events = {} -- a list of the arena events
|
||||
|
||||
function arena.create(name,pos,fee,desc)
|
||||
if ( events[name] == nil ) then
|
||||
events[name] = {name=name,pos=pos,fee=fee,description=desc,participants={},fees_collected=0}
|
||||
minetest.chat_send_all(name.." has created an arena event at "..minetest.pos_to_string(pos)..". Entrance fee is "..fee)
|
||||
else
|
||||
minetest.chat_send_player(name,'It looks like you already have an arena event setup')
|
||||
end
|
||||
end
|
||||
|
||||
function arena.cancel(name)
|
||||
if ( events[name] ~= nil ) then
|
||||
events[name] = nil
|
||||
minetest.chat_send_all(name.." has canceled their arena event")
|
||||
else
|
||||
minetest.chat_send_player(name,"You have not created an arena event")
|
||||
end
|
||||
end
|
||||
|
||||
function arena.list(name)
|
||||
minetest.chat_send_player(name,'Arena Events:')
|
||||
|
||||
for k,event in pairs(events) do
|
||||
minetest.chat_send_player(name,event.name.." Arena Event at "..minetest.pos_to_string(event.pos)..". "..event.fee.." Entrance Fee")
|
||||
end
|
||||
end
|
||||
|
||||
function arena.in_arena(name)
|
||||
for _,event in ipairs(events) do
|
||||
if ( event.participants[name] == true ) then
|
||||
return event
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function arena.die(player)
|
||||
local name = player:get_player_name();
|
||||
|
||||
event = arena.in_arena(name)
|
||||
event.participants[name] = false
|
||||
minetest.chat_send_all(name.." died in the arena!")
|
||||
|
||||
if ( arena.has_winner(event) ) then
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function arena.join(name,event)
|
||||
if ( events[event] ~= nil ) then
|
||||
if ( arena.in_arena(name) ) then
|
||||
minetest.chat_send_player(name,"You are already signed up for an arena")
|
||||
else
|
||||
if ( money.get(name) >= events[event].fee ) then
|
||||
-- pay the entrance fee
|
||||
money.dec(name,events[event].fee)
|
||||
events[event].fees_collected = events[event].fees_collected + events[event].fee
|
||||
|
||||
events[event].participants[name]=true
|
||||
minetest.chat_send_all(name.." has joined "..event.." arena event!")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function arena.create_formspec(name)
|
||||
local player = minetest.get_player_by_name(name);
|
||||
local formspec = "size[6,8;]"
|
||||
formspec = formspec.."label[.25,.25;Create Arena Event]"
|
||||
formspec = formspec.."label[.25,1;Location]"
|
||||
formspec = formspec.."field[.25,2;2,1;arena_x;X;"..math.floor(player:getpos().x).."]"
|
||||
formspec = formspec.."field[2.25,2;2,1;arena_y;Y;"..math.ceil(player:getpos().y).."]"
|
||||
formspec = formspec.."field[4.25,2;2,1;arena_z;Z;"..math.floor(player:getpos().z).."]"
|
||||
formspec = formspec.."field[.25,3.5;3,1;arena_fee;Entrance Fee;0]"
|
||||
formspec = formspec.."field[.25,5.25;5,1;arena_desc;Description;]"
|
||||
formspec = formspec.."button_exit[.25,6.5;2,1;arena_save;Create]"
|
||||
formspec = formspec.."button_exit[2.5,6.5;2,1;arena_cancel;Cancel]"
|
||||
|
||||
return formspec
|
||||
end
|
||||
|
||||
function arena.process_forms(player,formname,fields)
|
||||
if ( formname == "arena_create" ) then
|
||||
if ( fields.arena_save ) then
|
||||
arena.create(player:get_player_name(),{x=fields.arena_x,y=fields.arena_y,z=fields.arena_z},fields.arena_fee,fields.arena_desc)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(arena.process_forms)
|
||||
|
||||
minetest.register_chatcommand("arena",{
|
||||
params = "create | cancel | list | join <name>",
|
||||
description = "Create or Manage Arenas",
|
||||
func = function (name, param)
|
||||
local psplit = param:split(" ")
|
||||
if ( psplit[1] == "create" ) then
|
||||
minetest.show_formspec(name,"arena_create", arena.create_formspec(name))
|
||||
end
|
||||
if ( psplit[1] == "list" ) then
|
||||
arena.list(name)
|
||||
end
|
||||
|
||||
if ( psplit[1] == "cancel" ) then
|
||||
arena.cancel(name)
|
||||
end
|
||||
|
||||
if ( psplit[1] == "join" ) then
|
||||
if ( psplit[2] ~= nil ) then
|
||||
arena.join(name,psplit[2])
|
||||
else
|
||||
minetest.chat_send_player("name","Usage is /arena join <event name>")
|
||||
end
|
||||
end
|
||||
|
||||
if ( psplit[1] == "leave" ) then
|
||||
if ( event == arena.in_arena(name) ) then
|
||||
event.participants[name] = false
|
||||
minetest.chat_send_all(name.." died in the arena!")
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_on_dieplayer(function (player)
|
||||
if ( #events > 0 ) then
|
||||
arena.die(player)
|
||||
end
|
||||
end)
|
||||
|
||||
function string:split(sep)
|
||||
local sep, fields = sep or ":", {}
|
||||
local pattern = string.format("([^%s]+)", sep)
|
||||
self:gsub(pattern, function(c) fields[#fields+1] = c end)
|
||||
return fields
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
Minetest 0.4 mod: bones
|
||||
=======================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2012 PilzAdam
|
||||
|
||||
WTFPL
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
----------------------
|
||||
Bad_Command_
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,217 @@
|
|||
-- Minetest 0.4 mod: bones
|
||||
-- See README.txt for licensing and other information.
|
||||
bone_file = minetest.get_worldpath().."/player_bones"
|
||||
player_bones = default.deserialize_from_file(bone_file)
|
||||
|
||||
local function is_owner(pos, name)
|
||||
local owner = minetest.get_meta(pos):get_string("owner")
|
||||
if owner == "" or owner == name then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function not_pillaged(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if ( meta:get_string("pillaged") == "" ) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_node("bones:bones", {
|
||||
description = "Bones",
|
||||
tiles = {
|
||||
"bones_top.png",
|
||||
"bones_bottom.png",
|
||||
"bones_side.png",
|
||||
"bones_side.png",
|
||||
"bones_rear.png",
|
||||
"bones_front.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {dig_immediate=2},
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_gravel_footstep", gain=0.5},
|
||||
dug = {name="default_gravel_footstep", gain=1.0},
|
||||
}),
|
||||
on_punch = function(pos, node, player)
|
||||
if node == nil or node.name ~= "bones:bones" then
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
|
||||
local name = player:get_player_name()
|
||||
if name ~= meta:get_string("owner") then
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local bones_inv = meta:get_inventory()
|
||||
if ( bones_inv == nil ) then
|
||||
return
|
||||
end
|
||||
|
||||
local player_inv = player:get_inventory()
|
||||
if ( player_inv == nil ) then
|
||||
minetest.log("error", 'Bones: Unable to get player '..name..' inventory')
|
||||
return
|
||||
end
|
||||
|
||||
for i=1,32 do
|
||||
local stack = bones_inv:get_stack("main", i)
|
||||
if stack ~= nil and not stack:is_empty() then
|
||||
local leftover = player_inv:add_item("main", stack)
|
||||
bones_inv:set_stack("main", i, nil)
|
||||
if leftover ~= nil and not leftover:is_empty() then
|
||||
bones_inv:set_stack("main", i, leftover)
|
||||
else
|
||||
bones_inv:set_stack("main", i, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.log("action", name.." unloaded his fresh bones at "..minetest.pos_to_string(pos))
|
||||
|
||||
-- destroy the bone node
|
||||
minetest.set_node(pos, {name="air", param1=0, param2=0})
|
||||
minetest.log("action","Destroying bones "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
return is_owner(pos, player:get_player_name())
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local meta = minetest:get_meta(pos)
|
||||
meta:from_table(oldmetadata)
|
||||
local inv = meta:get_inventory()
|
||||
default.dump_inv(pos,"main",inv)
|
||||
player_bones[meta:get_string("owner")] = nil
|
||||
default.serialize_to_file(bone_file,player_bones)
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
if is_owner(pos, player:get_player_name()) then
|
||||
return count
|
||||
end
|
||||
return 0
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
return 0
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if is_owner(pos, player:get_player_name()) or not_pillaged(pos) then
|
||||
return stack:get_count()
|
||||
end
|
||||
return 0
|
||||
end,
|
||||
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("pillaged","1")
|
||||
if meta:get_string("owner") ~= "" and meta:get_inventory():is_empty("main") then
|
||||
meta:set_string("infotext", meta:get_string("owner").."'s old bones")
|
||||
meta:set_string("formspec", "")
|
||||
meta:set_string("owner", "")
|
||||
end
|
||||
end,
|
||||
|
||||
on_timer = function(pos, elapsed)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local time = meta:get_int("time")+elapsed
|
||||
local publish = 1200
|
||||
local delete = 2400
|
||||
if tonumber(minetest.setting_get("share_bones_time")) then
|
||||
publish = tonumber(minetest.setting_get("share_bones_time"))
|
||||
end
|
||||
if publish == 0 then
|
||||
return
|
||||
end
|
||||
if time >= publish then
|
||||
meta:set_string("infotext", meta:get_string("owner").."'s old bones")
|
||||
meta:set_string("owner", "")
|
||||
return
|
||||
end
|
||||
|
||||
if time >= delete then
|
||||
inv = meta:get_inventory()
|
||||
if inv:is_empty("main") == false then
|
||||
dump_bones(pos)
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
player_bones[meta:get_string("owner")] = nil
|
||||
default.serialize_to_file(bone_file,player_bones)
|
||||
end
|
||||
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
function dump_bones(pos)
|
||||
-- drop everything in the bones on the ground
|
||||
default.dump_inv(pos,"main")
|
||||
end
|
||||
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
return
|
||||
end
|
||||
|
||||
local pos = player:getpos()
|
||||
local name = player:get_player_name()
|
||||
|
||||
player_bones[name] = pos
|
||||
default.serialize_to_file(bone_file,player_bones)
|
||||
|
||||
minetest.sound_play("default_death",{
|
||||
object = player,
|
||||
})
|
||||
|
||||
minetest.chat_send_player(player:get_player_name(),"Your bones are at "..math.floor(pos.x + 0.5) .. "," .. math.floor(pos.y+0.5) .. "," .. math.floor(pos.z+0.5))
|
||||
|
||||
pos.x = math.floor(pos.x+0.5)
|
||||
pos.y = math.floor(pos.y+0.5)
|
||||
pos.z = math.floor(pos.z+0.5)
|
||||
local param2 = minetest.dir_to_facedir(player:get_look_dir())
|
||||
|
||||
local nn = minetest.get_node(pos).name
|
||||
if minetest.registered_nodes[nn].can_dig and
|
||||
not minetest.registered_nodes[nn].can_dig(pos, player) then
|
||||
local player_inv = player:get_inventory()
|
||||
|
||||
for i=1,player_inv:get_size("main") do
|
||||
player_inv:set_stack("main", i, nil)
|
||||
end
|
||||
for i=1,player_inv:get_size("craft") do
|
||||
player_inv:set_stack("craft", i, nil)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
--minetest.dig_node(pos)
|
||||
minetest.add_node(pos, {name="bones:bones", param2=param2})
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local player_inv = player:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
|
||||
local empty_list = inv:get_list("main")
|
||||
inv:set_list("main", player_inv:get_list("main"))
|
||||
player_inv:set_list("main", empty_list)
|
||||
|
||||
for i=1,player_inv:get_size("craft") do
|
||||
inv:add_item("main", player_inv:get_stack("craft", i))
|
||||
player_inv:set_stack("craft", i, nil)
|
||||
end
|
||||
|
||||
meta:set_string("formspec", "size[8,9;]"..
|
||||
"list[current_name;main;0,0;8,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", player:get_player_name().."'s fresh bones")
|
||||
meta:set_string("owner", player:get_player_name())
|
||||
meta:set_int("time", 0)
|
||||
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(10)
|
||||
end)
|
After Width: | Height: | Size: 284 B |
After Width: | Height: | Size: 300 B |
After Width: | Height: | Size: 306 B |
After Width: | Height: | Size: 289 B |
After Width: | Height: | Size: 279 B |
|
@ -0,0 +1,26 @@
|
|||
Minetest 0.4 mod: bucket
|
||||
=========================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2011-2012 Kahrl <kahrl@gmx.net>
|
||||
Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
Everything not listed in here:
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
-- Minetest 0.4 mod: bucket
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
local LIQUID_MAX = 8 --The number of water levels when liquid_finite is enabled
|
||||
|
||||
minetest.register_alias("bucket", "bucket:bucket_empty")
|
||||
minetest.register_alias("bucket_water", "bucket:bucket_water")
|
||||
minetest.register_alias("bucket_lava", "bucket:bucket_lava")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bucket:bucket_empty 1',
|
||||
recipe = {
|
||||
{'default:steel_ingot', '', 'default:steel_ingot'},
|
||||
{'', 'default:steel_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
||||
bucket = {}
|
||||
bucket.liquids = {}
|
||||
|
||||
local function check_protection(pos, name, text)
|
||||
if minetest.is_protected(pos, name) then
|
||||
minetest.log("action", (name ~= "" and name or "A mod")
|
||||
.. " tried to " .. text
|
||||
.. " at protected position "
|
||||
.. minetest.pos_to_string(pos)
|
||||
.. " with a bucket")
|
||||
minetest.record_protection_violation(pos, name)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Register a new liquid
|
||||
-- source = name of the source node
|
||||
-- flowing = name of the flowing node
|
||||
-- itemname = name of the new bucket item (or nil if liquid is not takeable)
|
||||
-- inventory_image = texture of the new bucket item (ignored if itemname == nil)
|
||||
-- This function can be called from any mod (that depends on bucket).
|
||||
function bucket.register_liquid(source, flowing, itemname, inventory_image, name)
|
||||
bucket.liquids[source] = {
|
||||
source = source,
|
||||
flowing = flowing,
|
||||
itemname = itemname,
|
||||
}
|
||||
bucket.liquids[flowing] = bucket.liquids[source]
|
||||
|
||||
if itemname ~= nil then
|
||||
minetest.register_craftitem(itemname, {
|
||||
description = name,
|
||||
inventory_image = inventory_image,
|
||||
stack_max = 1,
|
||||
liquids_pointable = true,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
-- Must be pointing to node
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local node = minetest.get_node_or_nil(pointed_thing.under)
|
||||
local ndef
|
||||
if node then
|
||||
ndef = minetest.registered_nodes[node.name]
|
||||
end
|
||||
-- Call on_rightclick if the pointed node defines it
|
||||
if ndef and ndef.on_rightclick and
|
||||
user and not user:get_player_control().sneak then
|
||||
return ndef.on_rightclick(
|
||||
pointed_thing.under,
|
||||
node, user,
|
||||
itemstack) or itemstack
|
||||
end
|
||||
|
||||
local place_liquid = function(pos, node, source, flowing, fullness)
|
||||
if check_protection(pos,
|
||||
user and user:get_player_name() or "",
|
||||
"place "..source) then
|
||||
return
|
||||
end
|
||||
if math.floor(fullness/128) == 1 or
|
||||
not minetest.setting_getbool("liquid_finite") then
|
||||
minetest.add_node(pos, {name=source,
|
||||
param2=fullness})
|
||||
return
|
||||
elseif node.name == flowing then
|
||||
fullness = fullness + node.param2
|
||||
elseif node.name == source then
|
||||
fullness = LIQUID_MAX
|
||||
end
|
||||
|
||||
if fullness >= LIQUID_MAX then
|
||||
minetest.add_node(pos, {name=source,
|
||||
param2=LIQUID_MAX})
|
||||
else
|
||||
minetest.add_node(pos, {name=flowing,
|
||||
param2=fullness})
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if pointing to a buildable node
|
||||
local fullness = tonumber(itemstack:get_metadata())
|
||||
if not fullness then fullness = LIQUID_MAX end
|
||||
|
||||
if ndef and ndef.buildable_to then
|
||||
-- buildable; replace the node
|
||||
place_liquid(pointed_thing.under, node,
|
||||
source, flowing, fullness)
|
||||
else
|
||||
-- not buildable to; place the liquid above
|
||||
-- check if the node above can be replaced
|
||||
local node = minetest.get_node_or_nil(pointed_thing.above)
|
||||
if node and minetest.registered_nodes[node.name].buildable_to then
|
||||
place_liquid(pointed_thing.above,
|
||||
node, source,
|
||||
flowing, fullness)
|
||||
else
|
||||
-- do not remove the bucket with the liquid
|
||||
return
|
||||
end
|
||||
end
|
||||
return {name="bucket:bucket_empty"}
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_craftitem("bucket:bucket_empty", {
|
||||
description = "Empty Bucket",
|
||||
inventory_image = "bucket.png",
|
||||
stack_max = 1,
|
||||
liquids_pointable = true,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
-- Must be pointing to node
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
-- Check if pointing to a liquid source
|
||||
node = minetest.get_node(pointed_thing.under)
|
||||
liquiddef = bucket.liquids[node.name]
|
||||
if liquiddef ~= nil and liquiddef.itemname ~= nil and
|
||||
(node.name == liquiddef.source or
|
||||
(node.name == liquiddef.flowing and
|
||||
minetest.setting_getbool("liquid_finite"))) then
|
||||
if check_protection(pointed_thing.under,
|
||||
user:get_player_name(),
|
||||
"take ".. node.name) then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.add_node(pointed_thing.under, {name="air"})
|
||||
|
||||
if node.name == liquiddef.source then
|
||||
node.param2 = LIQUID_MAX
|
||||
end
|
||||
return ItemStack({name = liquiddef.itemname,
|
||||
metadata = tostring(node.param2)})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
bucket.register_liquid(
|
||||
"default:water_source",
|
||||
"default:water_flowing",
|
||||
"bucket:bucket_water",
|
||||
"bucket_water.png",
|
||||
"Water Bucket"
|
||||
)
|
||||
|
||||
bucket.register_liquid(
|
||||
"default:lava_source",
|
||||
"default:lava_flowing",
|
||||
"bucket:bucket_lava",
|
||||
"bucket_lava.png",
|
||||
"Lava Bucket"
|
||||
)
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "bucket:bucket_lava",
|
||||
burntime = 60,
|
||||
replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
|
||||
})
|
After Width: | Height: | Size: 278 B |
After Width: | Height: | Size: 287 B |
After Width: | Height: | Size: 288 B |
|
@ -0,0 +1,38 @@
|
|||
=== BUILTIN_ITEM MOD for MINETEST-C55 ===
|
||||
by PilzAdam
|
||||
|
||||
Features:
|
||||
This mod adds some new features to the builtin items:
|
||||
- The items are pushed by flowing water
|
||||
- The items are destroyed by lava
|
||||
- The items are removed after 300 seconds or the time that is specified by
|
||||
remove_items in minetest.conf (0 disables it)
|
||||
|
||||
How to install:
|
||||
Unzip the archive an place it in minetest-base-directory/mods/minetest/
|
||||
if you have a windows client or a linux run-in-place client. If you have
|
||||
a linux system-wide instalation place it in ~/.minetest/mods/minetest/.
|
||||
If you want to install this mod only in one world create the folder
|
||||
worldmods/ in your worlddirectory.
|
||||
For further information or help see:
|
||||
http://wiki.minetest.com/wiki/Installing_Mods
|
||||
|
||||
License:
|
||||
WTFPL (see below)
|
||||
|
||||
See also:
|
||||
http://minetest.net/
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
@ -0,0 +1,183 @@
|
|||
minetest.register_entity(":__builtin:item", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collisionbox = {-0.17,-0.17,-0.17, 0.17,0.17,0.17},
|
||||
visual = "sprite",
|
||||
visual_size = {x=0.5, y=0.5},
|
||||
textures = {""},
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = false,
|
||||
timer = 0,
|
||||
},
|
||||
|
||||
itemstring = '',
|
||||
physical_state = true,
|
||||
|
||||
set_item = function(self, itemstring)
|
||||
self.itemstring = itemstring
|
||||
local stack = ItemStack(itemstring)
|
||||
local itemtable = stack:to_table()
|
||||
local itemname = nil
|
||||
if itemtable then
|
||||
itemname = stack:to_table().name
|
||||
end
|
||||
local item_texture = nil
|
||||
local item_type = ""
|
||||
if minetest.registered_items[itemname] then
|
||||
item_texture = minetest.registered_items[itemname].inventory_image
|
||||
item_type = minetest.registered_items[itemname].type
|
||||
end
|
||||
prop = {
|
||||
is_visible = true,
|
||||
visual = "sprite",
|
||||
textures = {"unknown_item.png"}
|
||||
}
|
||||
if item_texture and item_texture ~= "" then
|
||||
prop.visual = "sprite"
|
||||
prop.textures = {item_texture}
|
||||
prop.visual_size = {x=0.50, y=0.50}
|
||||
else
|
||||
prop.visual = "wielditem"
|
||||
prop.textures = {itemname}
|
||||
prop.visual_size = {x=0.20, y=0.20}
|
||||
prop.automatic_rotate = math.pi * 0.25
|
||||
end
|
||||
self.object:set_properties(prop)
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
--return self.itemstring
|
||||
return minetest.serialize({
|
||||
itemstring = self.itemstring,
|
||||
always_collect = self.always_collect,
|
||||
timer = self.timer,
|
||||
})
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if string.sub(staticdata, 1, string.len("return")) == "return" then
|
||||
local data = minetest.deserialize(staticdata)
|
||||
if data and type(data) == "table" then
|
||||
self.itemstring = data.itemstring
|
||||
self.always_collect = data.always_collect
|
||||
self.timer = data.timer
|
||||
if not self.timer then
|
||||
self.timer = 0
|
||||
end
|
||||
self.timer = self.timer+dtime_s
|
||||
end
|
||||
else
|
||||
self.itemstring = staticdata
|
||||
end
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
self.object:setvelocity({x=0, y=2, z=0})
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self:set_item(self.itemstring)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
local time = minetest.setting_get("remove_items")
|
||||
if not time then
|
||||
time = 300
|
||||
end
|
||||
if not self.timer then
|
||||
self.timer = 0
|
||||
end
|
||||
self.timer = self.timer + dtime
|
||||
if time ~= 0 and (self.timer > time) then
|
||||
self.object:remove()
|
||||
end
|
||||
|
||||
local p = self.object:getpos()
|
||||
|
||||
local name = minetest.env:get_node(p).name
|
||||
if name == "default:lava_flowing" or name == "default:lava_source" then
|
||||
minetest.sound_play("builtin_item_lava", {pos=self.object:getpos()})
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
--[[
|
||||
if minetest.registered_nodes[name].liquidtype == "flowing" then
|
||||
get_flowing_dir = function(self)
|
||||
local pos = self.object:getpos()
|
||||
local param2 = minetest.env:get_node(pos).param2
|
||||
for i,d in ipairs({-1, 1, -1, 1}) do
|
||||
if i<3 then
|
||||
pos.x = pos.x+d
|
||||
else
|
||||
pos.z = pos.z+d
|
||||
end
|
||||
|
||||
local name = minetest.env:get_node(pos).name
|
||||
local par2 = minetest.env:get_node(pos).param2
|
||||
if name == "default:water_flowing" and par2 < param2 then
|
||||
return pos
|
||||
end
|
||||
|
||||
if i<3 then
|
||||
pos.x = pos.x-d
|
||||
else
|
||||
pos.z = pos.z-d
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local vec = get_flowing_dir(self)
|
||||
if vec then
|
||||
local v = self.object:getvelocity()
|
||||
if vec and vec.x-p.x > 0 then
|
||||
self.object:setvelocity({x=0.5,y=v.y,z=0})
|
||||
elseif vec and vec.x-p.x < 0 then
|
||||
self.object:setvelocity({x=-0.5,y=v.y,z=0})
|
||||
elseif vec and vec.z-p.z > 0 then
|
||||
self.object:setvelocity({x=0,y=v.y,z=0.5})
|
||||
elseif vec and vec.z-p.z < 0 then
|
||||
self.object:setvelocity({x=0,y=v.y,z=-0.5})
|
||||
end
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self.physical_state = true
|
||||
self.object:set_properties({
|
||||
physical = true
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
p.y = p.y - 0.3
|
||||
local nn = minetest.env:get_node(p).name
|
||||
-- If node is not registered or node is walkably solid
|
||||
if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable then
|
||||
if self.physical_state then
|
||||
self.object:setvelocity({x=0,y=0,z=0})
|
||||
self.object:setacceleration({x=0, y=0, z=0})
|
||||
self.physical_state = false
|
||||
self.object:set_properties({
|
||||
physical = false
|
||||
})
|
||||
end
|
||||
else
|
||||
if not self.physical_state then
|
||||
self.object:setvelocity({x=0,y=0,z=0})
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self.physical_state = true
|
||||
self.object:set_properties({
|
||||
physical = true
|
||||
})
|
||||
end
|
||||
end
|
||||
]]
|
||||
end,
|
||||
|
||||
on_punch = function(self, hitter)
|
||||
if self.itemstring ~= '' then
|
||||
hitter:get_inventory():add_item("main", self.itemstring)
|
||||
end
|
||||
self.object:remove()
|
||||
end,
|
||||
})
|
||||
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.log("action", "builtin_item loaded")
|
||||
end
|
|
@ -0,0 +1,182 @@
|
|||
minetest.register_entity(":__builtin:item", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collisionbox = {-0.17,-0.17,-0.17, 0.17,0.17,0.17},
|
||||
visual = "sprite",
|
||||
visual_size = {x=0.5, y=0.5},
|
||||
textures = {""},
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = false,
|
||||
timer = 0,
|
||||
},
|
||||
|
||||
itemstring = '',
|
||||
physical_state = true,
|
||||
|
||||
set_item = function(self, itemstring)
|
||||
self.itemstring = itemstring
|
||||
local stack = ItemStack(itemstring)
|
||||
local itemtable = stack:to_table()
|
||||
local itemname = nil
|
||||
if itemtable then
|
||||
itemname = stack:to_table().name
|
||||
end
|
||||
local item_texture = nil
|
||||
local item_type = ""
|
||||
if minetest.registered_items[itemname] then
|
||||
item_texture = minetest.registered_items[itemname].inventory_image
|
||||
item_type = minetest.registered_items[itemname].type
|
||||
end
|
||||
prop = {
|
||||
is_visible = true,
|
||||
visual = "sprite",
|
||||
textures = {"unknown_item.png"}
|
||||
}
|
||||
if item_texture and item_texture ~= "" then
|
||||
prop.visual = "sprite"
|
||||
prop.textures = {item_texture}
|
||||
prop.visual_size = {x=0.50, y=0.50}
|
||||
else
|
||||
prop.visual = "wielditem"
|
||||
prop.textures = {itemname}
|
||||
prop.visual_size = {x=0.20, y=0.20}
|
||||
prop.automatic_rotate = math.pi * 0.25
|
||||
end
|
||||
self.object:set_properties(prop)
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
--return self.itemstring
|
||||
return minetest.serialize({
|
||||
itemstring = self.itemstring,
|
||||
always_collect = self.always_collect,
|
||||
timer = self.timer,
|
||||
})
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if string.sub(staticdata, 1, string.len("return")) == "return" then
|
||||
local data = minetest.deserialize(staticdata)
|
||||
if data and type(data) == "table" then
|
||||
self.itemstring = data.itemstring
|
||||
self.always_collect = data.always_collect
|
||||
self.timer = data.timer
|
||||
if not self.timer then
|
||||
self.timer = 0
|
||||
end
|
||||
self.timer = self.timer+dtime_s
|
||||
end
|
||||
else
|
||||
self.itemstring = staticdata
|
||||
end
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
self.object:setvelocity({x=0, y=2, z=0})
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self:set_item(self.itemstring)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
local time = minetest.setting_get("remove_items")
|
||||
if not time then
|
||||
time = 300
|
||||
end
|
||||
if not self.timer then
|
||||
self.timer = 0
|
||||
end
|
||||
self.timer = self.timer + dtime
|
||||
if time ~= 0 and (self.timer > time) then
|
||||
self.object:remove()
|
||||
end
|
||||
|
||||
local p = self.object:getpos()
|
||||
|
||||
local name = minetest.env:get_node(p).name
|
||||
if name == "default:lava_flowing" or name == "default:lava_source" then
|
||||
minetest.sound_play("builtin_item_lava", {pos=self.object:getpos()})
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
--[[
|
||||
if minetest.registered_nodes[name].liquidtype == "flowing" then
|
||||
get_flowing_dir = function(self)
|
||||
local pos = self.object:getpos()
|
||||
local param2 = minetest.env:get_node(pos).param2
|
||||
for i,d in ipairs({-1, 1, -1, 1}) do
|
||||
if i<3 then
|
||||
pos.x = pos.x+d
|
||||
else
|
||||
pos.z = pos.z+d
|
||||
end
|
||||
|
||||
local name = minetest.env:get_node(pos).name
|
||||
local par2 = minetest.env:get_node(pos).param2
|
||||
if name == "default:water_flowing" and par2 < param2 then
|
||||
return pos
|
||||
end
|
||||
|
||||
if i<3 then
|
||||
pos.x = pos.x-d
|
||||
else
|
||||
pos.z = pos.z-d
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local vec = get_flowing_dir(self)
|
||||
if vec then
|
||||
local v = self.object:getvelocity()
|
||||
if vec and vec.x-p.x > 0 then
|
||||
self.object:setvelocity({x=0.5,y=v.y,z=0})
|
||||
elseif vec and vec.x-p.x < 0 then
|
||||
self.object:setvelocity({x=-0.5,y=v.y,z=0})
|
||||
elseif vec and vec.z-p.z > 0 then
|
||||
self.object:setvelocity({x=0,y=v.y,z=0.5})
|
||||
elseif vec and vec.z-p.z < 0 then
|
||||
self.object:setvelocity({x=0,y=v.y,z=-0.5})
|
||||
end
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self.physical_state = true
|
||||
self.object:set_properties({
|
||||
physical = true
|
||||
})
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
p.y = p.y - 0.3
|
||||
local nn = minetest.env:get_node(p).name
|
||||
-- If node is not registered or node is walkably solid
|
||||
if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable then
|
||||
if self.physical_state then
|
||||
self.object:setvelocity({x=0,y=0,z=0})
|
||||
self.object:setacceleration({x=0, y=0, z=0})
|
||||
self.physical_state = false
|
||||
self.object:set_properties({
|
||||
physical = false
|
||||
})
|
||||
end
|
||||
else
|
||||
if not self.physical_state then
|
||||
self.object:setvelocity({x=0,y=0,z=0})
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self.physical_state = true
|
||||
self.object:set_properties({
|
||||
physical = true
|
||||
})
|
||||
end
|
||||
end
|
||||
end,
|
||||
]]
|
||||
on_punch = function(self, hitter)
|
||||
if self.itemstring ~= '' then
|
||||
hitter:get_inventory():add_item("main", self.itemstring)
|
||||
end
|
||||
self.object:remove()
|
||||
end,
|
||||
})
|
||||
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.log("action", "builtin_item loaded")
|
||||
end
|
|
@ -0,0 +1,81 @@
|
|||
-- Basket
|
||||
minetest.register_node("bushes:basket_empty", {
|
||||
description = "Basket",
|
||||
tiles = {
|
||||
"bushes_basket_empty_top.png",
|
||||
"bushes_basket_bottom.png",
|
||||
"bushes_basket_side.png"
|
||||
},
|
||||
groups = { dig_immediate = 3 },
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bushes:basket_empty',
|
||||
recipe = {
|
||||
{ 'default:stick', 'default:stick', 'default:stick' },
|
||||
{ '', 'default:stick', '' },
|
||||
},
|
||||
})
|
||||
|
||||
-- Sugar
|
||||
minetest.register_craftitem("bushes:sugar", {
|
||||
description = "Sugar",
|
||||
inventory_image = "bushes_sugar.png",
|
||||
on_use = minetest.item_eat(1),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bushes:sugar 1',
|
||||
recipe = {
|
||||
{ 'default:papyrus', 'default:papyrus' },
|
||||
},
|
||||
})
|
||||
|
||||
-- Raw pie
|
||||
minetest.register_craftitem("bushes:berry_pie_raw", {
|
||||
description = "Raw berry pie",
|
||||
inventory_image = "bushes_berry_pie_raw.png",
|
||||
on_use = minetest.item_eat(3),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bushes:berry_pie_raw 1',
|
||||
recipe = {
|
||||
{ 'bushes:sugar', 'default:junglegrass', 'bushes:sugar' },
|
||||
{ 'bushes:strawberry', 'bushes:strawberry', 'bushes:strawberry' },
|
||||
},
|
||||
})
|
||||
|
||||
-- Cooked pie
|
||||
minetest.register_craftitem("bushes:berry_pie_cooked", {
|
||||
description = "Cooked berry pie",
|
||||
inventory_image = "bushes_berry_pie_cooked.png",
|
||||
on_use = minetest.item_eat(4),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = 'cooking',
|
||||
output = 'bushes:berry_pie_cooked',
|
||||
recipe = 'bushes:berry_pie_raw',
|
||||
cooktime = 30,
|
||||
})
|
||||
|
||||
-- Basket with pies
|
||||
minetest.register_node("bushes:basket_pies", {
|
||||
description = "Basket with pies",
|
||||
tiles = {
|
||||
"bushes_basket_full_top.png",
|
||||
"bushes_basket_bottom.png",
|
||||
"bushes_basket_side.png"
|
||||
},
|
||||
on_use = minetest.item_eat(15),
|
||||
groups = { dig_immediate = 3 },
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bushes:basket_pies 1',
|
||||
recipe = {
|
||||
{ 'bushes:berry_pie_cooked', 'bushes:berry_pie_cooked', 'bushes:berry_pie_cooked' },
|
||||
{ '', 'bushes:basket_empty', '' },
|
||||
},
|
||||
})
|
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
plants_lib
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,50 @@
|
|||
local BUSHES = {
|
||||
"strawberry",
|
||||
}
|
||||
|
||||
local BUSHES_DESCRIPTIONS = {
|
||||
"Strawberry",
|
||||
}
|
||||
|
||||
for i, bush_name in ipairs(BUSHES) do
|
||||
minetest.register_node("bushes:" .. bush_name .. "_bush", {
|
||||
description = BUSHES_DESCRIPTIONS[i] .. " bush",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.3,
|
||||
tiles = { "bushes_" .. bush_name .. "_bush.png" },
|
||||
inventory_image = "bushes_" .. bush_name .. "_bush.png",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
drop = 'bushes:' .. bush_name .. ' 4',
|
||||
groups = { snappy = 3, bush=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("bushes:" .. bush_name, {
|
||||
description = BUSHES_DESCRIPTIONS[i],
|
||||
inventory_image = "bushes_" .. bush_name .. ".png",
|
||||
stack_max = 99,
|
||||
on_use = minetest.item_eat(1),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bushes:' .. bush_name .. '_bush',
|
||||
recipe = {
|
||||
{ 'bushes:' .. bush_name, 'bushes:' .. bush_name, 'bushes:' .. bush_name },
|
||||
{ 'bushes:' .. bush_name, 'bushes:' .. bush_name, 'bushes:' .. bush_name },
|
||||
}
|
||||
})
|
||||
|
||||
plantslib:spawn_on_surfaces(
|
||||
3600,
|
||||
"bushes:"..bush_name.."_bush",
|
||||
15,
|
||||
100,
|
||||
"default:dirt_with_grass",
|
||||
"group:bush"
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath('bushes') .. '/cooking.lua')
|
|
@ -0,0 +1,50 @@
|
|||
local BUSHES = {
|
||||
"strawberry",
|
||||
}
|
||||
|
||||
local BUSHES_DESCRIPTIONS = {
|
||||
"Strawberry",
|
||||
}
|
||||
|
||||
for i, bush_name in ipairs(BUSHES) do
|
||||
minetest.register_node("bushes:" .. bush_name .. "_bush", {
|
||||
description = BUSHES_DESCRIPTIONS[i] .. " bush",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.3,
|
||||
tiles = { "bushes_" .. bush_name .. "_bush.png" },
|
||||
inventory_image = "bushes_" .. bush_name .. "_bush.png",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
drop = 'bushes:' .. bush_name .. ' 4',
|
||||
groups = { snappy = 3, bush=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("bushes:" .. bush_name, {
|
||||
description = BUSHES_DESCRIPTIONS[i],
|
||||
inventory_image = "bushes_" .. bush_name .. ".png",
|
||||
stack_max = 99,
|
||||
on_use = minetest.item_eat(1),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bushes:' .. bush_name .. '_bush',
|
||||
recipe = {
|
||||
{ 'bushes:' .. bush_name, 'bushes:' .. bush_name, 'bushes:' .. bush_name },
|
||||
{ 'bushes:' .. bush_name, 'bushes:' .. bush_name, 'bushes:' .. bush_name },
|
||||
}
|
||||
})
|
||||
|
||||
spawn_on_surfaces(
|
||||
3600,
|
||||
"bushes:"..bush_name.."_bush",
|
||||
15,
|
||||
100,
|
||||
"default:dirt_with_grass",
|
||||
"group:bush"
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath('bushes') .. '/cooking.lua')
|
After Width: | Height: | Size: 283 B |
After Width: | Height: | Size: 285 B |
After Width: | Height: | Size: 633 B |
After Width: | Height: | Size: 320 B |
After Width: | Height: | Size: 918 B |
After Width: | Height: | Size: 918 B |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 7.1 KiB |
After Width: | Height: | Size: 4.3 KiB |
|
@ -0,0 +1,22 @@
|
|||
Minetest 0.4 mod: creative
|
||||
==========================
|
||||
|
||||
Implements creative mode.
|
||||
|
||||
Switch on by using the "creative_mode" setting.
|
||||
|
||||
Registered items that
|
||||
- have a description, and
|
||||
- do not have the group not_in_creative_inventory
|
||||
are added to the creative inventory.
|
||||
|
||||
License of source code and media files:
|
||||
---------------------------------------
|
||||
Copyright (C) 2012 Perttu Ahola (celeron55) <celeron55@gmail.com>
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,165 @@
|
|||
-- minetest/creative/init.lua
|
||||
|
||||
creative_inventory = {}
|
||||
creative_inventory.creative_inventory_size = 0
|
||||
|
||||
-- Create detached creative inventory after loading all mods
|
||||
minetest.after(0, function()
|
||||
local inv = minetest.create_detached_inventory("creative", {
|
||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
return count
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
return 0
|
||||
end,
|
||||
allow_take = function(inv, listname, index, stack, player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
return -1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||
end,
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
end,
|
||||
on_take = function(inv, listname, index, stack, player)
|
||||
--print(player:get_player_name().." takes item from creative inventory; listname="..dump(listname)..", index="..dump(index)..", stack="..dump(stack))
|
||||
if stack then
|
||||
minetest.log("action", player:get_player_name().." takes "..dump(stack:get_name()).." from creative inventory")
|
||||
--print("stack:get_name()="..dump(stack:get_name())..", stack:get_count()="..dump(stack:get_count()))
|
||||
end
|
||||
end,
|
||||
})
|
||||
local creative_list = {}
|
||||
for name,def in pairs(minetest.registered_items) do
|
||||
if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0)
|
||||
and def.description and def.description ~= "" then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
end
|
||||
table.sort(creative_list)
|
||||
inv:set_size("main", #creative_list)
|
||||
for _,itemstring in ipairs(creative_list) do
|
||||
inv:add_item("main", ItemStack(itemstring))
|
||||
end
|
||||
creative_inventory.creative_inventory_size = #creative_list
|
||||
--print("creative inventory size: "..dump(creative_inventory.creative_inventory_size))
|
||||
end)
|
||||
|
||||
-- Create the trash field
|
||||
local trash = minetest.create_detached_inventory("creative_trash", {
|
||||
-- Allow the stack to be placed and remove it in on_put()
|
||||
-- This allows the creative inventory to restore the stack
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
return stack:get_count()
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
inv:set_stack(listname, index, "")
|
||||
end,
|
||||
})
|
||||
trash:set_size("main", 1)
|
||||
|
||||
|
||||
creative_inventory.set_creative_formspec = function(player, start_i, pagenum)
|
||||
pagenum = math.floor(pagenum)
|
||||
local pagemax = math.floor((creative_inventory.creative_inventory_size-1) / (6*4) + 1)
|
||||
player:set_inventory_formspec("size[13,7.5]"..
|
||||
--"image[6,0.6;1,2;player.png]"..
|
||||
"list[current_player;main;5,3.5;8,4;]"..
|
||||
"list[current_player;craft;8,0;3,3;]"..
|
||||
"list[current_player;craftpreview;12,1;1,1;]"..
|
||||
"list[detached:creative;main;0.3,0.5;4,6;"..tostring(start_i).."]"..
|
||||
"label[2.0,6.55;"..tostring(pagenum).."/"..tostring(pagemax).."]"..
|
||||
"button[0.3,6.5;1.6,1;creative_prev;<<]"..
|
||||
"button[2.7,6.5;1.6,1;creative_next;>>]"..
|
||||
"label[5,1.5;Trash:]"..
|
||||
"list[detached:creative_trash;main;5,2;1,1;]")
|
||||
end
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
-- If in creative mode, modify player's inventory forms
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
return
|
||||
end
|
||||
creative_inventory.set_creative_formspec(player, 0, 1)
|
||||
end)
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
return
|
||||
end
|
||||
-- Figure out current page from formspec
|
||||
local current_page = 0
|
||||
local formspec = player:get_inventory_formspec()
|
||||
local start_i = string.match(formspec, "list%[detached:creative;main;[%d.]+,[%d.]+;[%d.]+,[%d.]+;(%d+)%]")
|
||||
start_i = tonumber(start_i) or 0
|
||||
|
||||
if fields.creative_prev then
|
||||
start_i = start_i - 4*6
|
||||
end
|
||||
if fields.creative_next then
|
||||
start_i = start_i + 4*6
|
||||
end
|
||||
|
||||
if start_i < 0 then
|
||||
start_i = start_i + 4*6
|
||||
end
|
||||
if start_i >= creative_inventory.creative_inventory_size then
|
||||
start_i = start_i - 4*6
|
||||
end
|
||||
|
||||
if start_i < 0 or start_i >= creative_inventory.creative_inventory_size then
|
||||
start_i = 0
|
||||
end
|
||||
|
||||
creative_inventory.set_creative_formspec(player, start_i, start_i / (6*4) + 1)
|
||||
end)
|
||||
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
local digtime = 0.5
|
||||
minetest.register_item(":", {
|
||||
type = "none",
|
||||
wield_image = "wieldhand.png",
|
||||
wield_scale = {x=1,y=1,z=2.5},
|
||||
range = 10,
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.5,
|
||||
max_drop_level = 3,
|
||||
groupcaps = {
|
||||
crumbly = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3},
|
||||
cracky = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3},
|
||||
snappy = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3},
|
||||
choppy = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3},
|
||||
oddly_breakable_by_hand = {times={[1]=digtime, [2]=digtime, [3]=digtime}, uses=0, maxlevel=3},
|
||||
},
|
||||
damage_groups = {fleshy = 10},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
||||
return true
|
||||
end)
|
||||
|
||||
function minetest.handle_node_drops(pos, drops, digger)
|
||||
if not digger or not digger:is_player() then
|
||||
return
|
||||
end
|
||||
local inv = digger:get_inventory()
|
||||
if inv then
|
||||
for _,item in ipairs(drops) do
|
||||
item = ItemStack(item):get_name()
|
||||
if not inv:contains_item("main", item) then
|
||||
inv:add_item("main", item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,181 @@
|
|||
Minetest 0.4 mod: default
|
||||
==========================
|
||||
|
||||
License of source code:
|
||||
-----------------------
|
||||
Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
|
||||
License of media (textures and sounds)
|
||||
--------------------------------------
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
Authors of media files
|
||||
-----------------------
|
||||
Everything not listed in here:
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
Cisoun's WTFPL texture pack:
|
||||
default_chest_front.png
|
||||
default_chest_lock.png
|
||||
default_chest_side.png
|
||||
default_chest_top.png
|
||||
default_stone_brick.png
|
||||
default_dirt.png
|
||||
default_grass.png
|
||||
default_grass_side.png
|
||||
default_jungletree.png
|
||||
default_jungletree_top.png
|
||||
default_lava.png
|
||||
default_leaves.png
|
||||
default_sapling.png
|
||||
default_sign_wall.png
|
||||
default_stone.png
|
||||
default_tool_mesepick.png
|
||||
default_tool_steelpick.png
|
||||
default_tool_steelshovel.png
|
||||
default_tool_stonepick.png
|
||||
default_tool_stoneshovel.png
|
||||
default_tool_woodpick.png
|
||||
default_tool_woodshovel.png
|
||||
default_tree.png
|
||||
default_tree_top.png
|
||||
default_water.png
|
||||
|
||||
Originating from G4JC's Almost MC Texture Pack:
|
||||
default_wood.png
|
||||
default_torch.png
|
||||
default_torch_on_ceiling.png
|
||||
default_torch_on_floor.png
|
||||
default_cobble.png
|
||||
|
||||
VanessaE's animated torches (WTFPL):
|
||||
default_torch_animated.png
|
||||
default_torch_on_ceiling_animated.png
|
||||
default_torch_on_floor_animated.png
|
||||
default_torch_on_floor.png
|
||||
|
||||
RealBadAngel's animated water (WTFPL):
|
||||
default_water_source_animated.png
|
||||
default_water_flowing_animated.png
|
||||
|
||||
VanessaE (WTFPL):
|
||||
default_nc_back.png
|
||||
default_nc_front.png
|
||||
default_nc_rb.png
|
||||
default_nc_side.png
|
||||
default_grass_*.png
|
||||
default_desert_sand.png
|
||||
default_desert_stone.png
|
||||
default_desert_stone_brick.png
|
||||
default_sand.png
|
||||
default_sandstone_brick.png
|
||||
|
||||
Calinou (CC BY-SA):
|
||||
default_brick.png
|
||||
default_clay_brick.png
|
||||
default_papyrus.png
|
||||
default_tool_steelsword.png
|
||||
default_bronze_ingot.png
|
||||
default_copper_ingot.png
|
||||
default_copper_lump.png
|
||||
default_mineral_copper.png
|
||||
|
||||
MirceaKitsune (WTFPL):
|
||||
character.x
|
||||
|
||||
Jordach (CC BY-SA 3.0):
|
||||
character.png
|
||||
|
||||
PilzAdam (WTFPL):
|
||||
default_jungleleaves.png
|
||||
default_junglesapling.png
|
||||
default_junglewood.png
|
||||
default_obsidian_glass.png
|
||||
default_obsidian_shard.png
|
||||
default_mossycobble.png
|
||||
default_gold_ingot.png
|
||||
default_gold_lump.png
|
||||
default_mineral_gold.png
|
||||
default_diamond.png
|
||||
default_tool_diamondpick.png
|
||||
default_tool_diamondsword.png
|
||||
default_tool_diamondshovel.png
|
||||
default_tool_diamondaxe.png
|
||||
default_tool_meseaxe.png
|
||||
default_tool_meseshovel.png
|
||||
default_tool_mesesword.png
|
||||
default_tool_bronzeaxe.png
|
||||
default_tool_bronzepick.png
|
||||
default_tool_bronzeshovel.png
|
||||
default_tool_bronzesword.png
|
||||
default_snowball.png
|
||||
|
||||
jojoa1997 (WTFPL):
|
||||
default_obsidian.png
|
||||
|
||||
InfinityProject (WTFPL):
|
||||
default_mineral_diamond.png
|
||||
|
||||
Splizard (CC BY-SA 3.0):
|
||||
default_snow.png
|
||||
default_snow_side.png
|
||||
default_ice.png
|
||||
|
||||
Zeg9 (CC BY-SA 3.0):
|
||||
default_coal_block.png
|
||||
default_steel_block.png
|
||||
default_copper_block.png
|
||||
default_bronze_block.png
|
||||
default_gold_block.png
|
||||
default_diamond_block.png
|
||||
|
||||
kaeza (WTFPL):
|
||||
bubble.png
|
||||
|
||||
Glass breaking sounds (CC BY 3.0):
|
||||
1: http://www.freesound.org/people/cmusounddesign/sounds/71947/
|
||||
2: http://www.freesound.org/people/Tomlija/sounds/97669/
|
||||
3: http://www.freesound.org/people/lsprice/sounds/88808/
|
||||
|
||||
Mito551 (sounds) (CC BY-SA):
|
||||
default_dig_choppy.ogg
|
||||
default_dig_cracky.ogg
|
||||
default_dig_crumbly.1.ogg
|
||||
default_dig_crumbly.2.ogg
|
||||
default_dig_dig_immediate.ogg
|
||||
default_dig_oddly_breakable_by_hand.ogg
|
||||
default_dug_node.1.ogg
|
||||
default_dug_node.2.ogg
|
||||
default_grass_footstep.1.ogg
|
||||
default_grass_footstep.2.ogg
|
||||
default_grass_footstep.3.ogg
|
||||
default_gravel_footstep.1.ogg
|
||||
default_gravel_footstep.2.ogg
|
||||
default_gravel_footstep.3.ogg
|
||||
default_gravel_footstep.4.ogg
|
||||
default_grass_footstep.1.ogg
|
||||
default_place_node.1.ogg
|
||||
default_place_node.2.ogg
|
||||
default_place_node.3.ogg
|
||||
default_place_node_hard.1.ogg
|
||||
default_place_node_hard.2.ogg
|
||||
default_snow_footstep.1.ogg
|
||||
default_snow_footstep.2.ogg
|
||||
default_hard_footstep.1.ogg
|
||||
default_hard_footstep.2.ogg
|
||||
default_hard_footstep.3.ogg
|
||||
default_sand_footstep.1.ogg
|
||||
default_sand_footstep.2.ogg
|
||||
default_wood_footstep.1.ogg
|
||||
default_wood_footstep.2.ogg
|
||||
default_dirt_footstep.1.ogg
|
||||
default_dirt_footstep.2.ogg
|
||||
default_glass_footstep.ogg
|
|
@ -0,0 +1,742 @@
|
|||
-- mods/default/crafting.lua
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:wood 4',
|
||||
recipe = {
|
||||
{'default:tree'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:junglewood 4',
|
||||
recipe = {
|
||||
{'default:jungletree'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:stick 4',
|
||||
recipe = {
|
||||
{'group:wood'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:fence_wood 2',
|
||||
recipe = {
|
||||
{'group:stick', 'group:stick', 'group:stick'},
|
||||
{'group:stick', 'group:stick', 'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:sign_wall',
|
||||
recipe = {
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
{'', 'group:stick', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:torch 4',
|
||||
recipe = {
|
||||
{'default:coal_lump'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:pick_wood',
|
||||
recipe = {
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
{'', 'group:stick', ''},
|
||||
{'', 'group:stick', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:pick_stone',
|
||||
recipe = {
|
||||
{'group:stone', 'group:stone', 'group:stone'},
|
||||
{'', 'group:stick', ''},
|
||||
{'', 'group:stick', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:pick_steel',
|
||||
recipe = {
|
||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
||||
{'', 'group:stick', ''},
|
||||
{'', 'group:stick', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:pick_bronze',
|
||||
recipe = {
|
||||
{'default:bronze_ingot', 'default:bronze_ingot', 'default:bronze_ingot'},
|
||||
{'', 'group:stick', ''},
|
||||
{'', 'group:stick', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:pick_mese',
|
||||
recipe = {
|
||||
{'default:mese_crystal', 'default:mese_crystal', 'default:mese_crystal'},
|
||||
{'', 'group:stick', ''},
|
||||
{'', 'group:stick', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:pick_diamond',
|
||||
recipe = {
|
||||
{'default:diamond', 'default:diamond', 'default:diamond'},
|
||||
{'', 'group:stick', ''},
|
||||
{'', 'group:stick', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:shovel_wood',
|
||||
recipe = {
|
||||
{'group:wood'},
|
||||
{'group:stick'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:shovel_stone',
|
||||
recipe = {
|
||||
{'group:stone'},
|
||||
{'group:stick'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:shovel_steel',
|
||||
recipe = {
|
||||
{'default:steel_ingot'},
|
||||
{'group:stick'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:shovel_bronze',
|
||||
recipe = {
|
||||
{'default:bronze_ingot'},
|
||||
{'group:stick'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:shovel_mese',
|
||||
recipe = {
|
||||
{'default:mese_crystal'},
|
||||
{'group:stick'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:shovel_diamond',
|
||||
recipe = {
|
||||
{'default:diamond'},
|
||||
{'group:stick'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:axe_wood',
|
||||
recipe = {
|
||||
{'group:wood', 'group:wood'},
|
||||
{'group:wood', 'group:stick'},
|
||||
{'', 'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:axe_stone',
|
||||
recipe = {
|
||||
{'group:stone', 'group:stone'},
|
||||
{'group:stone', 'group:stick'},
|
||||
{'', 'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:axe_steel',
|
||||
recipe = {
|
||||
{'default:steel_ingot', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', 'group:stick'},
|
||||
{'', 'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:axe_bronze',
|
||||
recipe = {
|
||||
{'default:bronze_ingot', 'default:bronze_ingot'},
|
||||
{'default:bronze_ingot', 'group:stick'},
|
||||
{'', 'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:axe_mese',
|
||||
recipe = {
|
||||
{'default:mese_crystal', 'default:mese_crystal'},
|
||||
{'default:mese_crystal', 'group:stick'},
|
||||
{'', 'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:axe_diamond',
|
||||
recipe = {
|
||||
{'default:diamond', 'default:diamond'},
|
||||
{'default:diamond', 'group:stick'},
|
||||
{'', 'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:club_wood',
|
||||
recipe = {
|
||||
{'group:wood'},
|
||||
{'group:wood'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:club_stone',
|
||||
recipe = {
|
||||
{'group:stone'},
|
||||
{'group:stone'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:sword_steel',
|
||||
recipe = {
|
||||
{'default:steel_ingot'},
|
||||
{'default:steel_ingot'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:sword_bronze',
|
||||
recipe = {
|
||||
{'default:bronze_ingot'},
|
||||
{'default:bronze_ingot'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:sword_mese',
|
||||
recipe = {
|
||||
{'default:mese_crystal'},
|
||||
{'default:mese_crystal'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:sword_diamond',
|
||||
recipe = {
|
||||
{'default:diamond'},
|
||||
{'default:diamond'},
|
||||
{'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:rail 15',
|
||||
recipe = {
|
||||
{'default:steel_ingot', '', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', 'group:stick', 'default:steel_ingot'},
|
||||
{'default:steel_ingot', '', 'default:steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:chest',
|
||||
recipe = {
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
{'group:wood', '', 'group:wood'},
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:chest_locked',
|
||||
recipe = {
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
{'group:wood', 'default:steel_ingot', 'group:wood'},
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:furnace',
|
||||
recipe = {
|
||||
{'group:stone', 'group:stone', 'group:stone'},
|
||||
{'group:stone', '', 'group:stone'},
|
||||
{'group:stone', 'group:stone', 'group:stone'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "default:bronze_ingot",
|
||||
recipe = {"default:steel_ingot", "default:copper_ingot"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:coalblock',
|
||||
recipe = {
|
||||
{'default:coal_lump', 'default:coal_lump', 'default:coal_lump'},
|
||||
{'default:coal_lump', 'default:coal_lump', 'default:coal_lump'},
|
||||
{'default:coal_lump', 'default:coal_lump', 'default:coal_lump'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:coal_lump 9',
|
||||
recipe = {
|
||||
{'default:coalblock'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:steelblock',
|
||||
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', 'default:steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:steel_ingot 9',
|
||||
recipe = {
|
||||
{'default:steelblock'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:copperblock',
|
||||
recipe = {
|
||||
{'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
|
||||
{'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
|
||||
{'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:copper_ingot 9',
|
||||
recipe = {
|
||||
{'default:copperblock'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:bronzeblock',
|
||||
recipe = {
|
||||
{'default:bronze_ingot', 'default:bronze_ingot', 'default:bronze_ingot'},
|
||||
{'default:bronze_ingot', 'default:bronze_ingot', 'default:bronze_ingot'},
|
||||
{'default:bronze_ingot', 'default:bronze_ingot', 'default:bronze_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:bronze_ingot 9',
|
||||
recipe = {
|
||||
{'default:bronzeblock'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:goldblock',
|
||||
recipe = {
|
||||
{'default:gold_ingot', 'default:gold_ingot', 'default:gold_ingot'},
|
||||
{'default:gold_ingot', 'default:gold_ingot', 'default:gold_ingot'},
|
||||
{'default:gold_ingot', 'default:gold_ingot', 'default:gold_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:gold_ingot 9',
|
||||
recipe = {
|
||||
{'default:goldblock'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:diamondblock',
|
||||
recipe = {
|
||||
{'default:diamond', 'default:diamond', 'default:diamond'},
|
||||
{'default:diamond', 'default:diamond', 'default:diamond'},
|
||||
{'default:diamond', 'default:diamond', 'default:diamond'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:diamond 9',
|
||||
recipe = {
|
||||
{'default:diamondblock'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:sandstone',
|
||||
recipe = {
|
||||
{'group:sand', 'group:sand'},
|
||||
{'group:sand', 'group:sand'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:sand 4',
|
||||
recipe = {
|
||||
{'default:sandstone'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:sandstonebrick',
|
||||
recipe = {
|
||||
{'default:sandstone', 'default:sandstone'},
|
||||
{'default:sandstone', 'default:sandstone'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:clay',
|
||||
recipe = {
|
||||
{'default:clay_lump', 'default:clay_lump'},
|
||||
{'default:clay_lump', 'default:clay_lump'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:brick',
|
||||
recipe = {
|
||||
{'default:clay_brick', 'default:clay_brick'},
|
||||
{'default:clay_brick', 'default:clay_brick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:clay_brick 4',
|
||||
recipe = {
|
||||
{'default:brick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:paper',
|
||||
recipe = {
|
||||
{'default:papyrus', 'default:papyrus', 'default:papyrus'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:book',
|
||||
recipe = {
|
||||
{'default:paper'},
|
||||
{'default:paper'},
|
||||
{'default:paper'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:bookshelf',
|
||||
recipe = {
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
{'default:book', 'default:book', 'default:book'},
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:ladder',
|
||||
recipe = {
|
||||
{'group:stick', '', 'group:stick'},
|
||||
{'group:stick', 'group:stick', 'group:stick'},
|
||||
{'group:stick', '', 'group:stick'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:mese',
|
||||
recipe = {
|
||||
{'default:mese_crystal', 'default:mese_crystal', 'default:mese_crystal'},
|
||||
{'default:mese_crystal', 'default:mese_crystal', 'default:mese_crystal'},
|
||||
{'default:mese_crystal', 'default:mese_crystal', 'default:mese_crystal'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:mese_crystal 9',
|
||||
recipe = {
|
||||
{'default:mese'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:mese_crystal_fragment 9',
|
||||
recipe = {
|
||||
{'default:mese_crystal'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:obsidian_shard 9',
|
||||
recipe = {
|
||||
{'default:obsidian'}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:obsidian',
|
||||
recipe = {
|
||||
{'default:obsidian_shard', 'default:obsidian_shard', 'default:obsidian_shard'},
|
||||
{'default:obsidian_shard', 'default:obsidian_shard', 'default:obsidian_shard'},
|
||||
{'default:obsidian_shard', 'default:obsidian_shard', 'default:obsidian_shard'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:stonebrick',
|
||||
recipe = {
|
||||
{'default:stone', 'default:stone'},
|
||||
{'default:stone', 'default:stone'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:desert_stonebrick',
|
||||
recipe = {
|
||||
{'default:desert_stone', 'default:desert_stone'},
|
||||
{'default:desert_stone', 'default:desert_stone'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:snowblock',
|
||||
recipe = {
|
||||
{'default:snow', 'default:snow', 'default:snow'},
|
||||
{'default:snow', 'default:snow', 'default:snow'},
|
||||
{'default:snow', 'default:snow', 'default:snow'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'default:snow 9',
|
||||
recipe = {
|
||||
{'default:snowblock'},
|
||||
}
|
||||
})
|
||||
|
||||
--
|
||||
-- Crafting (tool repair)
|
||||
--
|
||||
minetest.register_craft({
|
||||
type = "toolrepair",
|
||||
additional_wear = -0.02,
|
||||
})
|
||||
|
||||
--
|
||||
-- Cooking recipes
|
||||
--
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:glass",
|
||||
recipe = "group:sand",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:obsidian_glass",
|
||||
recipe = "default:obsidian_shard",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:stone",
|
||||
recipe = "default:cobble",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:steel_ingot",
|
||||
recipe = "default:iron_lump",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:copper_ingot",
|
||||
recipe = "default:copper_lump",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:gold_ingot",
|
||||
recipe = "default:gold_lump",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:clay_brick",
|
||||
recipe = "default:clay_lump",
|
||||
})
|
||||
|
||||
--
|
||||
-- Fuels
|
||||
--
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "group:tree",
|
||||
burntime = 30,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:junglegrass",
|
||||
burntime = 2,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "group:leaves",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:cactus",
|
||||
burntime = 15,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:papyrus",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:bookshelf",
|
||||
burntime = 30,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:fence_wood",
|
||||
burntime = 15,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:ladder",
|
||||
burntime = 5,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "group:wood",
|
||||
burntime = 7,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:lava_source",
|
||||
burntime = 60,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:torch",
|
||||
burntime = 4,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:sign_wall",
|
||||
burntime = 10,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:chest",
|
||||
burntime = 30,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:chest_locked",
|
||||
burntime = 30,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:nyancat",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:nyancat_rainbow",
|
||||
burntime = 1,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:sapling",
|
||||
burntime = 10,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:apple",
|
||||
burntime = 3,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:coal_lump",
|
||||
burntime = 40,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:coalblock",
|
||||
burntime = 370,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:junglesapling",
|
||||
burntime = 10,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:grass_1",
|
||||
burntime = 2,
|
||||
})
|
|
@ -0,0 +1,102 @@
|
|||
-- mods/default/craftitems.lua
|
||||
|
||||
minetest.register_craftitem("default:stick", {
|
||||
description = "Stick",
|
||||
inventory_image = "default_stick.png",
|
||||
groups = {stick=1,skill=SKILL_WOOD},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:paper", {
|
||||
description = "Paper",
|
||||
inventory_image = "default_paper.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:book", {
|
||||
description = "Book",
|
||||
inventory_image = "default_book.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:coal_lump", {
|
||||
description = "Coal Lump",
|
||||
inventory_image = "default_coal_lump.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:iron_lump", {
|
||||
description = "Iron Lump",
|
||||
inventory_image = "default_iron_lump.png",
|
||||
groups = {skill=SKILL_IRON},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:copper_lump", {
|
||||
description = "Copper Lump",
|
||||
inventory_image = "default_copper_lump.png",
|
||||
groups = {skill=SKILL_COPPER},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:mese_crystal", {
|
||||
description = "Mese Crystal",
|
||||
inventory_image = "default_mese_crystal.png",
|
||||
groups = {skill=SKILL_MESE},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:gold_lump", {
|
||||
description = "Gold Lump",
|
||||
inventory_image = "default_gold_lump.png",
|
||||
groups = {skill=SKILL_GOLD},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:diamond", {
|
||||
description = "Diamond",
|
||||
inventory_image = "default_diamond.png",
|
||||
groups = {skill=SKILL_DIAMOND},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:clay_lump", {
|
||||
description = "Clay Lump",
|
||||
inventory_image = "default_clay_lump.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:steel_ingot", {
|
||||
description = "Steel Ingot",
|
||||
inventory_image = "default_steel_ingot.png",
|
||||
groups = {skill=SKILL_IRON},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:copper_ingot", {
|
||||
description = "Copper Ingot",
|
||||
inventory_image = "default_copper_ingot.png",
|
||||
groups = {skill=SKILL_COPPER},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:bronze_ingot", {
|
||||
description = "Bronze Ingot",
|
||||
inventory_image = "default_bronze_ingot.png",
|
||||
groups = {skill=SKILL_BRONZE},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:gold_ingot", {
|
||||
description = "Gold Ingot",
|
||||
inventory_image = "default_gold_ingot.png",
|
||||
groups = {skill=SKILL_GOLD},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:mese_crystal_fragment", {
|
||||
description = "Mese Crystal Fragment",
|
||||
inventory_image = "default_mese_crystal_fragment.png",
|
||||
groups = {skill=SKILL_MESE},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:clay_brick", {
|
||||
description = "Clay Brick",
|
||||
inventory_image = "default_clay_brick.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:scorched_stuff", {
|
||||
description = "Scorched Stuff",
|
||||
inventory_image = "default_scorched_stuff.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("default:obsidian_shard", {
|
||||
description = "Obsidian Shard",
|
||||
inventory_image = "default_obsidian_shard.png",
|
||||
})
|
|
@ -0,0 +1 @@
|
|||
skills?
|
|
@ -0,0 +1,436 @@
|
|||
-- mods/default/functions.lua
|
||||
|
||||
--
|
||||
-- Sounds
|
||||
--
|
||||
|
||||
function default.node_sound_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name="", gain=1.0}
|
||||
table.dug = table.dug or
|
||||
{name="default_dug_node", gain=0.25}
|
||||
table.place = table.place or
|
||||
{name="default_place_node_hard", gain=1.0}
|
||||
return table
|
||||
end
|
||||
|
||||
function default.node_sound_stone_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name="default_hard_footstep", gain=0.5}
|
||||
table.dug = table.dug or
|
||||
{name="default_hard_footstep", gain=1.0}
|
||||
default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
function default.node_sound_dirt_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name="default_dirt_footstep", gain=1.0}
|
||||
table.dug = table.dug or
|
||||
{name="default_dirt_footstep", gain=1.5}
|
||||
table.place = table.place or
|
||||
{name="default_place_node", gain=1.0}
|
||||
default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
function default.node_sound_sand_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name="default_sand_footstep", gain=0.5}
|
||||
table.dug = table.dug or
|
||||
{name="default_sand_footstep", gain=1.0}
|
||||
table.place = table.place or
|
||||
{name="default_place_node", gain=1.0}
|
||||
default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
function default.node_sound_wood_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name="default_wood_footstep", gain=0.5}
|
||||
table.dug = table.dug or
|
||||
{name="default_wood_footstep", gain=1.0}
|
||||
default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
function default.node_sound_leaves_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name="default_grass_footstep", gain=0.35}
|
||||
table.dug = table.dug or
|
||||
{name="default_grass_footstep", gain=0.85}
|
||||
table.dig = table.dig or
|
||||
{name="default_dig_crumbly", gain=0.4}
|
||||
table.place = table.place or
|
||||
{name="default_place_node", gain=1.0}
|
||||
default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
function default.node_sound_glass_defaults(table)
|
||||
table = table or {}
|
||||
table.footstep = table.footstep or
|
||||
{name="default_glass_footstep", gain=0.5}
|
||||
table.dug = table.dug or
|
||||
{name="default_break_glass", gain=1.0}
|
||||
default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
--
|
||||
-- Legacy
|
||||
--
|
||||
|
||||
function default.spawn_falling_node(p, nodename)
|
||||
spawn_falling_node(p, nodename)
|
||||
end
|
||||
|
||||
-- Horrible crap to support old code
|
||||
-- Don't use this and never do what this does, it's completely wrong!
|
||||
-- (More specifically, the client and the C++ code doesn't get the group)
|
||||
function default.register_falling_node(nodename, texture)
|
||||
minetest.log("error", debug.traceback())
|
||||
minetest.log('error', "WARNING: default.register_falling_node is deprecated")
|
||||
if minetest.registered_nodes[nodename] then
|
||||
minetest.registered_nodes[nodename].groups.falling_node = 1
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Global callbacks
|
||||
--
|
||||
|
||||
-- Global environment step function
|
||||
function on_step(dtime)
|
||||
-- print("on_step")
|
||||
end
|
||||
minetest.register_globalstep(on_step)
|
||||
|
||||
function on_placenode(p, node)
|
||||
--print("on_placenode")
|
||||
end
|
||||
minetest.register_on_placenode(on_placenode)
|
||||
|
||||
function on_dignode(pos, node, digger)
|
||||
--print("on_dignode")
|
||||
-- going to try to consolidate all on_dignode calls here so there is only one function call
|
||||
|
||||
-- ON DIG NODE FOR MONEY MOD
|
||||
for k,v in pairs(money.convert_items) do
|
||||
if ( node.name == money.convert_items[k].dig_block ) then
|
||||
money.stats[k].running_dug = money.stats[k].running_dug + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- EXPERIENCE
|
||||
if minetest.registered_nodes[node.name]["skill"] ~= nil then
|
||||
default.drop_item(pos,"experience:1_exp")
|
||||
end
|
||||
|
||||
-- STAMINA
|
||||
if digger ~= nil and digger ~= "" then
|
||||
local name= digger:get_player_name()
|
||||
player_stamina[name] = player_stamina[name] - 0.1
|
||||
end
|
||||
|
||||
end
|
||||
minetest.register_on_dignode(on_dignode)
|
||||
|
||||
function on_punchnode(p, node)
|
||||
end
|
||||
minetest.register_on_punchnode(on_punchnode)
|
||||
|
||||
|
||||
--
|
||||
-- Grow trees
|
||||
--
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:sapling"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local is_soil = minetest.get_item_group(nu, "soil")
|
||||
if is_soil == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.log("action", "A sapling grows into a tree at "..minetest.pos_to_string(pos))
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16})
|
||||
local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
|
||||
local data = vm:get_data()
|
||||
default.grow_tree(data, a, pos, math.random(1, 4) == 1, math.random(1,100000))
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
vm:update_map()
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:junglesapling"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local is_soil = minetest.get_item_group(nu, "soil")
|
||||
if is_soil == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.log("action", "A jungle sapling grows into a tree at "..minetest.pos_to_string(pos))
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y-1, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16})
|
||||
local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
|
||||
local data = vm:get_data()
|
||||
default.grow_jungletree(data, a, pos, math.random(1,100000))
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
vm:update_map()
|
||||
end
|
||||
})
|
||||
|
||||
--
|
||||
-- Lavacooling
|
||||
--
|
||||
|
||||
default.cool_lava_source = function(pos)
|
||||
minetest.set_node(pos, {name="default:obsidian"})
|
||||
minetest.sound_play("default_cool_lava", {pos = pos, gain = 0.25})
|
||||
end
|
||||
|
||||
default.cool_lava_flowing = function(pos)
|
||||
minetest.set_node(pos, {name="default:stone"})
|
||||
minetest.sound_play("default_cool_lava", {pos = pos, gain = 0.25})
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:lava_flowing"},
|
||||
neighbors = {"group:water"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
default.cool_lava_flowing(pos, node, active_object_count, active_object_count_wider)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:lava_source"},
|
||||
neighbors = {"group:water"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
default.cool_lava_source(pos, node, active_object_count, active_object_count_wider)
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
-- Papyrus and cactus growing
|
||||
--
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:cactus"},
|
||||
neighbors = {"group:sand"},
|
||||
interval = 50,
|
||||
chance = 20,
|
||||
action = function(pos, node)
|
||||
pos.y = pos.y-1
|
||||
local name = minetest.get_node(pos).name
|
||||
if minetest.get_item_group(name, "sand") ~= 0 then
|
||||
pos.y = pos.y+1
|
||||
local height = 0
|
||||
while minetest.get_node(pos).name == "default:cactus" and height < 4 do
|
||||
height = height+1
|
||||
pos.y = pos.y+1
|
||||
end
|
||||
if height < 4 then
|
||||
if minetest.get_node(pos).name == "air" then
|
||||
minetest.set_node(pos, {name="default:cactus"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:papyrus"},
|
||||
neighbors = {"default:dirt", "default:dirt_with_grass"},
|
||||
interval = 50,
|
||||
chance = 20,
|
||||
action = function(pos, node)
|
||||
pos.y = pos.y-1
|
||||
local name = minetest.get_node(pos).name
|
||||
if name == "default:dirt" or name == "default:dirt_with_grass" then
|
||||
if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
|
||||
return
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
local height = 0
|
||||
while minetest.get_node(pos).name == "default:papyrus" and height < 4 do
|
||||
height = height+1
|
||||
pos.y = pos.y+1
|
||||
end
|
||||
if height < 4 then
|
||||
if minetest.get_node(pos).name == "air" then
|
||||
minetest.set_node(pos, {name="default:papyrus"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
-- Leafdecay
|
||||
--
|
||||
|
||||
-- To enable leaf decay for a node, add it to the "leafdecay" group.
|
||||
--
|
||||
-- The rating of the group determines how far from a node in the group "tree"
|
||||
-- the node can be without decaying.
|
||||
--
|
||||
-- If param2 of the node is ~= 0, the node will always be preserved. Thus, if
|
||||
-- the player places a node of that kind, you will want to set param2=1 or so.
|
||||
--
|
||||
-- If the node is in the leafdecay_drop group then the it will always be dropped
|
||||
-- as an item
|
||||
|
||||
default.leafdecay_trunk_cache = {}
|
||||
default.leafdecay_enable_cache = true
|
||||
-- Spread the load of finding trunks
|
||||
default.leafdecay_trunk_find_allow_accumulator = 0
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local finds_per_second = 5000
|
||||
default.leafdecay_trunk_find_allow_accumulator =
|
||||
math.floor(dtime * finds_per_second)
|
||||
end)
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:leafdecay"},
|
||||
neighbors = {"air", "group:liquid"},
|
||||
-- A low interval and a high inverse chance spreads the load
|
||||
interval = 2,
|
||||
chance = 5,
|
||||
|
||||
action = function(p0, node, _, _)
|
||||
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
|
||||
local do_preserve = false
|
||||
local d = minetest.registered_nodes[node.name].groups.leafdecay
|
||||
if not d or d == 0 then
|
||||
--print("not groups.leafdecay")
|
||||
return
|
||||
end
|
||||
local n0 = minetest.get_node(p0)
|
||||
if n0.param2 ~= 0 then
|
||||
--print("param2 ~= 0")
|
||||
return
|
||||
end
|
||||
local p0_hash = nil
|
||||
if default.leafdecay_enable_cache then
|
||||
p0_hash = minetest.hash_node_position(p0)
|
||||
local trunkp = default.leafdecay_trunk_cache[p0_hash]
|
||||
if trunkp then
|
||||
local n = minetest.get_node(trunkp)
|
||||
local reg = minetest.registered_nodes[n.name]
|
||||
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
||||
if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then
|
||||
--print("cached trunk still exists")
|
||||
return
|
||||
end
|
||||
--print("cached trunk is invalid")
|
||||
-- Cache is invalid
|
||||
table.remove(default.leafdecay_trunk_cache, p0_hash)
|
||||
end
|
||||
end
|
||||
if default.leafdecay_trunk_find_allow_accumulator <= 0 then
|
||||
return
|
||||
end
|
||||
default.leafdecay_trunk_find_allow_accumulator =
|
||||
default.leafdecay_trunk_find_allow_accumulator - 1
|
||||
-- Assume ignore is a trunk, to make the thing work at the border of the active area
|
||||
local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"})
|
||||
if p1 then
|
||||
do_preserve = true
|
||||
if default.leafdecay_enable_cache then
|
||||
--print("caching trunk")
|
||||
-- Cache the trunk
|
||||
default.leafdecay_trunk_cache[p0_hash] = p1
|
||||
end
|
||||
end
|
||||
if not do_preserve then
|
||||
-- Drop stuff other than the node itself
|
||||
itemstacks = minetest.get_node_drops(n0.name)
|
||||
for _, itemname in ipairs(itemstacks) do
|
||||
if minetest.get_item_group(n0.name, "leafdecay_drop") ~= 0 or
|
||||
itemname ~= n0.name then
|
||||
local p_drop = {
|
||||
x = p0.x - 0.5 + math.random(),
|
||||
y = p0.y - 0.5 + math.random(),
|
||||
z = p0.z - 0.5 + math.random(),
|
||||
}
|
||||
minetest.add_item(p_drop, itemname)
|
||||
end
|
||||
end
|
||||
-- Remove node
|
||||
minetest.remove_node(p0)
|
||||
nodeupdate(p0)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
function default.serialize_to_file(filename,t)
|
||||
local f = io.open(filename, "w")
|
||||
f:write(minetest.serialize(t))
|
||||
f:close()
|
||||
end
|
||||
|
||||
function default.deserialize_from_file(filename)
|
||||
local f = io.open(filename, "r")
|
||||
if f==nil then
|
||||
minetest.log("error","File "..filename.." not found, returning empty table")
|
||||
return {}
|
||||
end
|
||||
local t = f:read("*all")
|
||||
f:close()
|
||||
if t=="" or t==nil then
|
||||
minetest.log("error","File "..filename.." is blank, returning empty table")
|
||||
return {}
|
||||
end
|
||||
return minetest.deserialize(t)
|
||||
end
|
||||
|
||||
function default.dump_inv(pos,listname,inv)
|
||||
if inv == nil then
|
||||
local meta = minetest.get_meta(pos)
|
||||
inv = meta:get_inventory()
|
||||
end
|
||||
if inv:get_list(listname) ~= nil then
|
||||
for i,stack in ipairs(inv:get_list(listname)) do
|
||||
default.drop_item(pos,stack)
|
||||
stack:clear()
|
||||
inv:set_stack(listname, i, stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function default.drop_item(pos,itemstack)
|
||||
-- math.randomseed(os.time() + os.clock())
|
||||
local x = math.random(0, 15)/10 - 0.5
|
||||
local z = math.random(0, 15)/10 - 0.5
|
||||
--local y = math.random(0, 15)/10 - 2
|
||||
local np = pos
|
||||
np.x = np.x + x
|
||||
np.z = np.z + z
|
||||
np.y = np.y + .25
|
||||
local obj = minetest.add_item(np, itemstack)
|
||||
if obj then
|
||||
obj:get_luaentity().collect = true
|
||||
end
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
-- Minetest 0.4 mod: default
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
-- The API documentation in here was moved into doc/lua_api.txt
|
||||
|
||||
WATER_ALPHA = 160
|
||||
WATER_VISC = 1
|
||||
LAVA_VISC = 7
|
||||
LIGHT_MAX = 14
|
||||
|
||||
-- Definitions made by this mod that other mods can use too
|
||||
default = {}
|
||||
|
||||
-- Load files
|
||||
dofile(minetest.get_modpath("default").."/functions.lua")
|
||||
dofile(minetest.get_modpath("default").."/register_skills.lua")
|
||||
dofile(minetest.get_modpath("default").."/nodes.lua")
|
||||
dofile(minetest.get_modpath("default").."/tools.lua")
|
||||
dofile(minetest.get_modpath("default").."/craftitems.lua")
|
||||
dofile(minetest.get_modpath("default").."/crafting.lua")
|
||||
dofile(minetest.get_modpath("default").."/mapgen.lua")
|
||||
dofile(minetest.get_modpath("default").."/player.lua")
|
||||
dofile(minetest.get_modpath("default").."/trees.lua")
|
|
@ -0,0 +1,513 @@
|
|||
-- mods/default/mapgen.lua
|
||||
|
||||
--
|
||||
-- Aliases for map generator outputs
|
||||
--
|
||||
|
||||
minetest.register_alias("mapgen_stone", "default:stone")
|
||||
minetest.register_alias("mapgen_tree", "default:tree")
|
||||
minetest.register_alias("mapgen_leaves", "default:leaves")
|
||||
minetest.register_alias("mapgen_jungletree", "default:jungletree")
|
||||
minetest.register_alias("mapgen_jungleleaves", "default:jungleleaves")
|
||||
minetest.register_alias("mapgen_apple", "default:apple")
|
||||
minetest.register_alias("mapgen_water_source", "default:water_source")
|
||||
minetest.register_alias("mapgen_dirt", "default:dirt")
|
||||
minetest.register_alias("mapgen_sand", "default:sand")
|
||||
minetest.register_alias("mapgen_gravel", "default:gravel")
|
||||
minetest.register_alias("mapgen_clay", "default:clay")
|
||||
minetest.register_alias("mapgen_lava_source", "default:lava_source")
|
||||
minetest.register_alias("mapgen_cobble", "default:cobble")
|
||||
minetest.register_alias("mapgen_mossycobble", "default:mossycobble")
|
||||
minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass")
|
||||
minetest.register_alias("mapgen_junglegrass", "default:junglegrass")
|
||||
minetest.register_alias("mapgen_stone_with_coal", "default:stone_with_coal")
|
||||
minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
|
||||
minetest.register_alias("mapgen_mese", "default:mese")
|
||||
minetest.register_alias("mapgen_desert_sand", "default:desert_sand")
|
||||
minetest.register_alias("mapgen_desert_stone", "default:desert_stone")
|
||||
minetest.register_alias("mapgen_stair_cobble", "stairs:stair_cobble")
|
||||
|
||||
--
|
||||
-- Ore generation
|
||||
--
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_coal",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 8*8*8,
|
||||
clust_num_ores = 8,
|
||||
clust_size = 3,
|
||||
height_min = -31000,
|
||||
height_max = 64,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_coal",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 24*24*24,
|
||||
clust_num_ores = 27,
|
||||
clust_size = 6,
|
||||
height_min = -31000,
|
||||
height_max = 0,
|
||||
flags = "absheight",
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_iron",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 12*12*12,
|
||||
clust_num_ores = 3,
|
||||
clust_size = 2,
|
||||
height_min = -15,
|
||||
height_max = 2,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_iron",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 9*9*9,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
height_min = -63,
|
||||
height_max = -16,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_iron",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 7*7*7,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
height_min = -31000,
|
||||
height_max = -64,
|
||||
flags = "absheight",
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_iron",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 24*24*24,
|
||||
clust_num_ores = 27,
|
||||
clust_size = 6,
|
||||
height_min = -31000,
|
||||
height_max = -64,
|
||||
flags = "absheight",
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_mese",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 18*18*18,
|
||||
clust_num_ores = 3,
|
||||
clust_size = 2,
|
||||
height_min = -255,
|
||||
height_max = -64,
|
||||
flags = "absheight",
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_mese",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 14*14*14,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
height_min = -31000,
|
||||
height_max = -256,
|
||||
flags = "absheight",
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:mese",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 36*36*36,
|
||||
clust_num_ores = 3,
|
||||
clust_size = 2,
|
||||
height_min = -31000,
|
||||
height_max = -1024,
|
||||
flags = "absheight",
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_gold",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 15*15*15,
|
||||
clust_num_ores = 3,
|
||||
clust_size = 2,
|
||||
height_min = -255,
|
||||
height_max = -64,
|
||||
flags = "absheight",
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_gold",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 13*13*13,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
height_min = -31000,
|
||||
height_max = -256,
|
||||
flags = "absheight",
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_diamond",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 17*17*17,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
height_min = -255,
|
||||
height_max = -128,
|
||||
flags = "absheight",
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_diamond",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 15*15*15,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
height_min = -31000,
|
||||
height_max = -256,
|
||||
flags = "absheight",
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_copper",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 12*12*12,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
height_min = -63,
|
||||
height_max = -16,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_copper",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 9*9*9,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
height_min = -31000,
|
||||
height_max = -64,
|
||||
flags = "absheight",
|
||||
})
|
||||
|
||||
if minetest.setting_get("mg_name") == "indev" then
|
||||
-- Floatlands and high mountains springs
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:water_source",
|
||||
ore_param2 = 128,
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 40*40*40,
|
||||
clust_num_ores = 8,
|
||||
clust_size = 3,
|
||||
height_min = 100,
|
||||
height_max = 31000,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:lava_source",
|
||||
ore_param2 = 128,
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 50*50*50,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 2,
|
||||
height_min = 10000,
|
||||
height_max = 31000,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:sand",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 20*20*20,
|
||||
clust_num_ores = 5*5*3,
|
||||
clust_size = 5,
|
||||
height_min = 500,
|
||||
height_max = 31000,
|
||||
})
|
||||
|
||||
-- Underground springs
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:water_source",
|
||||
ore_param2 = 128,
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 25*25*25,
|
||||
clust_num_ores = 8,
|
||||
clust_size = 3,
|
||||
height_min = -10000,
|
||||
height_max = -10,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:lava_source",
|
||||
ore_param2 = 128,
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 35*35*35,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 2,
|
||||
height_min = -31000,
|
||||
height_max = -100,
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:clay",
|
||||
wherein = "default:sand",
|
||||
clust_scarcity = 15*15*15,
|
||||
clust_num_ores = 64,
|
||||
clust_size = 5,
|
||||
height_max = 0,
|
||||
height_min = -10,
|
||||
})
|
||||
|
||||
function default.generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
|
||||
minetest.log('action', "WARNING: default.generate_ore is deprecated")
|
||||
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
if chunk_size >= y_max - y_min + 1 then
|
||||
return
|
||||
end
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed)
|
||||
local num_chunks = math.floor(chunks_per_volume * volume)
|
||||
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
|
||||
--print("generate_ore num_chunks: "..dump(num_chunks))
|
||||
for i=1,num_chunks do
|
||||
local y0 = pr:next(y_min, y_max-chunk_size+1)
|
||||
if y0 >= height_min and y0 <= height_max then
|
||||
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
|
||||
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
for x1=0,chunk_size-1 do
|
||||
for y1=0,chunk_size-1 do
|
||||
for z1=0,chunk_size-1 do
|
||||
if pr:next(1,inverse_chance) == 1 then
|
||||
local x2 = x0+x1
|
||||
local y2 = y0+y1
|
||||
local z2 = z0+z1
|
||||
local p2 = {x=x2, y=y2, z=z2}
|
||||
if minetest.get_node(p2).name == wherein then
|
||||
minetest.set_node(p2, {name=name})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--print("generate_ore done")
|
||||
end
|
||||
|
||||
function default.make_papyrus(pos, size)
|
||||
for y=0,size-1 do
|
||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||
local nn = minetest.get_node(p).name
|
||||
if minetest.registered_nodes[nn] and
|
||||
minetest.registered_nodes[nn].buildable_to then
|
||||
minetest.set_node(p, {name="default:papyrus"})
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function default.make_cactus(pos, size)
|
||||
for y=0,size-1 do
|
||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||
local nn = minetest.get_node(p).name
|
||||
if minetest.registered_nodes[nn] and
|
||||
minetest.registered_nodes[nn].buildable_to then
|
||||
minetest.set_node(p, {name="default:cactus"})
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- facedir: 0/1/2/3 (head node facedir value)
|
||||
-- length: length of rainbow tail
|
||||
function default.make_nyancat(pos, facedir, length)
|
||||
local tailvec = {x=0, y=0, z=0}
|
||||
if facedir == 0 then
|
||||
tailvec.z = 1
|
||||
elseif facedir == 1 then
|
||||
tailvec.x = 1
|
||||
elseif facedir == 2 then
|
||||
tailvec.z = -1
|
||||
elseif facedir == 3 then
|
||||
tailvec.x = -1
|
||||
else
|
||||
--print("default.make_nyancat(): Invalid facedir: "+dump(facedir))
|
||||
facedir = 0
|
||||
tailvec.z = 1
|
||||
end
|
||||
local p = {x=pos.x, y=pos.y, z=pos.z}
|
||||
minetest.set_node(p, {name="default:nyancat", param2=facedir})
|
||||
for i=1,length do
|
||||
p.x = p.x + tailvec.x
|
||||
p.z = p.z + tailvec.z
|
||||
minetest.set_node(p, {name="default:nyancat_rainbow", param2=facedir})
|
||||
end
|
||||
end
|
||||
|
||||
function generate_nyancats(seed, minp, maxp)
|
||||
local height_min = -31000
|
||||
local height_max = -32
|
||||
if maxp.y < height_min or minp.y > height_max then
|
||||
return
|
||||
end
|
||||
local y_min = math.max(minp.y, height_min)
|
||||
local y_max = math.min(maxp.y, height_max)
|
||||
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
|
||||
local pr = PseudoRandom(seed + 9324342)
|
||||
local max_num_nyancats = math.floor(volume / (16*16*16))
|
||||
for i=1,max_num_nyancats do
|
||||
if pr:next(0, 1000) == 0 then
|
||||
local x0 = pr:next(minp.x, maxp.x)
|
||||
local y0 = pr:next(minp.y, maxp.y)
|
||||
local z0 = pr:next(minp.z, maxp.z)
|
||||
local p0 = {x=x0, y=y0, z=z0}
|
||||
default.make_nyancat(p0, pr:next(0,3), pr:next(3,15))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
if maxp.y >= 2 and minp.y <= 0 then
|
||||
-- Generate papyrus
|
||||
local perlin1 = minetest.get_perlin(354, 3, 0.7, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 8
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine papyrus amount from perlin noise
|
||||
local papyrus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 45 - 20)
|
||||
-- Find random positions for papyrus based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,papyrus_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
if minetest.get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
|
||||
minetest.find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then
|
||||
default.make_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate cactuses
|
||||
local perlin1 = minetest.get_perlin(230, 3, 0.6, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 16
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine cactus amount from perlin noise
|
||||
local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 6 - 3)
|
||||
-- Find random positions for cactus based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,cactus_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
-- Find ground level (0...15)
|
||||
local ground_y = nil
|
||||
for y=30,0,-1 do
|
||||
if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||
ground_y = y
|
||||
break
|
||||
end
|
||||
end
|
||||
-- If desert sand, make cactus
|
||||
if ground_y and minetest.get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
|
||||
default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate grass
|
||||
local perlin1 = minetest.get_perlin(329, 3, 0.6, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 16
|
||||
local divs = (maxp.x-minp.x)/divlen+1;
|
||||
for divx=0,divs-1 do
|
||||
for divz=0,divs-1 do
|
||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||
-- Determine grass amount from perlin noise
|
||||
local grass_amount = math.floor(perlin1:get2d({x=x0, y=z0}) ^ 3 * 9)
|
||||
-- Find random positions for grass based on this random
|
||||
local pr = PseudoRandom(seed+1)
|
||||
for i=0,grass_amount do
|
||||
local x = pr:next(x0, x1)
|
||||
local z = pr:next(z0, z1)
|
||||
-- Find ground level (0...15)
|
||||
local ground_y = nil
|
||||
for y=30,0,-1 do
|
||||
if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||
ground_y = y
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if ground_y then
|
||||
local p = {x=x,y=ground_y+1,z=z}
|
||||
local nn = minetest.get_node(p).name
|
||||
-- Check if the node can be replaced
|
||||
if minetest.registered_nodes[nn] and
|
||||
minetest.registered_nodes[nn].buildable_to then
|
||||
nn = minetest.get_node({x=x,y=ground_y,z=z}).name
|
||||
-- If desert sand, add dry shrub
|
||||
if nn == "default:desert_sand" then
|
||||
minetest.set_node(p,{name="default:dry_shrub"})
|
||||
|
||||
-- If dirt with grass, add grass
|
||||
elseif nn == "default:dirt_with_grass" then
|
||||
minetest.set_node(p,{name="default:grass_"..pr:next(1, 5)})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Generate nyan cats
|
||||
generate_nyancats(seed, minp, maxp)
|
||||
end)
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
|
@ -0,0 +1,209 @@
|
|||
-- Minetest 0.4 mod: player
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
--[[
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
default.player_register_model(name, def)
|
||||
^ Register a new model to be used by players.
|
||||
^ <name> is the model filename such as "character.x", "foo.b3d", etc.
|
||||
^ See Model Definition below for format of <def>.
|
||||
|
||||
default.registered_player_models[name]
|
||||
^ See Model Definition below for format.
|
||||
|
||||
default.player_set_model(player, model_name)
|
||||
^ <player> is a PlayerRef.
|
||||
^ <model_name> is a model registered with player_register_model.
|
||||
|
||||
default.player_set_animation(player, anim_name [, speed])
|
||||
^ <player> is a PlayerRef.
|
||||
^ <anim_name> is the name of the animation.
|
||||
^ <speed> is in frames per second. If nil, default from the model is used
|
||||
|
||||
default.player_set_textures(player, textures)
|
||||
^ <player> is a PlayerRef.
|
||||
^ <textures> is an array of textures
|
||||
^ If <textures> is nil, the default textures from the model def are used
|
||||
|
||||
default.player_get_animation(player)
|
||||
^ <player> is a PlayerRef.
|
||||
^ Returns a table containing fields "model", "textures" and "animation".
|
||||
^ Any of the fields of the returned table may be nil.
|
||||
|
||||
Model Definition
|
||||
----------------
|
||||
|
||||
model_def = {
|
||||
animation_speed = 30, -- Default animation speed, in FPS.
|
||||
textures = {"character.png", }, -- Default array of textures.
|
||||
visual_size = {x=1, y=1,}, -- Used to scale the model.
|
||||
animations = {
|
||||
-- <anim_name> = { x=<start_frame>, y=<end_frame>, },
|
||||
foo = { x= 0, y=19, },
|
||||
bar = { x=20, y=39, },
|
||||
-- ...
|
||||
},
|
||||
}
|
||||
|
||||
]]
|
||||
|
||||
-- Player animation blending
|
||||
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
|
||||
local animation_blend = 0
|
||||
|
||||
default.registered_player_models = { }
|
||||
|
||||
-- Local for speed.
|
||||
local models = default.registered_player_models
|
||||
|
||||
function default.player_register_model(name, def)
|
||||
models[name] = def
|
||||
end
|
||||
|
||||
-- Default player appearance
|
||||
default.player_register_model("character.x", {
|
||||
animation_speed = 30,
|
||||
textures = {"character.png", },
|
||||
animations = {
|
||||
-- Standard animations.
|
||||
stand = { x= 0, y= 79, },
|
||||
lay = { x=162, y=166, },
|
||||
walk = { x=168, y=187, },
|
||||
mine = { x=189, y=198, },
|
||||
walk_mine = { x=200, y=219, },
|
||||
-- Extra animations (not currently used by the game).
|
||||
sit = { x= 81, y=160, },
|
||||
},
|
||||
})
|
||||
|
||||
-- Player stats and animations
|
||||
local player_model = {}
|
||||
local player_textures = {}
|
||||
local player_anim = {}
|
||||
local player_sneak = {}
|
||||
|
||||
function default.player_get_animation(player)
|
||||
local name = player:get_player_name()
|
||||
return {
|
||||
model = player_model[name],
|
||||
textures = player_textures[name],
|
||||
animation = player_anim[name],
|
||||
}
|
||||
end
|
||||
|
||||
-- Called when a player's appearance needs to be updated
|
||||
function default.player_set_model(player, model_name)
|
||||
local name = player:get_player_name()
|
||||
local model = models[model_name]
|
||||
if model then
|
||||
if player_model[name] == model_name then
|
||||
return
|
||||
end
|
||||
player:set_properties({
|
||||
mesh = model_name,
|
||||
textures = player_textures[name] or model.textures,
|
||||
visual = "mesh",
|
||||
visual_size = model.visual_size or {x=1, y=1},
|
||||
})
|
||||
default.player_set_animation(player, "stand")
|
||||
else
|
||||
player:set_properties({
|
||||
textures = { "player.png", "player_back.png", },
|
||||
visual = "upright_sprite",
|
||||
})
|
||||
end
|
||||
player_model[name] = model_name
|
||||
end
|
||||
|
||||
function default.player_set_textures(player, textures)
|
||||
local name = player:get_player_name()
|
||||
player_textures[name] = textures
|
||||
player:set_properties({textures = textures,})
|
||||
end
|
||||
|
||||
function default.player_set_animation(player, anim_name, speed)
|
||||
local name = player:get_player_name()
|
||||
if player_anim[name] == anim_name then
|
||||
return
|
||||
end
|
||||
local model = player_model[name] and models[player_model[name]]
|
||||
if not (model and model.animations[anim_name]) then
|
||||
return
|
||||
end
|
||||
local anim = model.animations[anim_name]
|
||||
player_anim[name] = anim_name
|
||||
player:set_animation(anim, speed or model.animation_speed, animation_blend)
|
||||
end
|
||||
|
||||
-- Update appearance when the player joins
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
default.player_set_model(player, "character.x")
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
player_model[name] = nil
|
||||
player_anim[name] = nil
|
||||
player_textures[name] = nil
|
||||
end)
|
||||
|
||||
-- Localize for better performance.
|
||||
local player_set_animation = default.player_set_animation
|
||||
|
||||
-- Check each player and apply animations
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
local model_name = player_model[name]
|
||||
local model = model_name and models[model_name]
|
||||
if model then
|
||||
local controls = player:get_player_control()
|
||||
local walking = false
|
||||
local animation_speed_mod = model.animation_speed or 30
|
||||
|
||||
-- Determine if the player is walking
|
||||
if controls.up or controls.down or controls.left or controls.right then
|
||||
walking = true
|
||||
end
|
||||
|
||||
-- Determine if the player is sneaking, and reduce animation speed if so
|
||||
if controls.sneak then
|
||||
animation_speed_mod = animation_speed_mod / 2
|
||||
end
|
||||
|
||||
-- Apply animations based on what the player is doing
|
||||
if player:get_hp() == 0 then
|
||||
player_set_animation(player, "lay")
|
||||
elseif walking then
|
||||
if player_anim[name] == "lay" or player_anim[name] == "sit" then
|
||||
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
if player_sleephuds[name] ~= nil then
|
||||
player:hud_remove(player_sleephuds[name])
|
||||
player_sleephuds[name] = nil
|
||||
end
|
||||
end
|
||||
if player_sneak[name] ~= controls.sneak then
|
||||
player_anim[name] = nil
|
||||
player_sneak[name] = controls.sneak
|
||||
end
|
||||
if controls.LMB then
|
||||
player_set_animation(player, "walk_mine", animation_speed_mod)
|
||||
else
|
||||
player_set_animation(player, "walk", animation_speed_mod)
|
||||
end
|
||||
elseif controls.LMB then
|
||||
if player_anim[name] == "lay" or player_anim[name] == "sit" then
|
||||
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
end
|
||||
player_set_animation(player, "mine")
|
||||
else
|
||||
if player_anim[name] ~= "lay" and player_anim[name] ~= "sit" then
|
||||
player_set_animation(player, "stand", animation_speed_mod)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
|
@ -0,0 +1,32 @@
|
|||
-- REGISTER SKILLS
|
||||
|
||||
|
||||
-- CONSTANT IDs
|
||||
SKILL_WOOD = 1
|
||||
SKILL_STONE = 2
|
||||
SKILL_IRON = 4
|
||||
SKILL_STEEL = 4
|
||||
SKILL_COPPER = 8
|
||||
SKILL_DIAMOND = 16
|
||||
SKILL_MESE = 32
|
||||
SKILL_GOLD = 64
|
||||
|
||||
SKILL_SMELTING= 128
|
||||
SKILL_CRAFTING= 256
|
||||
SKILL_ARROW=512
|
||||
SKILL_MAGIC=1024
|
||||
|
||||
-- REGISTER THE SKILLS
|
||||
skills.register_skill(SKILL_WOOD, { desc = 'Wood', max_level = 10, level_exp = 15 })
|
||||
skills.register_skill(SKILL_STONE, { desc = 'Stone', max_level = 10, level_exp = 15 })
|
||||
skills.register_skill(SKILL_IRON, { desc = 'Iron/Steel', max_level = 25, level_exp = 20 })
|
||||
skills.register_skill(SKILL_COPPER, { desc = 'Copper', max_level = 25, level_exp = 20 })
|
||||
skills.register_skill(SKILL_DIAMOND, { desc = 'Diamond', max_level = 40, level_exp = 15 })
|
||||
skills.register_skill(SKILL_MESE, { desc = 'Mese', max_level = 40, level_exp = 15 })
|
||||
skills.register_skill(SKILL_GOLD, { desc = 'Gold', max_level = 15, level_exp = 20 })
|
||||
|
||||
skills.register_skill(SKILL_SMELTING, { desc = 'Smelting', max_level = 50, level_exp = 10 })
|
||||
skills.register_skill(SKILL_CRAFTING, { desc = 'Crafting', max_level = 50, level_exp = 10 })
|
||||
|
||||
skills.register_skill(SKILL_ARROW, { desc = 'Bow and Arrow', max_level=10, level_exp = 25})
|
||||
skills.register_skill(SKILL_MAGIC, { desc = 'Magic', max_level=15, level_exp = 25})
|