Initial Commit

master
Rubenwardy 2013-08-16 17:05:56 +01:00
commit 9b57579fb9
459 changed files with 17424 additions and 0 deletions

22
.gitattributes vendored Normal file
View File

@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

215
.gitignore vendored Normal file
View File

@ -0,0 +1,215 @@
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg

90
README.md Normal file
View File

@ -0,0 +1,90 @@
Capture The Flag
================
This is a highly customisable game for PvP servers.
All settings and features can be modified by editing the settings in this game's configuration.
What is this game for?
----------------------
This game can be used for many PvP purposes.
* Traditional capture the flag.
* Country wars - players can make cities and defend them.
* Obstactle courses - players can make their bases hard to get to with traps.
License
-------
This mod was made by Andrew "rubenwardy" Ward.
License: CC-BY-SA 3.0 UNPORTED
http://creativecommons.org/licenses/by-sa/3.0/
Teams
=====
Players are part of teams. They can either be allocated to teams, or can be invited. Each team is like a separate country; teams have bases and can declare war on each other. Teams can only build on their own territory and unclaimed territory.
Expanding territory
-------------------
If the multiple_flags setting is set to true, players can add more flags to protect areas and claim land for cities.
(coming soon) By default, only the team captain can place flags, but you can make anyone in the team able to place flags by setting the captian_place_flag_only to false.
Allocation
----------
(coming soon - the only current way to join a team is /join team_name)
Players are allocated to teams depending on the allocate_mode setting
* cycle - players are added in a cycle motion to each team (one to team 1, one to team 2, etc)
* lowest - players are added to the team with the lowest number of players
* nil - players have to be invited
Defenses
========
Turrets
-------
Turrets automatically fire at enemy players and vechiles.
* The owner of the current area is the owner of the turret.
* If an area is unclaimed, the placer is the owner.
Mines and traps
---------------
Mines and traps can be placed in the game as defenses.
* Mine - blows up if ANYONE steps on it
* Cage trap - Locks a player in indestructible glass
* Lava trap - Locks a player in a foundian of lava
Fire arms
---------
The fire arms mod is installed
Commands
========
Admin only
----------
Uses priv "team"
* /ateam <name> - add a team called <name>.
* /team_owner <name> - make a player the mod or not off the team (toggle)
* (coming soon) /join <name> <team> - add player <name> to team <team>.
* (coming soon) /lock <team> - stop any players joining team <team>
* (coming soon) /unlock <team> - allow players to join team <team>
Players
-------
* /team - view team panel
* /list_teams - list all teams and their statistics
* /join <team> - join the team <team>

1
game.conf Normal file
View File

@ -0,0 +1 @@
name = Capture the flag

BIN
menu/header.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

BIN
menu/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

2
minetest.conf Normal file
View File

@ -0,0 +1,2 @@
# Chatplus settings
chatplus_distance = 0 #(0=off)

17
mods/bones/README.txt Normal file
View File

@ -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_

1
mods/bones/depends.txt Normal file
View File

@ -0,0 +1 @@
default

131
mods/bones/init.lua Normal file
View File

@ -0,0 +1,131 @@
-- Minetest 0.4 mod: bones
-- See README.txt for licensing and other information.
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
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},
}),
can_dig = function(pos, player)
local inv = minetest.get_meta(pos):get_inventory()
return is_owner(pos, player:get_player_name()) and inv:is_empty("main")
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()) 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)
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
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", "")
else
return true
end
end,
})
minetest.register_on_dieplayer(function(player)
if minetest.setting_getbool("creative_mode") then
return
end
local pos = player:getpos()
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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

26
mods/bucket/README.txt Normal file
View File

@ -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>

2
mods/bucket/depends.txt Normal file
View File

@ -0,0 +1,2 @@
default

144
mods/bucket/init.lua Normal file
View File

@ -0,0 +1,144 @@
-- 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 = {}
-- 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
-- Call on_rightclick if the pointed node defines it
if user and not user:get_player_control().sneak then
local n = minetest.get_node(pointed_thing.under)
local nn = n.name
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then
return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, n, user, itemstack) or itemstack
end
end
local place_liquid = function(pos, node, source, flowing, fullness)
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 node = minetest.get_node(pointed_thing.under)
local fullness = tonumber(itemstack:get_metadata())
if not fullness then fullness = LIQUID_MAX end
if minetest.registered_nodes[node.name].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(pointed_thing.above)
if 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
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"}},
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

View File

@ -0,0 +1,173 @@
cf.area = {}
-- add a flag to a team
function cf.area.add_flag(team,pos)
if not team or team == "" then
return
end
if not cf.team(team).flags then
cf.team(team).flags = {}
end
pos.team = team
table.insert(cf.team(team).flags,pos)
cf.save()
end
-- get a flag from a team
function cf.area.get_flag(pos)
if not pos then
return
end
local result = nil
for _, team in pairs(cf.teams) do
for i = 1, #team.flags do
if (
team.flags[i].x == pos.x and
team.flags[i].y == pos.y and
team.flags[i].z == pos.z
) then
if result then
minetest.chat_send_all("[CTF WARNING] Multiple teams have same flag. please report this to the server operator / admin")
print("CTF WARNING DATA")
print("Multiple teams have same flag. See debug log for details")
print("----------------")
print(dump(result))
print(dump(team.flags[i]))
print("----------------")
else
result = {pos=team.flags[i],team=team.data.name}
end
end
end
end
return result
end
-- delete a flag from a team
function cf.area.delete_flag(team,pos)
if not team or team == "" then
return
end
print(dump(cf.team(team).flags))
for i = 1, #cf.team(team).flags do
if (
cf.team(team).flags[i].x == pos.x and
cf.team(team).flags[i].y == pos.y and
cf.team(team).flags[i].z == pos.z
) then
table.remove(cf.team(team).flags,i)
return
end
end
end
-- Gets the nearest flag in a 25 metre radius block
function cf.area.nearest_flag(pos)
if not pos then
print ("No position provided to nearest_flag()")
return nil
end
print("cf.settings.flag_protect_distance is "..dump(cf.settings.flag_protect_distance))
local nodes = minetest.env:find_nodes_in_area(
{x=pos.x-cf.settings.flag_protect_distance,y=pos.y-cf.settings.flag_protect_distance,z=pos.z-cf.settings.flag_protect_distance},
{x=pos.x+cf.settings.flag_protect_distance,y=pos.y+cf.settings.flag_protect_distance,z=pos.z+cf.settings.flag_protect_distance},
{"group:is_flag"}
)
if nodes then
local closest = nil
local _dis = 1000
for a=1, #nodes do
if v3.distance(pos, nodes[a]) < _dis then
closest = nodes[a]
_dis = v3.distance(pos, nodes[a])
end
end
return closest
end
return nil
end
-- gets the name of the owner of that location
function cf.area.get_area(pos)
local closest = cf.area.nearest_flag(pos)
if not closest then
return false
end
local meta = minetest.env:get_meta(closest)
if not meta then
return false
end
return meta:get_string("team")
end
-- updates the spawn position for a team
function cf.area.get_spawn(team)
cf.area.asset_flags(team)
if team and cf.teams and cf.team(team) then
if cf.team(team).spawn and minetest.env:get_node(cf.team(team).spawn).name == "capturetheflag:flag" then
-- Get meta data
local meta = minetest.env:get_meta(cf.team(team).spawn)
local _team = nil
if meta then
_team = meta:get_string("team")
end
-- Check to see if spawn is already defined
if team == _team then
return true
end
end
-- Get new spawn
if #cf.team(team).flags > 0 then
cf.team(team).spawn = cf.team(team).flags[1]
return true
end
end
return false
end
function cf.area.asset_flags(team)
if not team or not cf.team(team) then
return false
end
print("Checking the flags of "..team)
local tmp = cf.team(team).flags
local new = {}
for i=1,#tmp do
if tmp[i] and minetest.env:get_node(tmp[i]) and minetest.env:get_node(tmp[i]).name == "capturetheflag:flag" then
-- Get meta data
local meta = minetest.env:get_meta(tmp[i])
local _team = nil
if meta then
_team = meta:get_string("team")
end
-- Check to see if spawn is already defined
if team == _team then
table.insert(new,tmp[i])
else
print(_team.." is not "..team.." at "..dump(tmp[i]))
end
end
end
cf.team(team).flags = new
end

