Initial Commit

This commit is contained in:
rubenwardy 2014-05-21 18:00:15 +01:00
commit f74d1ba975
3 changed files with 346 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

109
init.lua Normal file
View File

@ -0,0 +1,109 @@
local gui_ids = {}
local count = 0
local scores = {}
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
gui_ids[name] = nil
end)
minetest.register_globalstep(function(dtime)
count = count + dtime
if count > 0.5 then
count = 0
local players = minetest.get_connected_players()
for _,player in pairs(players) do
local name = player:get_player_name()
local pos = player:getpos()
local dist = math.sqrt(pos.x^2 + pos.z^2)
local best = 0
if scores[name] then
best = scores[name]
end
if gui_ids[name] then
player:hud_change(gui_ids[name].current, "text", "Current: "..(math.floor(dist*100)/100).."m")
player:hud_change(gui_ids[name].best, "text", "Best: "..best.."m")
else
gui_ids[name] = {
current = player:hud_add({
hud_elem_type = "text",
name = "jump_d",
number = 0xFFFFFF,
position = {x=0.99, y=0.05},
text="Current: "..(math.floor(dist*100)/100).."m",
scale = {x=200,y=25},
alignment = {x=-1, y=0}
}),
best = player:hud_add({
hud_elem_type = "text",
name = "jump_b",
number = 0xFFFFFF,
position = {x=0.99, y=0.09},
text="Best: "..best.."m",
scale = {x=200,y=25},
alignment = {x=-1, y=0}
})
}
end
if pos.y > -1 and (not scores[name] or scores[name] < (math.floor(dist*100)/100)) then
scores[name] = (math.floor(dist*100)/100)
end
if pos.y < -10 then
player:moveto({x = 0, y = 2, z = 0}, false)
end
end
end
end)
minetest.register_on_mapgen_init(function(mgparams)
minetest.set_mapgen_params({mgname="singlenode"})
end)
minetest.register_on_generated(function(minp, maxp, seed)
-- Set up voxel manip
local t1 = os.clock()
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local a = VoxelArea:new{
MinEdge={x=emin.x, y=emin.y, z=emin.z},
MaxEdge={x=emax.x, y=emax.y, z=emax.z},
}
local data = vm:get_data()
local c_stone = minetest.get_content_id("default:stone")
local c_lava = minetest.get_content_id("default:lava_source")
local dist = 3
-- Loop through
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
if x % dist == 0 and z % dist == 0 and minp.y <= 0 then
for y = minp.y, maxp.y do
if y <= 0 then
local vi = a:index(x, y, z)
data[vi] = c_stone
end
end
elseif minp.y <= -20 then
for y = minp.y, maxp.y do
if y <= -30 then
local vi = a:index(x, y, z)
data[vi] = c_stone
elseif y <= -20 then
local vi = a:index(x, y, z)
data[vi] = c_lava
end
end
end
end
end
vm:set_data(data)
vm:write_to_map(data)
end)
minetest.register_on_respawnplayer(function(player)
if player then
player:moveto({x = 0, y = 2, z = 0}, false)
return true
end
return false
end)