154
mods/capturetheflag/cli.lua Normal file
View File

@ -0,0 +1,154 @@
-- CLI stuff
minetest.register_privilege("team",{
description = "Team manager",
})
minetest.register_chatcommand("join", {
params = "team name",
description = "Add to team",
func = function(name, param)
local player = cf.player(name)
if not player then
player = {name=name}
end
if cf.add_user(param,player) == true then
minetest.chat_send_all(name.." has joined team "..param)
end
end,
})
minetest.register_chatcommand("list_teams", {
params = "",
description = "List all avaliable teams",
func = function(name, param)
minetest.chat_send_player(name, "Teams:")
for k,v in pairs(cf.teams) do
if v and v.players then
local numItems = 0
for k,v in pairs(v.players) do
numItems = numItems + 1
end
local numItems2 = 0
for k,v in pairs(v.flags) do
numItems2 = numItems2 + 1
end
minetest.chat_send_player(name, ">> "..k.." ("..numItems2.." flags, "..numItems.." players)")
end
end
end,
})
minetest.register_chatcommand("ateam", {
params = "team name",
description = "Create a team",
privs = {team=true},
func = function(name, param)
if string.match(param,"([%a%b_]-)") and cf.team({name=param,add_team=true}) then
minetest.chat_send_player(name, "Added team "..param)
else
minetest.chat_send_player(name, "Error adding team "..param)
end
end,
})
minetest.register_chatcommand("ctf", {
description = "Do admin debug stuff",
privs = {team=true},
func = function(name, param)
cf.clean_flags()
cf.clean_player_lists()
end,
})
minetest.register_chatcommand("reload_ctf", {
description = "reload the ctf main frame and get settings",
privs = {team=true},
func = function(name, param)
cf.save()
cf.init()
end,
})
minetest.register_chatcommand("team_owner", {
params = "player name",
description = "Create a team",
privs = {team=true},
func = function(name, param)
if cf and cf.players and cf.player(param) and cf.player(param).team and cf.team(cf.player(param).team) then
if cf.player(param).auth == true then
cf.player(param).auth = false
minetest.chat_send_player(name, param.." was downgraded from team admin status")
else
cf.player(param).auth = true
minetest.chat_send_player(name, param.." was upgraded to an admin of "..cf.player(name).team)
end
cf.save()
else
minetest.chat_send_player(name, "Player "..param.." does not exist")
end
end,
})
minetest.register_chatcommand("all", {
params = "msg",
description = "Send a message on the global channel",
func = function(name, param)
if not cf.settings.global_channel then
return
end
if cf.player(name) and cf.player(name).team then
minetest.chat_send_all(cf.player(name).team.." <"..name.."> "..param)
else
minetest.chat_send_all("GLOBAL <"..name.."> "..param)
end
end,
})
minetest.register_chatcommand("post", {
params = "message",
description = "Post a message on your team's message board",
func = function(name, param)
if cf and cf.players and cf.players[name] and cf.players[name].team and cf.teams[cf.players[name].team] then
if not cf.player(name).auth then
minetest.chat_send_player(name, "You do not own that team")
end
if not cf.teams[cf.players[name].team].log then
cf.teams[cf.players[name].team].log = {}
end
table.insert(cf.teams[cf.players[name].team].log,{msg=param})
minetest.chat_send_player(name, "Posted: "..param)
else
minetest.chat_send_player(name, "Could not post message")
end
end,
})
-- Chat plus stuff
if chatplus then
chatplus.register_handler(function(from,to,msg)
local fromp = cf.player(from)
local top = cf.player(to)
if not fromp then
if not cf.settings.global_channel then
minetest.chat_send_player(from,"You are not yet part of a team, so you have no mates to send to",false)
else
minetest.chat_send_player(to,"GLOBAL <"..from.."> "..msg,false)
end
return false
end
if not top then
return false
end
return (fromp.team == top.team)
end)
end

View File

@ -0,0 +1 @@
chatplus?

View File

@ -0,0 +1,249 @@
cf.flag_func = {
on_punch_top = function(pos, node, puncher)
pos.y=pos.y-1
cf.flag_func.on_punch(pos,node,puncher)
end,
on_rightclick_top = function(pos, node, clicker)
pos.y=pos.y-1
cf.gui.flag_board(clicker:get_player_name(),pos)
end,
on_rightclick = function(pos, node, clicker)
cf.gui.flag_board(clicker:get_player_name(),pos)
end,
on_punch = function(pos, node, puncher)
local player = puncher:get_player_name()
if not puncher or not player then
return
end
local meta = minetest.env:get_meta(pos)
if not meta then
return
end
local team = meta:get_string("team")
if not team then
return
end
if meta and cf.players and cf.team(team) and cf.player(player) and cf.player(player).team then
if cf.player(player).team ~= team then
local diplo = cf.diplo.get(team,cf.player(player).team)
if not diplo then
diplo = cf.settings.default_diplo_state
end
if diplo ~= "war" then
minetest.chat_send_player(player,"You are at peace with this team!")
return
end
local flag_name = meta:get_string("flag_name")
if flag_name and flag_name~="" then
minetest.chat_send_all(flag_name.." has been taken from "..team.." by "..cf.player(player).team.."!")
cf.post(team,{msg=flag_name.." has been captured by "..cf.player(player).team,icon="flag_red"})
cf.post(cf.player(player).team,{msg=player.." captured '"..flag_name.."' from "..team,icon="flag_green"})
else
minetest.chat_send_all(team.."'s flag at ("..pos.x..","..pos.z..") has been captured by "..cf.player(player).team)
cf.post(team,{msg="The flag at ("..pos.x..","..pos.z..") has been captured by "..cf.player(player).team,icon="flag_red"})
cf.post(cf.player(player).team,{msg=player.." captured flag ("..pos.x..","..pos.z..") from "..team,icon="flag_green"})
end
cf.team(team).spawn = nil
if cf.settings.multiple_flags == true then
meta:set_string("team",cf.player(player).team)
meta:set_string("infotext", meta:get_string("team").."'s flag")
cf.area.delete_flag(team,pos)
cf.area.add_flag(cf.player(player).team,pos)
else
minetest.env:set_node(pos,{name="air"})
cf.area.delete_flag(team,pos)
end
end
else
minetest.chat_send_player(puncher:get_player_name(),"You are not part of a team!")
end
end,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Unowned flag")
end,
after_place_node = function(pos, placer)
if not pos then
return
end
local meta = minetest.env:get_meta(pos)
if not meta then
return
end
if cf.players and cf.players[placer:get_player_name()] and cf.players[placer:get_player_name()].team then
local team = cf.players[placer:get_player_name()].team
meta:set_string("team", team)
meta:set_string("infotext", meta:get_string("team").."'s flag")
-- add flag
cf.area.add_flag(team,pos)
if cf.teams[team].spawn and minetest.env:get_node(cf.teams[team].spawn).name == "capturetheflag:flag" then
if not cf.settings.multiple_flags then
-- send message
minetest.chat_send_all(team.."'s flag has been moved")
minetest.env:set_node(cf.team(team).spawn,{name="air"})
minetest.env:set_node({
x=cf.team(team).spawn.x,
y=cf.team(team).spawn.y+1,
z=cf.team(team).spawn.z
},{name="air"})
cf.team(team).spawn = pos
end
else
cf.area.get_spawn(team)
end
cf.save()
local pos2 = {
x=pos.x,
y=pos.y+1,
z=pos.z
}
if not cf.team(team).data.color then
cf.team(team).data.color = "red"
cf.save()
end
minetest.env:set_node(pos2,{name="capturetheflag:flag_top_"..cf.team(team).data.color})
local meta2 = minetest.env:get_meta(pos2)
meta2:set_string("team", team)
meta2:set_string("infotext", meta:get_string("team").."'s flag")
else
minetest.chat_send_player(placer:get_player_name(),"You are not part of a team!")
minetest.env:set_node(pos,{name="air"})
end
end
}
-- The flag
minetest.register_node("capturetheflag:flag",{
description = "Flag",
drawtype="nodebox",
paramtype = "light",
walkable = false,
tiles = {
"default_wood.png",
"default_wood.png",
"default_wood.png",
"default_wood.png",
"default_wood.png",
"default_wood.png"
},
node_box = {
type = "fixed",
fixed = {
{0.250000,-0.500000,0.000000,0.312500,0.500000,0.062500}
}
},
groups = {immortal=1,is_flag=1,flag_bottom=1},
on_punch = cf.flag_func.on_punch,
on_rightclick = cf.flag_func.on_rightclick,
on_construct = cf.flag_func.on_construct,
after_place_node = cf.flag_func.after_place_node
})
local colors = {"red","green","blue"}
for i=1,#colors do
local color = colors[i]
minetest.register_node("capturetheflag:flag_top_"..color,{
description = "You are not meant to have this! - flag top",
drawtype="nodebox",
paramtype = "light",
walkable = false,
tiles = {
"default_wood.png",
"default_wood.png",
"default_wood.png",
"default_wood.png",
"flag_"..color.."2.png",
"flag_"..color..".png"
},
node_box = {
type = "fixed",
fixed = {
{0.250000,-0.500000,0.000000,0.312500,0.500000,0.062500},
{-0.5,0,0.000000,0.250000,0.500000,0.062500}
}
},
groups = {immortal=1,is_flag=1,flag_top=1,not_in_creative_inventory=1},
on_punch = cf.flag_func.on_punch_top,
on_rightclick = cf.flag_func.on_rightclick_top
})
end
-- On respawn
minetest.register_on_respawnplayer(function(player)
if player and cf.player(player:get_player_name()) then
local team = cf.player(player:get_player_name()).team
if team and cf.team(team) and cf.area.get_spawn(team)==true then
print("Player "..player:get_player_name().." moved to team spawn")
player:moveto(cf.team(team).spawn, false)
return true
end
end
return false
end)
minetest.register_abm({
nodenames = {"group:flag_bottom"},
inteval = 5,
chance = 1,
action = function(pos)
local top = {x=pos.x,y=pos.y+1,z=pos.z}
local flagmeta = minetest.env:get_meta(pos)
if not flagmeta then
return
end
local flag_team_data = cf.area.get_flag(pos)
if not flag_team_data or not cf.team(flag_team_data.team)then
print("Flag does not exist! "..dump(pos))
minetest.env:set_node(pos,{name="air"})
minetest.env:set_node(top,{name="air"})
return
end
flagmeta:set_string("team", flag_team_data.team)
local topmeta = minetest.env:get_meta(top)
local flag_name = nil
if topmeta then
flag_name = flagmeta:get_string("flag_name")
end
if flag_name then
flagmeta:set_string("infotext", flag_name.." - "..flag_team_data.team)
else
flagmeta:set_string("infotext", flag_team_data.team.."'s flag")
end
if not cf.team(flag_team_data.team).data.color then
cf.team(flag_team_data.team).data.color = "red"
cf.save()
end
minetest.env:set_node(top,{name="capturetheflag:flag_top_"..cf.team(flag_team_data.team).data.color})
topmeta = minetest.env:get_meta(top)
topmeta:set_string("team", flag_team_data.team)
topmeta:set_string("flag_name", flag_name)
if flag_name then
topmeta:set_string("infotext", flag_name.." - "..flag_team_data.team)
else
topmeta:set_string("infotext", flag_team_data.team.."'s flag")
end
end
})

381
mods/capturetheflag/gui.lua Normal file
View File

@ -0,0 +1,381 @@
cf.gui = {}
if cf.settings.team_gui and cf.settings.gui then -- check if team guis are enabled
-- Get tab buttons
function cf.gui.tabs(name,team)
return (
"button[1,0;2,1;home;About]"..
"button[3,0;2,1;board;News]"..
"button[5,0;2,1;diplo;Diplomacy]"..
"button[7,0;2,1;admin;Settings]"
)
end
-- Team interface
function cf.gui.team_board(name,team)
local result = ""
local data = cf.teams[team].log
if not data then
data = {}
end
local amount = 0
for i=1,#data do
if data[i].type == "request" then
if cf.can_mod(name,team)==true then
amount = amount + 2
local height = (amount*0.5) + 0.5
amount = amount + 1
if data[i].mode == "diplo" then
result = result .. "image[0.5,".. height ..";10.5,1;diplo_"..data[i].msg..".png]"
if data[i].msg == "alliance" then
result = result .. "label[1,".. height ..";".. data[i].team .." offers an "..minetest.formspec_escape(data[i].msg).." treaty]"
else
result = result .. "label[1,".. height ..";".. data[i].team .." offers a "..minetest.formspec_escape(data[i].msg).." treaty]"
end
result = result .. "button[6,".. height ..";1,1;btn_y"..i..";Yes]"
result = result .. "button[7,".. height ..";1,1;btn_n"..i..";No]"
else
result = result .. "label[0.5,".. height ..";RANDOM REQUEST TYPE]"
end
end
else
amount = amount + 1
local height = (amount*0.5)+0.5
if height > 7 then
print("break!")
break
end
result = result .. "label[0.5,".. height ..";".. minetest.formspec_escape(data[i].msg) .."]"
end
end
if cf.can_mod(name,team)==true then
result = result .. "button[4,6;2,1;clear;Clear all]"
end
if amount == 0 then
result = "label[0.5,1;Welcome to the news panel]"..
"label[0.5,1.5;News such as attacks will appear here]"
end
minetest.show_formspec(name, "capturetheflag:board",
"size[10,7]"..
cf.gui.tabs(name,team)..
result
)
end
-- Team interface
function cf.gui.team_about(name,team)
local result = ""
local data = {
"Welcome to "..team.."!",
}
local amount = 0
for i=1,#data do
amount = i
local height = (i*0.5)+0.5
if height > 7 then
break
end
result = result .. "label[0.5,".. height ..";".. data[i] .."]"
end
minetest.show_formspec(name, "capturetheflag:home",
"size[10,7]"..
cf.gui.tabs(name,team)..
result
)
end
-- Team interface
function cf.gui.team_dip(name,team)
local result = ""
local data = {}
local amount = 0
for key,value in pairs(cf.teams) do
if key ~= team then
table.insert(data,{team=key,state=cf.diplo.get(team,key)})
end
end
result = result .. "label[1,1;Diplomacy from the perspective of "..team.."]"
for i=1,#data do
amount = i
local height = (i*1)+0.5
if height > 6 then
break
end
result = result .. "image[1,".. height ..";10,1;diplo_"..data[i].state..".png]"
result = result .. "button[1.25,".. height ..";2,1;team_".. data[i].team ..";".. data[i].team .."]"
result = result .. "label[3.75,".. height ..";".. data[i].state .."]"
if cf.can_mod(name,team)==true then
if data[i].state == "war" then
result = result .. "button[7.5,".. height ..";1.5,1;peace_".. data[i].team ..";Peace]"
elseif data[i].state == "peace" then
result = result .. "button[6,".. height ..";1.5,1;war_".. data[i].team ..";War]"
result = result .. "button[7.5,".. height ..";1.5,1;alli_".. data[i].team ..";Alliance]"
elseif data[i].state == "alliance" then
result = result .. "button[6,".. height ..";1.5,1;peace_".. data[i].team ..";Peace]"
end
end
end
minetest.show_formspec(name, "capturetheflag:dip",
"size[10,7]"..
cf.gui.tabs(name,team)..
result
)
end
-- Team interface
function cf.gui.team_settings(name,team)
if not team or not cf.team(team) then
return
end
local color = ""
if cf.team(team).data and cf.team(team).data.color then
color = cf.team(team).data.color
end
local result = "field[1,2;4,1;color;Team Color;"..color.."]"..
"button[4,6;2,1;save;Save]"
if cf.can_mod(name,team) == false then
result = "label[0.5,1;You do not own this team!"
end
minetest.show_formspec(name, "capturetheflag:team_settings",
"size[10,7]"..
cf.gui.tabs(name,team)..
result
)
end
minetest.register_chatcommand("team", {
description = "Open the team console",
func = function(name, param)
if cf and cf.players and cf.players[name] and cf.players[name].team then
cf.gui.team_board(name,cf.players[name].team)
end
end,
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name()
if formname=="capturetheflag:board" or formname=="capturetheflag:home" or formname=="capturetheflag:dip" or formname=="capturetheflag:team_settings" then
if fields.home then
if cf and cf.players and cf.players[name] and cf.players[name].team then
cf.gui.team_about(name,cf.players[name].team)
end
return true
end
if fields.board then
if cf and cf.players and cf.players[name] and cf.players[name].team then
cf.gui.team_board(name,cf.players[name].team)
end
return true
end
if fields.diplo then
if cf and cf.players and cf.players[name] and cf.players[name].team then
cf.gui.team_dip(name,cf.players[name].team)
end
return true
end
if fields.admin then
if cf and cf.players and cf.players[name] and cf.players[name].team then
cf.gui.team_settings(name,cf.players[name].team)
end
return true
end
if fields.clear then
if cf and cf.players and cf.players[name] and cf.players[name].team then
cf.team(cf.players[name].team).log = {}
cf.save()
cf.gui.team_board(name,cf.players[name].team)
end
return true
end
if fields.save and formname=="capturetheflag:team_settings" then
if cf and cf.players and cf.players[name] and cf.players[name].team then
cf.gui.team_settings(name,cf.players[name].team)
end
if cf and cf.team(cf.players[name].team) and cf.team(cf.players[name].team).data then
if minetest.registered_items["capturetheflag:flag_top_"..fields.color] then
print("Setting color...")
cf.team(cf.players[name].team).data.color = fields.color
cf.save()
else
minetest.chat_send_player(name,"Color "..fields.color.." does not exist!")
end
end
return true
end
end
end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name()
if formname=="capturetheflag:board" then
for key, field in pairs(fields) do
local ok, id = string.match(key, "btn_([yn])([0123456789]+)")
if ok and id then
if cf.player(name) and cf.player(name).team and cf.team(cf.player(name).team) then
if ok == "y" then
cf.diplo.set(cf.player(name).team, cf.team(cf.player(name).team).log[tonumber(id)].team, cf.team(cf.player(name).team).log[tonumber(id)].msg)
end
table.remove(cf.team(cf.player(name).team).log,id)
cf.save()
cf.gui.team_board(name,cf.player(name).team)
return true
end
end
end
end
end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name()
if formname=="capturetheflag:dip" then
for key, field in pairs(fields) do
local newteam = string.match(key, "team_(.+)")
if newteam then
cf.gui.team_dip(name,newteam)
return true
end
end
end
end)
end -- end of check if team guis are enabled
-- Flag interface
function cf.gui.flag_board(name,pos)
local meta = minetest.env:get_meta(pos)
if not meta then
return
end
local team = meta:get_string("team")
if not team then
return
end
if cf.can_mod(name,team) == false then
return
end
local flag_name = meta:get_string("flag_name")
if not cf.settings.flag_names then
meta:set_string("flag_name",nil)
return
end
if not cf.settings.gui then
return
end
if not flag_name then
flag_name = ""
end
if not cf.gui.flag_data then
cf.gui.flag_data = {}
end
cf.gui.flag_data[name] = {pos=pos}
minetest.show_formspec(name, "capturetheflag:flag_board",
"size[6,3]"..
"field[1,1;4,1;flag_name;Flag Name;"..flag_name.."]"..
"button_exit[1,2;2,1;save;Save]"..
"button_exit[3,2;2,1;delete;Delete]"
)
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name()
if not formname=="capturetheflag:flag_board" then
return false
end
if fields.save and fields.flag_name then
local meta = minetest.env:get_meta(cf.gui.flag_data[name].pos)
if not meta then
return false
end
local team = meta:get_string("team")
if not team then
return false
end
if cf.can_mod(name,team) == false then
return false
end
local flag_name = meta:get_string("flag_name")
if not flag_name then
flag_name = ""
end
meta:set_string("flag_name",fields.flag_name)
local msg = flag_name.." was renamed to "..fields.flag_name
if flag_name=="" then
msg = "A flag was named "..fields.flag_name.." at ("..cf.gui.flag_data[name].pos.x..","..cf.gui.flag_data[name].pos.z..")"
end
print(msg)
cf.post(team,{msg=msg,icon="flag_info"})
return true
elseif fields.delete then
local pos = cf.gui.flag_data[name].pos
local meta = minetest.env:get_meta(cf.gui.flag_data[name].pos)
if not meta then
return false
end
local team = meta:get_string("team")
if not team then
return false
end
if cf.can_mod(name,team) == false then
return false
end
cf.area.delete_flag(team,pos)
minetest.env:set_node(pos,{name="air"})
pos.y=pos.y+1
minetest.env:set_node(pos,{name="air"})
return true
end
end)

View File

@ -0,0 +1,270 @@
-- CAPTURE THE FLAG
-- by Andrew "rubenwardy" Ward
-----------------------------------------
cf = {}
-- init game
function cf.init()
print("[CaptureTheFlag] Initialising...")
-- Set up structures
cf.settings = {}
cf.teams = {}
cf.players = {}
cf.diplo.diplo = {}
-- Settings: Feature enabling
cf._setb("node_ownership",true)
cf._setb("multiple_flags",true)
cf._setb("gui",true)
cf._setb("team_gui",true)
cf._setb("flag_names",true) -- can flags be named
cf._setb("team_channel",true) -- do teams have their own chat channel
cf._setb("global_channel",true) -- Can players chat with other teams on /all. If team_channel is false, this does nothing.
-- Settings: Teams
cf._set("allocate_mode",0) -- how are players allocated to teams?
cf._set("default_diplo_state","war") -- what is the default diplomatic state? (war/peace/alliance)
cf._setb("delete_teams",false) -- should teams be deleted when they are defeated?
-- Settings: Misc
cf._set("on_game_end",0) -- what happens when the game ends?
cf._set("flag_protect_distance",25) -- how far do flags protect?
local file = io.open(minetest.get_worldpath().."/ctf.txt", "r")
if file then
local table = minetest.deserialize(file:read("*all"))
if type(table) == "table" then
cf.teams = table.teams
cf.players = table.players
cf.diplo.diplo = table.diplo
return
end
end
end
-- Set settings
function cf._set(setting,default)
if minetest.setting_get("ctf_"..setting)~=nil and minetest.setting_get("ctf_"..setting)~="" then
print("Setting: "..setting.." has been set from config")
cf.settings[setting] = minetest.setting_get("ctf_"..setting)
else
print("Setting: "..setting.." has been set from default")
cf.settings[setting] = default
end
end
function cf._setb(setting,default)
if minetest.setting_get("ctf_"..setting)~=nil and minetest.setting_get("ctf_"..setting)~="" then
cf.settings[setting] = minetest.setting_getbool("ctf_"..setting)
else
cf.settings[setting] = default
end
end
-- Save game
function cf.save()
print("[CaptureTheFlag] Saving data...")
local file = io.open(minetest.get_worldpath().."/ctf.txt", "w")
if file then
file:write(minetest.serialize({
teams = cf.teams,
players = cf.players,
diplo = cf.diplo.diplo
}))
file:close()
end
end
-- Get or add a team
function cf.team(name) -- get or add a team
if type(name) == "table" then
if not name.add_team then
error("Invalid table given to cf.team")
return
end
print("Defining team "..name.name)
cf.teams[name.name]={
data = name,
spawn=nil,
players={},
flags = {}
}
cf.save()
return cf.teams[name.name]
else
return cf.teams[name]
end
end
-- get a player
function cf.player(name)
return cf.players[name]
end
-- add a user to a team
function cf.add_user(team,user)
local _team = cf.team(team)
local _user = cf.player(user.name)
if _team and user and user.name then
if _user and _user.team and cf.team(_user.team) then
cf.teams[_user.team].players[user.name] = nil
end
user.team = team
user.auth = false
_team.players[user.name]=user
cf.players[user.name] = user
cf.save()
return true
else
return false
end
end
-- Cleans up the player lists
function cf.clean_player_lists()
for _, str in pairs(cf.players) do
if str and str.team and cf.teams[str.team] then
print("Adding player "..str.name.." to team "..str.team)
cf.teams[str.team].players[str.name] = str
else
print("Skipping player "..str.name)
end
end
end
-- Cleans up the flag lists
function cf.clean_flags()
for _, str in pairs(cf.teams) do
cf.area.asset_flags(str.data.name)
end
end
-- Sees if the player can change stuff in a team
function cf.can_mod(player,team)
if player and cf.teams[team] and cf.teams[team].players and cf.teams[team].players[player] then
if cf.teams[team].players[player].auth == true then
return true
end
end
return false
end
-- post a message to a team board
function cf.post(team,msg)
if not cf.team(team) then
return false
end
if not cf.team(team).log then
cf.team(team).log = {}
end
table.insert(cf.team(team).log,1,msg)
cf.save()
return true
end
-- diplo states: war, peace, alliance
cf.diplo = {}
function cf.diplo.get(one,two)
if not cf.diplo.diplo then
return cf.settings.default_diplo_state
end
for i=1,#cf.diplo.diplo do
local dip = cf.diplo.diplo[i]
if (dip.one == one and dip.two == two) or (dip.one == two and dip.two == one) then
return dip.state
end
end
return cf.settings.default_diplo_state
end
function cf.diplo.set(one,two,state)
if cf.diplo.diplo then
for i=1,#cf.diplo.diplo do
local dip = cf.diplo.diplo[i]
if (dip.one == one and dip.two == two) or (dip.one == two and dip.two == one) then
dip.state = state
return
end
end
end
table.insert(cf.diplo.diplo,{one=one,two=two,state=state})
return
end
-- Vector stuff
v3={}
function v3.distance(v, w)
return math.sqrt(
math.pow(v.x - w.x, 2) +
math.pow(v.y - w.y, 2) +
math.pow(v.z - w.z, 2)
)
end
function v3.get_direction(pos1,pos2)
local x_raw = pos2.x -pos1.x
local y_raw = pos2.y -pos1.y
local z_raw = pos2.z -pos1.z
local x_abs = math.abs(x_raw)
local y_abs = math.abs(y_raw)
local z_abs = math.abs(z_raw)
if x_abs >= y_abs and
x_abs >= z_abs then
y_raw = y_raw * (1/x_abs)
z_raw = z_raw * (1/x_abs)
x_raw = x_raw/x_abs
end
if y_abs >= x_abs and
y_abs >= z_abs then
x_raw = x_raw * (1/y_abs)
z_raw = z_raw * (1/y_abs)
y_raw = y_raw/y_abs
end
if z_abs >= y_abs and
z_abs >= x_abs then
x_raw = x_raw * (1/z_abs)
y_raw = y_raw * (1/z_abs)
z_raw = z_raw/z_abs
end
return {x=x_raw,y=y_raw,z=z_raw}
end
-- Load the core
cf.init()
cf.clean_player_lists()
-- Load Modules
dofile(minetest.get_modpath("capturetheflag").."/area.lua")
dofile(minetest.get_modpath("capturetheflag").."/gui.lua")
dofile(minetest.get_modpath("capturetheflag").."/cli.lua")
dofile(minetest.get_modpath("capturetheflag").."/flag.lua")

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 732 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 812 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

22
mods/chatplus/.gitattributes vendored Normal file
View File

@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

215
mods/chatplus/.gitignore vendored Normal file
View File

@ -0,0 +1,215 @@
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg

18
mods/chatplus/README.md Normal file
View File

@ -0,0 +1,18 @@
Chatplus
--------
License: CC-BY-SA to Rubenwardy
Commands
========
* /ignore [name] - ignore a player
* /unignore [name] - unignore a player
* /mail [name] [msg] - message a player (online or offline!)
* /inbox - open your inbox
* /inbox clear - clear your inbox
HUD
===
This mod adds a new message icon to the HUD. If HUDs are not supported, no icon is added.

313
mods/chatplus/init.lua Normal file
View File

@ -0,0 +1,313 @@
-- Chat plus
chatplus = {
log = true, -- change this to true to log all chat messages
log_file = minetest.get_worldpath().."/chatplus-log.txt", -- default log file
distance = minetest.setting_get("chatplus_distance"),
log_handle = nil, -- do not change
-- Initialise Chat Plus
init = function()
chatplus.load()
if not chatplus.players then
chatplus.players = {}
end
chatplus._players = {}
end,
-- Checks that a user's namespace is ok
poke = function(name,player)
if not chatplus.players then
chatplus.init()
end
if not chatplus.players[name] then
chatplus.players[name] = {}
end
if not chatplus.players[name].ignore then
chatplus.players[name].ignore = {}
end
if not chatplus.players[name].messages then
chatplus.players[name].messages = {}
end
chatplus.players[name].enabled = true
if player then
if player=="end" then
chatplus.players[name].enabled = false
chatplus._players[name] = nil
elseif not chatplus._players[name] then
chatplus._players[name] = {player = player}
end
end
chatplus.save()
return chatplus.players[name]
end,
-- Outputs and sends message stream
activate = function(name)
if not chatplus.players[name] then
return false
end
local player = chatplus.players[name]
if not player.messages or #player.messages==0 then
minetest.chat_send_player(name,"You have no messages")
return false
end
minetest.chat_send_player(name,"("..#player.messages..") You have mail:")
for i=1,#player.messages do
minetest.chat_send_player(name,player.messages[i],false)
end
minetest.chat_send_player(name,"("..#player.messages..")",false)
return true
end,
count = 0,
save = function()
print("[Chatplus] Saving data")
local file = io.open(minetest.get_worldpath().."/chatplus.txt", "w")
if file then
file:write(minetest.serialize(chatplus.players))
file:close()
end
end,
load = function()
-- Initialize the log
if ( chatplus.log == true ) then
chatplus.log_handle = io.open(chatplus.log_file,"a+")
if ( chatplus.log_handle == nil ) then
minetest.log("action","Unable to open chat plus log file: "..chatplus.log_file)
else
minetest.log("action","Logging chat plus to: "..chatplus.log_file)
end
-- no further checking, when writing to log we will make sure chatplus.log_handle ~= nil
end
-- load saved messages
local file = io.open(minetest.get_worldpath().."/chatplus.txt", "r")
if file then
local table = minetest.deserialize(file:read("*all"))
file:close()
if type(table) == "table" then
chatplus.players = table
return
end
end
end,
_handlers = {},
register_handler = function(func,place)
if not place then
table.insert(chatplus._handlers,func)
else
table.insert(chatplus._handlers,place,func)
end
end
}
function chatplus.get_distance(v, w)
return math.sqrt(
math.pow(v.x - w.x, 2) +
math.pow(v.y - w.y, 2) +
math.pow(v.z - w.z, 2)
)
end
-- Register handler caller
minetest.register_on_chat_message(function(name,msg)
if ( chatplus.log_handle ~= nil ) then
chatplus.log_handle:write(os.date("%m/%d/%Y %I:%M%p").." <"..name.."> "..msg.."\r\n")
chatplus.log_handle:flush()
end
for key,value in pairs(chatplus.players) do
local res = nil
for i=1,#chatplus._handlers do
if chatplus._handlers[i] then
res = chatplus._handlers[i](name,key,msg)
if res ~= nil then
break
end
end
end
if (res == nil or res == true) and key~=name then
minetest.chat_send_player(key,"<"..name.."> "..msg,false)
end
end
return true
end)
-- Register ignore
chatplus.register_handler(function(from,to,msg)
if chatplus.players[to] and chatplus.players[to].ignore and chatplus.players[to].ignore[from]==true then
return false
end
return nil
end)
if not chatplus.distance then
chatplus.register_handler(function(from,to,msg)
local from_o = minetest.get_player_by_name(from)
local to_o = minetest.get_player_by_name(to)
if not from_o or not to_o then
return nil
end
if chatplus.distance ~= 0 and chatplus.distance ~= nil and (chatplus.get_distance(from_o:getpos(),to_o:getpos()) > tonumber(chatplus.distance)) then
return false
end
return nil
end)
end
minetest.register_on_joinplayer(function(player)
local _player = chatplus.poke(player:get_player_name(),player)
if ( chatplus.log_handle ~= nil ) then
chatplus.log_handle:write(os.date("%m/%d/%Y %I:%M%p").." "..player:get_player_name().." joined\r\n")
chatplus.log_handle:flush()
end
if _player.messages and #_player.messages>0 then
-- Sending chat messages immediately on join are sometimes missed or not received at all so we delay it
minetest.after(10,minetest.chat_send_player,player:get_player_name(),"("..#_player.messages..") You have mail! Type /inbox to recieve")
--minetest.chat_send_player(player:get_player_name(),"("..#_player.messages..") You have mail! Type /inbox to recieve")
end
end)
minetest.register_on_leaveplayer(function(player)
chatplus.poke(player:get_player_name(),"end")
chatplus.players[player:get_player_name()].enabled = false
if ( chatplus.log_handle ~= nil ) then
chatplus.log_handle:write(os.date("%m/%d/%Y %I:%M%p").." "..player:get_player_name().." disconnected\r\n")
chatplus.log_handle:flush()
end
end)
minetest.register_globalstep(function(dtime)
chatplus.count = chatplus.count + dtime
if chatplus.count > 5 then
chatplus.count = 0
-- loop through player list
for key,value in pairs(chatplus.players) do
if chatplus._players and chatplus._players[key] and chatplus._players[key].player and value and value.messages and chatplus._players[key].player.hud_add and chatplus._players[key].lastcount ~= #value.messages then
if chatplus._players[key].msgicon then
chatplus._players[key].player:hud_remove(chatplus._players[key].msgicon)
end
if chatplus._players[key].msgicon2 then
chatplus._players[key].player:hud_remove(chatplus._players[key].msgicon2)
end
if #value.messages>0 then
chatplus._players[key].msgicon = chatplus._players[key].player:hud_add({
hud_elem_type = "image",
name = "MailIcon",
position = {x=0.52, y=0.52},
text="chatplus_mail.png",
scale = {x=1,y=1},
alignment = {x=0.5, y=0.5},
})
chatplus._players[key].msgicon2 = chatplus._players[key].player:hud_add({
hud_elem_type = "text",
name = "MailText",
position = {x=0.55, y=0.52},
text=#value.messages,
scale = {x=1,y=1},
alignment = {x=0.5, y=0.5},
})
end
chatplus._players[key].lastcount = #value.messages
end
end
end
end)
minetest.register_chatcommand("ignore", {
params = "name",
description = "ignore: Ignore a player",
func = function(name, param)
chatplus.poke(name)
if not chatplus.players[name].ignore[param]==true then
chatplus.players[name].ignore[param]=true
minetest.chat_send_player(name,param.." has been ignored")
chatplus.save()
else
minetest.chat_send_player(name,"Player "..param.." is already ignored.")
end
end,
})
minetest.register_chatcommand("unignore", {
params = "name",
description = "unignore: Unignore a player",
func = function(name, param)
chatplus.poke(name)
if chatplus.players[name].ignore[param]==true then
chatplus.players[name].ignore[param]=false
minetest.chat_send_player(name,param.." has been unignored")
chatplus.save()
else
minetest.chat_send_player(name,"Player "..param.." is already unignored.")
end
end,
})
minetest.register_chatcommand("inbox", {
params = "clear?",
description = "inbox: print the items in your inbox",
func = function(name, param)
if param == "clear" then
local player = chatplus.poke(name)
player.messages = {}
chatplus.save()
minetest.chat_send_player(name,"Inbox cleared")
else
chatplus.activate(name)
end
end,
})
minetest.register_chatcommand("mail", {
params = "name msg",
description = "mail: add a message to a player's inbox",
func = function(name, param)
chatplus.poke(name)
local to, msg = string.match(param, "([%a%d_]+) (.+)")
if not to or not msg then
minetest.chat_send_player(name,"mail: <playername> <msg>")
return
end
print("To: "..to)
print("From: "..name)
print("MSG: "..msg)
if chatplus.players[to] then
table.insert(chatplus.players[to].messages,"mail from <"..name..">: "..msg)
minetest.chat_send_player(name,"Message sent")
chatplus.save()
else
minetest.chat_send_player(name,"Player "..to.." does not exist")
end
end,
})
chatplus.init()

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

22
mods/creative/README.txt Normal file
View File

@ -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.

View File

@ -0,0 +1 @@
default

163
mods/creative/init.lua Normal file
View File

@ -0,0 +1,163 @@
-- 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
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
minetest.register_item(":", {
type = "none",
wield_image = "wieldhand.png",
wield_scale = {x=1,y=1,z=2.5},
tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level = 3,
groupcaps = {
crumbly = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
cracky = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
snappy = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
choppy = {times={[1]=0.5, [2]=0.5, [3]=0.5}, uses=0, maxlevel=3},
oddly_breakable_by_hand = {times={[1]=0.5, [2]=0.5, [3]=0.5}, 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

181
mods/default/README.txt Normal file
View File

@ -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

742
mods/default/crafting.lua Normal file
View File

@ -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 = {
{'default:stick', 'default:stick', 'default:stick'},
{'default:stick', 'default:stick', 'default:stick'},
}
})
minetest.register_craft({
output = 'default:sign_wall',
recipe = {
{'group:wood', 'group:wood', 'group:wood'},
{'group:wood', 'group:wood', 'group:wood'},
{'', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'default:torch 4',
recipe = {
{'default:coal_lump'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:pick_wood',
recipe = {
{'group:wood', 'group:wood', 'group:wood'},
{'', 'default:stick', ''},
{'', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'default:pick_stone',
recipe = {
{'group:stone', 'group:stone', 'group:stone'},
{'', 'default:stick', ''},
{'', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'default:pick_steel',
recipe = {
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
{'', 'default:stick', ''},
{'', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'default:pick_bronze',
recipe = {
{'default:bronze_ingot', 'default:bronze_ingot', 'default:bronze_ingot'},
{'', 'default:stick', ''},
{'', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'default:pick_mese',
recipe = {
{'default:mese_crystal', 'default:mese_crystal', 'default:mese_crystal'},
{'', 'default:stick', ''},
{'', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'default:pick_diamond',
recipe = {
{'default:diamond', 'default:diamond', 'default:diamond'},
{'', 'default:stick', ''},
{'', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'default:shovel_wood',
recipe = {
{'group:wood'},
{'default:stick'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:shovel_stone',
recipe = {
{'group:stone'},
{'default:stick'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:shovel_steel',
recipe = {
{'default:steel_ingot'},
{'default:stick'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:shovel_bronze',
recipe = {
{'default:bronze_ingot'},
{'default:stick'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:shovel_mese',
recipe = {
{'default:mese_crystal'},
{'default:stick'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:shovel_diamond',
recipe = {
{'default:diamond'},
{'default:stick'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:axe_wood',
recipe = {
{'group:wood', 'group:wood'},
{'group:wood', 'default:stick'},
{'', 'default:stick'},
}
})
minetest.register_craft({
output = 'default:axe_stone',
recipe = {
{'group:stone', 'group:stone'},
{'group:stone', 'default:stick'},
{'', 'default:stick'},
}
})
minetest.register_craft({
output = 'default:axe_steel',
recipe = {
{'default:steel_ingot', 'default:steel_ingot'},
{'default:steel_ingot', 'default:stick'},
{'', 'default:stick'},
}
})
minetest.register_craft({
output = 'default:axe_bronze',
recipe = {
{'default:bronze_ingot', 'default:bronze_ingot'},
{'default:bronze_ingot', 'default:stick'},
{'', 'default:stick'},
}
})
minetest.register_craft({
output = 'default:axe_mese',
recipe = {
{'default:mese_crystal', 'default:mese_crystal'},
{'default:mese_crystal', 'default:stick'},
{'', 'default:stick'},
}
})
minetest.register_craft({
output = 'default:axe_diamond',
recipe = {
{'default:diamond', 'default:diamond'},
{'default:diamond', 'default:stick'},
{'', 'default:stick'},
}
})
minetest.register_craft({
output = 'default:sword_wood',
recipe = {
{'group:wood'},
{'group:wood'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:sword_stone',
recipe = {
{'group:stone'},
{'group:stone'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:sword_steel',
recipe = {
{'default:steel_ingot'},
{'default:steel_ingot'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:sword_bronze',
recipe = {
{'default:bronze_ingot'},
{'default:bronze_ingot'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:sword_mese',
recipe = {
{'default:mese_crystal'},
{'default:mese_crystal'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:sword_diamond',
recipe = {
{'default:diamond'},
{'default:diamond'},
{'default:stick'},
}
})
minetest.register_craft({
output = 'default:rail 15',
recipe = {
{'default:steel_ingot', '', 'default:steel_ingot'},
{'default:steel_ingot', 'default: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 = {
{'default:stick', '', 'default:stick'},
{'default:stick', 'default:stick', 'default:stick'},
{'default:stick', '', 'default: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,
})

View File

@ -0,0 +1,91 @@
-- mods/default/craftitems.lua
minetest.register_craftitem("default:stick", {
description = "Stick",
inventory_image = "default_stick.png",
})
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",
})
minetest.register_craftitem("default:copper_lump", {
description = "Copper Lump",
inventory_image = "default_copper_lump.png",
})
minetest.register_craftitem("default:mese_crystal", {
description = "Mese Crystal",
inventory_image = "default_mese_crystal.png",
})
minetest.register_craftitem("default:gold_lump", {
description = "Gold Lump",
inventory_image = "default_gold_lump.png",
})
minetest.register_craftitem("default:diamond", {
description = "Diamond",
inventory_image = "default_diamond.png",
})
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",
})
minetest.register_craftitem("default:copper_ingot", {
description = "Copper Ingot",
inventory_image = "default_copper_ingot.png",
})
minetest.register_craftitem("default:bronze_ingot", {
description = "Bronze Ingot",
inventory_image = "default_bronze_ingot.png",
})
minetest.register_craftitem("default:gold_ingot", {
description = "Gold Ingot",
inventory_image = "default_gold_ingot.png"
})
minetest.register_craftitem("default:mese_crystal_fragment", {
description = "Mese Crystal Fragment",
inventory_image = "default_mese_crystal_fragment.png",
})
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",
})

315
mods/default/functions.lua Normal file
View File

@ -0,0 +1,315 @@
-- 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(p, node)
--print("on_dignode")
end
minetest.register_on_dignode(on_dignode)
function on_punchnode(p, node)
end
minetest.register_on_punchnode(on_punchnode)
--
-- 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
})

21
mods/default/init.lua Normal file
View File

@ -0,0 +1,21 @@
-- 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").."/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")

513
mods/default/mapgen.lua Normal file
View File

@ -0,0 +1,513 @@
-- mods/default/mapgen.lua
--
-- Aliases for map generator outputs
--
minetest.register_alias("mapgen_air", "air")
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")
--
-- 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"})
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)

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

File diff suppressed because it is too large Load Diff

1329
mods/default/nodes.lua Normal file

File diff suppressed because it is too large Load Diff

132
mods/default/player.lua Normal file
View File

@ -0,0 +1,132 @@
-- Minetest 0.4 mod: player
-- See README.txt for licensing and other information.
--
-- Start of configuration area:
--
-- Player animation speed
animation_speed = 30
-- Player animation blending
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
animation_blend = 0
-- Default player appearance
default_model = "character.x"
default_textures = {"character.png", }
-- Frame ranges for each player model
function player_get_animations(model)
if model == "character.x" then
return {
stand_START = 0,
stand_END = 79,
sit_START = 81,
sit_END = 160,
lay_START = 162,
lay_END = 166,
walk_START = 168,
walk_END = 187,
mine_START = 189,
mine_END = 198,
walk_mine_START = 200,
walk_mine_END = 219
}
end
end
--
-- End of configuration area.
--
-- Player stats and animations
local player_model = {}
local player_anim = {}
local player_sneak = {}
local ANIM_STAND = 1
local ANIM_SIT = 2
local ANIM_LAY = 3
local ANIM_WALK = 4
local ANIM_WALK_MINE = 5
local ANIM_MINE = 6
-- Called when a player's appearance needs to be updated
function player_update_visuals(pl)
local name = pl:get_player_name()
player_model[name] = default_model
player_anim[name] = 0 -- Animation will be set further below immediately
player_sneak[name] = false
prop = {
mesh = default_model,
textures = default_textures,
visual = "mesh",
visual_size = {x=1, y=1},
}
pl:set_properties(prop)
end
-- Update appearance when the player joins
minetest.register_on_joinplayer(player_update_visuals)
-- Check each player and apply animations
function player_step(dtime)
for _, pl in pairs(minetest.get_connected_players()) do
local name = pl:get_player_name()
local anim = player_get_animations(player_model[name])
local controls = pl:get_player_control()
local walking = false
local animation_speed_mod = animation_speed
-- 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 and pl:get_hp() ~= 0 and (walking or controls.LMB) then
animation_speed_mod = animation_speed_mod / 2
-- Refresh player animation below if sneak state changed
if not player_sneak[name] then
player_anim[name] = 0
player_sneak[name] = true
end
else
-- Refresh player animation below if sneak state changed
if player_sneak[name] then
player_anim[name] = 0
player_sneak[name] = false
end
end
-- Apply animations based on what the player is doing
if pl:get_hp() == 0 then
if player_anim[name] ~= ANIM_LAY then
pl:set_animation({x=anim.lay_START, y=anim.lay_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_LAY
end
elseif walking and controls.LMB then
if player_anim[name] ~= ANIM_WALK_MINE then
pl:set_animation({x=anim.walk_mine_START, y=anim.walk_mine_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_WALK_MINE
end
elseif walking then
if player_anim[name] ~= ANIM_WALK then
pl:set_animation({x=anim.walk_START, y=anim.walk_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_WALK
end
elseif controls.LMB then
if player_anim[name] ~= ANIM_MINE then
pl:set_animation({x=anim.mine_START, y=anim.mine_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_MINE
end
elseif player_anim[name] ~= ANIM_STAND then
pl:set_animation({x=anim.stand_START, y=anim.stand_END}, animation_speed_mod, animation_blend)
player_anim[name] = ANIM_STAND
end
end
end
minetest.register_globalstep(player_step)
-- END

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

Some files were not shown because too many files have changed in this diff Show More