Compare commits
86 Commits
0.4.dev-20
...
0.4.dev-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
569156b013 | ||
|
|
6d4bc012f0 | ||
|
|
2f5c28aaf1 | ||
|
|
4f2c1e36a1 | ||
|
|
bc743ca7ce | ||
|
|
f9d7e399b2 | ||
|
|
3e6f824e6c | ||
|
|
6286c555d4 | ||
|
|
4630281318 | ||
|
|
cd0019acd2 | ||
|
|
e82a76e438 | ||
|
|
ab57fbe4ca | ||
|
|
56f55ab1af | ||
|
|
2445cbbbdc | ||
|
|
48131bf988 | ||
|
|
2b9596fe9b | ||
|
|
0e1f448b61 | ||
|
|
ff82b95800 | ||
|
|
49b7055cb3 | ||
|
|
cb88f7b6d4 | ||
|
|
9425fb8192 | ||
|
|
e48ccd7943 | ||
|
|
6be5441176 | ||
|
|
d5ba7ebaf0 | ||
|
|
270a482740 | ||
|
|
e0b4890794 | ||
|
|
247e8b6e5d | ||
|
|
b760e2ba23 | ||
|
|
103173fc9b | ||
|
|
70ed371d0c | ||
|
|
81d3485109 | ||
|
|
7b7b68cdab | ||
|
|
135a65e200 | ||
|
|
123529e5eb | ||
|
|
e81989a0d8 | ||
|
|
1c15f53318 | ||
|
|
7937813c98 | ||
|
|
ad4040d982 | ||
|
|
69579306dd | ||
|
|
bd21f00f0a | ||
|
|
012bcbcb48 | ||
|
|
e06d4555bf | ||
|
|
abd106bacb | ||
|
|
008de2fb8f | ||
|
|
2e67fa3e48 | ||
|
|
ea36951bc4 | ||
|
|
09c48b60bd | ||
|
|
4cc117ddf6 | ||
|
|
ceaf8edade | ||
|
|
520200d597 | ||
|
|
ab67985d21 | ||
|
|
bc5cc638fc | ||
|
|
bff8be8b76 | ||
|
|
3e95b8a158 | ||
|
|
e8539d4dae | ||
|
|
1907b31da7 | ||
|
|
6145a135bd | ||
|
|
97c3bc408b | ||
|
|
a00e908f52 | ||
|
|
4ad8891e05 | ||
|
|
2b8b2a4f30 | ||
|
|
5c24450e54 | ||
|
|
3a689a5c4f | ||
|
|
44e36d9aad | ||
|
|
62f7f72d20 | ||
|
|
829c632511 | ||
|
|
8730dfb1f9 | ||
|
|
6764365994 | ||
|
|
8addbc9655 | ||
|
|
658d1a7235 | ||
|
|
4b00d4d9d2 | ||
|
|
6a5829788e | ||
|
|
03074cd23e | ||
|
|
2620e8eada | ||
|
|
9b5e676ffa | ||
|
|
fd1ef11617 | ||
|
|
9fa567a6ce | ||
|
|
fc6c00cbe1 | ||
|
|
66f90a6101 | ||
|
|
1fe5c58d56 | ||
|
|
f23616acaf | ||
|
|
7d37913ea4 | ||
|
|
ac56053c74 | ||
|
|
d566ffaa5f | ||
|
|
d06d7cb9a4 | ||
|
|
e494b5d422 |
@@ -10,7 +10,7 @@ project(minetest)
|
||||
# Also remember to set PROTOCOL_VERSION in clientserver.h when releasing
|
||||
set(VERSION_MAJOR 0)
|
||||
set(VERSION_MINOR 4)
|
||||
set(VERSION_PATCH dev-20111203-3)
|
||||
set(VERSION_PATCH dev-20120106-1)
|
||||
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||
|
||||
MESSAGE(STATUS "*** Will build version ${VERSION_STRING} ***")
|
||||
|
||||
@@ -97,7 +97,6 @@ minetest.register_nodedef_defaults({
|
||||
post_effect_color = {a=0, r=0, g=0, b=0},
|
||||
paramtype = "none",
|
||||
is_ground_content = false,
|
||||
light_propagates = false,
|
||||
sunlight_propagates = false,
|
||||
walkable = true,
|
||||
pointable = true,
|
||||
@@ -133,7 +132,6 @@ minetest.register_nodedef_defaults({
|
||||
minetest.register_node("air", {
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
light_propagates = true,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
@@ -145,7 +143,6 @@ minetest.register_node("air", {
|
||||
minetest.register_node("ignore", {
|
||||
drawtype = "airlike",
|
||||
paramtype = "none",
|
||||
light_propagates = false,
|
||||
sunlight_propagates = false,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
@@ -304,7 +301,7 @@ end
|
||||
test_stackstring()
|
||||
|
||||
--
|
||||
-- nodeitem helpers
|
||||
-- NodeItem helpers
|
||||
--
|
||||
|
||||
minetest.inventorycube = function(img1, img2, img3)
|
||||
@@ -317,7 +314,7 @@ minetest.inventorycube = function(img1, img2, img3)
|
||||
end
|
||||
|
||||
--
|
||||
-- craftitem helpers
|
||||
-- CraftItem helpers
|
||||
--
|
||||
|
||||
minetest.craftitem_place_item = function(item, placer, pos)
|
||||
@@ -340,6 +337,77 @@ minetest.craftitem_eat = function(hp_change)
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Default material types
|
||||
--
|
||||
|
||||
function minetest.digprop_constanttime(time)
|
||||
return {
|
||||
diggability = "constant",
|
||||
constant_time = time,
|
||||
}
|
||||
end
|
||||
|
||||
function minetest.digprop_stonelike(toughness)
|
||||
return {
|
||||
diggablity = "normal",
|
||||
weight = toughness * 5,
|
||||
crackiness = 1,
|
||||
crumbliness = -0.1,
|
||||
cuttability = -0.2,
|
||||
}
|
||||
end
|
||||
|
||||
function minetest.digprop_dirtlike(toughness)
|
||||
return {
|
||||
diggablity = "normal",
|
||||
weight = toughness * 1.2,
|
||||
crackiness = 0,
|
||||
crumbliness = 1.2,
|
||||
cuttability = -0.4,
|
||||
}
|
||||
end
|
||||
|
||||
function minetest.digprop_gravellike(toughness)
|
||||
return {
|
||||
diggablity = "normal",
|
||||
weight = toughness * 2,
|
||||
crackiness = 0.2,
|
||||
crumbliness = 1.5,
|
||||
cuttability = -1.0,
|
||||
}
|
||||
end
|
||||
|
||||
function minetest.digprop_woodlike(toughness)
|
||||
return {
|
||||
diggablity = "normal",
|
||||
weight = toughness * 1.0,
|
||||
crackiness = 0.75,
|
||||
crumbliness = -1.0,
|
||||
cuttability = 1.5,
|
||||
}
|
||||
end
|
||||
|
||||
function minetest.digprop_leaveslike(toughness)
|
||||
return {
|
||||
diggablity = "normal",
|
||||
weight = toughness * (-0.5),
|
||||
crackiness = 0,
|
||||
crumbliness = 0,
|
||||
cuttability = 2.0,
|
||||
}
|
||||
end
|
||||
|
||||
function minetest.digprop_glasslike(toughness)
|
||||
return {
|
||||
diggablity = "normal",
|
||||
weight = toughness * 0.1,
|
||||
crackiness = 2.0,
|
||||
crumbliness = -1.0,
|
||||
cuttability = -1.0,
|
||||
}
|
||||
end
|
||||
|
||||
--
|
||||
-- Creative inventory
|
||||
--
|
||||
@@ -367,6 +435,7 @@ minetest.registered_on_dignodes, minetest.register_on_dignode = make_registratio
|
||||
minetest.registered_on_punchnodes, minetest.register_on_punchnode = make_registration()
|
||||
minetest.registered_on_generateds, minetest.register_on_generated = make_registration()
|
||||
minetest.registered_on_newplayers, minetest.register_on_newplayer = make_registration()
|
||||
minetest.registered_on_dieplayers, minetest.register_on_dieplayer = make_registration()
|
||||
minetest.registered_on_respawnplayers, minetest.register_on_respawnplayer = make_registration()
|
||||
|
||||
-- END
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
-- bucket (Minetest 0.4 mod)
|
||||
-- A bucket, which can pick up water and lava
|
||||
|
||||
minetest.alias_craftitem("bucket", "bucket:bucket_empty")
|
||||
minetest.alias_craftitem("bucket_water", "bucket:bucket_water")
|
||||
minetest.alias_craftitem("bucket_lava", "bucket:bucket_lava")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'craft "bucket:bucket_empty" 1',
|
||||
recipe = {
|
||||
@@ -14,11 +21,11 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
||||
on_use = function(item, player, pointed_thing)
|
||||
if pointed_thing.type == "node" then
|
||||
n = minetest.env:get_node(pointed_thing.under)
|
||||
if n.name == "water_source" then
|
||||
if n.name == "default:water_source" then
|
||||
minetest.env:add_node(pointed_thing.under, {name="air"})
|
||||
player:add_to_inventory_later('craft "bucket:bucket_water" 1')
|
||||
return true
|
||||
elseif n.name == "lava_source" then
|
||||
elseif n.name == "default:lava_source" then
|
||||
minetest.env:add_node(pointed_thing.under, {name="air"})
|
||||
player:add_to_inventory_later('craft "bucket:bucket_lava" 1')
|
||||
return true
|
||||
@@ -29,19 +36,19 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
||||
})
|
||||
|
||||
minetest.register_craftitem("bucket:bucket_water", {
|
||||
image = "bucket:bucket_water.png",
|
||||
image = "bucket_water.png",
|
||||
stack_max = 1,
|
||||
liquids_pointable = true,
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
on_use = function(item, player, pointed_thing)
|
||||
if pointed_thing.type == "node" then
|
||||
n = minetest.env:get_node(pointed_thing.under)
|
||||
if n.name == "water_source" then
|
||||
if n.name == "default:water_source" then
|
||||
-- unchanged
|
||||
elseif n.name == "water_flowing" or n.name == "lava_source" or n.name == "lava_flowing" then
|
||||
minetest.env:add_node(pointed_thing.under, {name="water_source"})
|
||||
elseif n.name == "default:water_flowing" or n.name == "default:lava_source" or n.name == "default:lava_flowing" then
|
||||
minetest.env:add_node(pointed_thing.under, {name="default:water_source"})
|
||||
else
|
||||
minetest.env:add_node(pointed_thing.above, {name="water_source"})
|
||||
minetest.env:add_node(pointed_thing.above, {name="default:water_source"})
|
||||
end
|
||||
player:add_to_inventory_later('craft "bucket:bucket_empty" 1')
|
||||
return true
|
||||
@@ -51,19 +58,19 @@ minetest.register_craftitem("bucket:bucket_water", {
|
||||
})
|
||||
|
||||
minetest.register_craftitem("bucket:bucket_lava", {
|
||||
image = "bucket:bucket_lava.png",
|
||||
image = "bucket_lava.png",
|
||||
stack_max = 1,
|
||||
liquids_pointable = true,
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
on_use = function(item, player, pointed_thing)
|
||||
if pointed_thing.type == "node" then
|
||||
n = minetest.env:get_node(pointed_thing.under)
|
||||
if n.name == "lava_source" then
|
||||
if n.name == "default:lava_source" then
|
||||
-- unchanged
|
||||
elseif n.name == "water_source" or n.name == "water_flowing" or n.name == "lava_flowing" then
|
||||
minetest.env:add_node(pointed_thing.under, {name="lava_source"})
|
||||
elseif n.name == "default:water_source" or n.name == "default:water_flowing" or n.name == "default:lava_flowing" then
|
||||
minetest.env:add_node(pointed_thing.under, {name="default:lava_source"})
|
||||
else
|
||||
minetest.env:add_node(pointed_thing.above, {name="lava_source"})
|
||||
minetest.env:add_node(pointed_thing.above, {name="default:lava_source"})
|
||||
end
|
||||
player:add_to_inventory_later('craft "bucket:bucket_empty" 1')
|
||||
return true
|
||||
|
||||
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
|
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 292 B |
|
Before Width: | Height: | Size: 597 B After Width: | Height: | Size: 597 B |
|
Before Width: | Height: | Size: 604 B After Width: | Height: | Size: 604 B |
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 167 B |
|
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 224 B |
|
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 151 B |
|
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 142 B |
|
Before Width: | Height: | Size: 613 B After Width: | Height: | Size: 613 B |
|
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 249 B |
|
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 210 B |
|
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 118 B |
|
Before Width: | Height: | Size: 933 B After Width: | Height: | Size: 933 B |
|
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 830 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 539 B After Width: | Height: | Size: 539 B |
|
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 978 B After Width: | Height: | Size: 978 B |
|
Before Width: | Height: | Size: 874 B After Width: | Height: | Size: 874 B |
|
Before Width: | Height: | Size: 856 B After Width: | Height: | Size: 856 B |
|
Before Width: | Height: | Size: 878 B After Width: | Height: | Size: 878 B |
|
Before Width: | Height: | Size: 591 B After Width: | Height: | Size: 591 B |
|
Before Width: | Height: | Size: 936 B After Width: | Height: | Size: 936 B |
|
Before Width: | Height: | Size: 672 B After Width: | Height: | Size: 672 B |
|
Before Width: | Height: | Size: 502 B After Width: | Height: | Size: 502 B |
|
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 507 B |
|
Before Width: | Height: | Size: 395 B After Width: | Height: | Size: 395 B |
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 357 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
|
Before Width: | Height: | Size: 965 B After Width: | Height: | Size: 965 B |
|
Before Width: | Height: | Size: 303 B After Width: | Height: | Size: 303 B |
|
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 410 B |
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
|
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 260 B |
|
Before Width: | Height: | Size: 242 B After Width: | Height: | Size: 242 B |
|
Before Width: | Height: | Size: 366 B After Width: | Height: | Size: 366 B |
|
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 507 B |
|
Before Width: | Height: | Size: 555 B After Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 545 B |
|
Before Width: | Height: | Size: 542 B After Width: | Height: | Size: 542 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 772 B After Width: | Height: | Size: 772 B |
|
Before Width: | Height: | Size: 502 B After Width: | Height: | Size: 502 B |
|
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 489 B |
|
Before Width: | Height: | Size: 219 B After Width: | Height: | Size: 219 B |
|
Before Width: | Height: | Size: 207 B After Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 182 B |
|
Before Width: | Height: | Size: 806 B After Width: | Height: | Size: 806 B |
|
Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 161 B |
|
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 186 B |
|
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 264 B |
|
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 252 B |
|
Before Width: | Height: | Size: 927 B After Width: | Height: | Size: 927 B |
|
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 271 B |
|
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 216 B |
|
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 291 B |
|
Before Width: | Height: | Size: 931 B After Width: | Height: | Size: 931 B |
|
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 262 B |
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
|
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
|
Before Width: | Height: | Size: 927 B After Width: | Height: | Size: 927 B |
|
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 245 B |
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
|
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 255 B |
|
Before Width: | Height: | Size: 925 B After Width: | Height: | Size: 925 B |
|
Before Width: | Height: | Size: 913 B After Width: | Height: | Size: 913 B |
|
Before Width: | Height: | Size: 917 B After Width: | Height: | Size: 917 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 518 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -2,29 +2,46 @@
|
||||
-- Experimental things
|
||||
--
|
||||
|
||||
-- For testing random stuff
|
||||
|
||||
function on_step(dtime)
|
||||
-- print("experimental on_step")
|
||||
--[[
|
||||
objs = minetest.env:get_objects_inside_radius({x=0,y=0,z=0}, 10)
|
||||
for k, obj in pairs(objs) do
|
||||
name = obj:get_player_name()
|
||||
if name then
|
||||
print(name.." at "..dump(obj:getpos()))
|
||||
print(name.." dir: "..dump(obj:get_look_dir()))
|
||||
print(name.." pitch: "..dump(obj:get_look_pitch()))
|
||||
print(name.." yaw: "..dump(obj:get_look_yaw()))
|
||||
else
|
||||
print("Some object at "..dump(obj:getpos()))
|
||||
end
|
||||
end
|
||||
--]]
|
||||
end
|
||||
minetest.register_globalstep(on_step)
|
||||
|
||||
-- An example furnace-thing implemented in Lua
|
||||
|
||||
minetest.register_node("experimental:luafurnace", {
|
||||
tile_images = {"lava.png", "furnace_side.png", "furnace_side.png",
|
||||
"furnace_side.png", "furnace_side.png", "furnace_front.png"},
|
||||
tile_images = {"default_lava.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png", "default_furnace_front.png"},
|
||||
--inventory_image = "furnace_front.png",
|
||||
inventory_image = minetest.inventorycube("furnace_front.png"),
|
||||
inventory_image = minetest.inventorycube("default_furnace_front.png"),
|
||||
paramtype = "facedir_simple",
|
||||
metadata_name = "generic",
|
||||
material = digprop_stonelike(3.0),
|
||||
material = minetest.digprop_stonelike(3.0),
|
||||
})
|
||||
|
||||
minetest.register_on_placenode(function(pos, newnode, placer)
|
||||
if newnode.name == "experimental:luafurnace" then
|
||||
print("get_meta");
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
print("inventory_set_list");
|
||||
meta:inventory_set_list("fuel", {""})
|
||||
print("inventory_set_list");
|
||||
meta:inventory_set_list("src", {""})
|
||||
print("inventory_set_list");
|
||||
meta:inventory_set_list("dst", {"","","",""})
|
||||
print("set_inventory_draw_spec");
|
||||
meta:set_inventory_draw_spec(
|
||||
"invsize[8,9;]"
|
||||
.."list[current_name;fuel;2,3;1,1;]"
|
||||
@@ -34,13 +51,132 @@ minetest.register_on_placenode(function(pos, newnode, placer)
|
||||
)
|
||||
|
||||
local total_cooked = 0;
|
||||
print("set_string")
|
||||
meta:set_string("total_cooked", total_cooked)
|
||||
print("set_infotext");
|
||||
meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
|
||||
end
|
||||
end)
|
||||
|
||||
local get_item_definition = function(item)
|
||||
if not item then return nil end
|
||||
if item.type == "node" then
|
||||
return minetest.registered_nodes[item.name]
|
||||
elseif item.type == "craft" then
|
||||
return minetest.registered_craftitems[item.name]
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"experimental:luafurnace"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
for i, name in ipairs({
|
||||
"fuel_totaltime",
|
||||
"fuel_time",
|
||||
"src_totaltime",
|
||||
"src_time"
|
||||
}) do
|
||||
if not meta:get_string(name) then
|
||||
meta:set_string(name, 0)
|
||||
end
|
||||
end
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
local fuelitem = inv:get_stack("fuel", 1):peek_item()
|
||||
local srcitem = inv:get_stack("src", 1):peek_item()
|
||||
--print("fuelitem="..dump(fuelitem))
|
||||
--print("srcitem="..dump(srcitem))
|
||||
|
||||
local was_active = false
|
||||
|
||||
local src_cooktime = -1
|
||||
local result_stackstring = nil
|
||||
|
||||
if srcitem then
|
||||
local prop = get_item_definition(srcitem)
|
||||
if prop and prop.cookresult_itemstring ~= "" then
|
||||
result_stackstring = prop.cookresult_itemstring
|
||||
src_cooktime = prop.furnace_cooktime or 3
|
||||
end
|
||||
end
|
||||
|
||||
print("src_cooktime="..dump(src_cooktime))
|
||||
print("result_stackstring="..dump(result_stackstring))
|
||||
|
||||
if tonumber(meta:get_string("fuel_time")) < tonumber(meta:get_string("fuel_totaltime")) then
|
||||
was_active = true
|
||||
meta:set_string("fuel_time", tonumber(meta:get_string("fuel_time")) + 1)
|
||||
meta:set_string("src_time", tonumber(meta:get_string("src_time")) + 1)
|
||||
--print("result_stackstring="..dump(result_stackstring))
|
||||
--print('tonumber(meta:get_string("src_time"))='..dump(tonumber(meta:get_string("src_time"))))
|
||||
--print("src_cooktime="..dump(src_cooktime))
|
||||
if result_stackstring and tonumber(meta:get_string("src_time")) >= src_cooktime and src_cooktime >= 0 then
|
||||
-- Put result in "dst" list
|
||||
success = inv:autoinsert_stackstring("dst", result_stackstring)
|
||||
if not success then
|
||||
print("Could not autoinsert '"..result_stackstring.."'")
|
||||
end
|
||||
-- If succeeded, take stuff from "src" list
|
||||
if success then
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack:take_item()
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
end
|
||||
meta:set_string("src_time", 0)
|
||||
end
|
||||
end
|
||||
|
||||
if tonumber(meta:get_string("fuel_time")) < tonumber(meta:get_string("fuel_totaltime")) then
|
||||
meta:set_infotext("Furnace active: "..(tonumber(meta:get_string("fuel_time"))/tonumber(meta:get_string("fuel_totaltime"))*100).."%")
|
||||
return
|
||||
end
|
||||
|
||||
local srcitem = inv:get_stack("src", 1):peek_item()
|
||||
|
||||
local src_cooktime = 0
|
||||
local result_stackstring = nil
|
||||
|
||||
if srcitem then
|
||||
local prop = get_item_definition(srcitem)
|
||||
if prop and prop.cookresult_itemstring ~= "" then
|
||||
result_stackstring = prop.cookresult_itemstring
|
||||
src_cooktime = prop.furnace_cooktime or 3
|
||||
end
|
||||
end
|
||||
|
||||
local fuelitem = inv:get_stack("fuel", 1):peek_item()
|
||||
|
||||
if not result_stackstring or not fuelitem then
|
||||
if was_active then
|
||||
meta:set_infotext("Furnace is empty")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local burntime = -1
|
||||
if fuelitem then
|
||||
local prop = get_item_definition(fuelitem)
|
||||
if prop then
|
||||
burntime = prop.furnace_burntime or -1
|
||||
end
|
||||
end
|
||||
|
||||
if burntime <= 0 then
|
||||
meta:set_infotext("Furnace out of fuel")
|
||||
return
|
||||
end
|
||||
|
||||
meta:set_string("fuel_totaltime", burntime)
|
||||
meta:set_string("fuel_time", 0)
|
||||
|
||||
local stack = inv:get_stack("fuel", 1)
|
||||
stack:take_item()
|
||||
inv:set_stack("fuel", 1, stack)
|
||||
end,
|
||||
})
|
||||
--[[
|
||||
minetest.register_abm({
|
||||
nodenames = {"experimental:luafurnace"},
|
||||
interval = 1.0,
|
||||
@@ -95,13 +231,13 @@ minetest.register_abm({
|
||||
meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
|
||||
end,
|
||||
})
|
||||
|
||||
--]]
|
||||
minetest.register_craft({
|
||||
output = 'node "experimental:luafurnace" 1',
|
||||
recipe = {
|
||||
{'node "cobble"', 'node "cobble"', 'node "cobble"'},
|
||||
{'node "cobble"', 'node "cobble"', 'node "cobble"'},
|
||||
{'node "cobble"', 'node "cobble"', 'node "cobble"'},
|
||||
{'node "default:cobble"', 'node "default:cobble"', 'node "default:cobble"'},
|
||||
{'node "default:cobble"', 'node "default:steel_ingot"', 'node "default:cobble"'},
|
||||
{'node "default:cobble"', 'node "default:cobble"', 'node "default:cobble"'},
|
||||
}
|
||||
})
|
||||
|
||||
@@ -110,8 +246,8 @@ minetest.register_craft({
|
||||
--
|
||||
|
||||
--[[
|
||||
minetest.register_tool("horribletool", {
|
||||
image = "lava.png",
|
||||
minetest.register_tool("experimental:horribletool", {
|
||||
image = "default_lava.png",
|
||||
basetime = 2.0
|
||||
dt_weight = 0.2
|
||||
dt_crackiness = 0.2
|
||||
@@ -125,10 +261,10 @@ minetest.register_tool("horribletool", {
|
||||
})
|
||||
--]]
|
||||
|
||||
minetest.register_craft({
|
||||
--[[minetest.register_craft({
|
||||
output = 'node "somenode" 4',
|
||||
recipe = {
|
||||
{'craft "Stick" 1'},
|
||||
{'craft "default_tick" 1'},
|
||||
}
|
||||
})
|
||||
|
||||
@@ -145,7 +281,7 @@ minetest.register_node("experimental:somenode", {
|
||||
flammability = 0
|
||||
},
|
||||
metadata_name = "chest",
|
||||
})
|
||||
})]]
|
||||
|
||||
--
|
||||
-- TNT (not functional)
|
||||
@@ -154,15 +290,18 @@ minetest.register_node("experimental:somenode", {
|
||||
minetest.register_craft({
|
||||
output = 'node "experimental:tnt" 4',
|
||||
recipe = {
|
||||
{'node "wood" 1'},
|
||||
{'craft "lump_of_coal" 1'},
|
||||
{'node "wood" 1'}
|
||||
{'node "default:wood" 1'},
|
||||
{'craft "default:coal_lump" 1'},
|
||||
{'node "default:wood" 1'}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("experimental:tnt", {
|
||||
tile_images = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png", "tnt_side.png", "tnt_side.png", "tnt_side.png"},
|
||||
inventory_image = "tnt_side.png",
|
||||
tile_images = {"default_tnt_top.png", "default_tnt_bottom.png",
|
||||
"default_tnt_side.png", "default_tnt_side.png",
|
||||
"default_tnt_side.png", "default_tnt_side.png"},
|
||||
inventory_image = minetest.inventorycube("default_tnt_top.png",
|
||||
"default_tnt_side.png", "default_tnt_side.png"),
|
||||
dug_item = '', -- Get nothing
|
||||
material = {
|
||||
diggability = "not",
|
||||
@@ -172,7 +311,7 @@ minetest.register_node("experimental:tnt", {
|
||||
minetest.register_on_punchnode(function(p, node)
|
||||
if node.name == "experimental:tnt" then
|
||||
minetest.env:remove_node(p)
|
||||
minetest.env:add_luaentity(p, "experimental:tnt")
|
||||
minetest.env:add_entity(p, "experimental:tnt")
|
||||
nodeupdate(p)
|
||||
end
|
||||
end)
|
||||
@@ -183,7 +322,9 @@ local TNT = {
|
||||
-- weight = 5,
|
||||
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
||||
visual = "cube",
|
||||
textures = {"tnt_top.png","tnt_bottom.png","tnt_side.png","tnt_side.png","tnt_side.png","tnt_side.png"},
|
||||
textures = {"default_tnt_top.png", "default_tnt_bottom.png",
|
||||
"default_tnt_side.png", "default_tnt_side.png",
|
||||
"default_tnt_side.png", "default_tnt_side.png"},
|
||||
-- Initial value for our timer
|
||||
timer = 0,
|
||||
-- Number of punches required to defuse
|
||||
@@ -238,6 +379,9 @@ end
|
||||
--print("Registering TNT");
|
||||
minetest.register_entity("experimental:tnt", TNT)
|
||||
|
||||
-- Add TNT's old name also
|
||||
minetest.alias_node("TNT", "experimental:tnt")
|
||||
|
||||
--
|
||||
-- A test entity for testing animated and yaw-modulated sprites
|
||||
--
|
||||
@@ -288,8 +432,8 @@ minetest.register_on_generated(function(minp, maxp)
|
||||
end)
|
||||
|
||||
-- Example setting get
|
||||
print("setting max_users = " .. dump(minetest.setting_get("max_users")))
|
||||
print("setting asdf = " .. dump(minetest.setting_get("asdf")))
|
||||
--print("setting max_users = " .. dump(minetest.setting_get("max_users")))
|
||||
--print("setting asdf = " .. dump(minetest.setting_get("asdf")))
|
||||
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
--[[print("on_chat_message: name="..dump(name).." message="..dump(message))
|
||||
@@ -403,4 +547,6 @@ minetest.register_abm({
|
||||
end,
|
||||
})--]]
|
||||
|
||||
print("experimental modpath="..dump(minetest.get_modpath("experimental")))
|
||||
|
||||
-- END
|
||||
|
||||
2
data/mods/legacy/depends.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
default
|
||||
|
||||
101
data/mods/legacy/init.lua
Normal file
@@ -0,0 +1,101 @@
|
||||
-- legacy (Minetest 0.4 mod)
|
||||
-- Provides as much backwards-compatibility as feasible
|
||||
|
||||
--
|
||||
-- Aliases to support loading 0.3 and old 0.4 worlds and inventories
|
||||
--
|
||||
|
||||
minetest.alias_node("stone", "default:stone")
|
||||
minetest.alias_node("dirt_with_grass", "default:dirt_with_grass")
|
||||
minetest.alias_node("dirt_with_grass_footsteps", "default:dirt_with_grass_footsteps")
|
||||
minetest.alias_node("dirt", "default:dirt")
|
||||
minetest.alias_node("sand", "default:sand")
|
||||
minetest.alias_node("gravel", "default:gravel")
|
||||
minetest.alias_node("sandstone", "default:sandstone")
|
||||
minetest.alias_node("clay", "default:clay")
|
||||
minetest.alias_node("brick", "default:brick")
|
||||
minetest.alias_node("tree", "default:tree")
|
||||
minetest.alias_node("jungletree", "default:jungletree")
|
||||
minetest.alias_node("junglegrass", "default:junglegrass")
|
||||
minetest.alias_node("leaves", "default:leaves")
|
||||
minetest.alias_node("cactus", "default:cactus")
|
||||
minetest.alias_node("papyrus", "default:papyrus")
|
||||
minetest.alias_node("bookshelf", "default:bookshelf")
|
||||
minetest.alias_node("glass", "default:glass")
|
||||
minetest.alias_node("wooden_fence", "default:fence_wood")
|
||||
minetest.alias_node("rail", "default:rail")
|
||||
minetest.alias_node("ladder", "default:ladder")
|
||||
minetest.alias_node("wood", "default:wood")
|
||||
minetest.alias_node("mese", "default:mese")
|
||||
minetest.alias_node("cloud", "default:cloud")
|
||||
minetest.alias_node("water_flowing", "default:water_flowing")
|
||||
minetest.alias_node("water_source", "default:water_source")
|
||||
minetest.alias_node("lava_flowing", "default:lava_flowing")
|
||||
minetest.alias_node("lava_source", "default:lava_source")
|
||||
minetest.alias_node("torch", "default:torch")
|
||||
minetest.alias_node("sign_wall", "default:sign_wall")
|
||||
minetest.alias_node("furnace", "default:furnace")
|
||||
minetest.alias_node("chest", "default:chest")
|
||||
minetest.alias_node("locked_chest", "default:chest_locked")
|
||||
minetest.alias_node("cobble", "default:cobble")
|
||||
minetest.alias_node("mossycobble", "default:mossycobble")
|
||||
minetest.alias_node("steelblock", "default:steelblock")
|
||||
minetest.alias_node("nyancat", "default:nyancat")
|
||||
minetest.alias_node("nyancat_rainbow", "default:nyancat_rainbow")
|
||||
minetest.alias_node("sapling", "default:sapling")
|
||||
minetest.alias_node("apple", "default:apple")
|
||||
|
||||
minetest.alias_tool("WPick", "default:pick_wood")
|
||||
minetest.alias_tool("STPick", "default:pick_stone")
|
||||
minetest.alias_tool("SteelPick", "default:pick_steel")
|
||||
minetest.alias_tool("MesePick", "default:pick_mese")
|
||||
minetest.alias_tool("WShovel", "default:shovel_wood")
|
||||
minetest.alias_tool("STShovel", "default:shovel_stone")
|
||||
minetest.alias_tool("SteelShovel", "default:shovel_steel")
|
||||
minetest.alias_tool("WAxe", "default:axe_wood")
|
||||
minetest.alias_tool("STAxe", "default:axe_stone")
|
||||
minetest.alias_tool("SteelAxe", "default:axe_steel")
|
||||
minetest.alias_tool("WSword", "default:sword_wood")
|
||||
minetest.alias_tool("STSword", "default:sword_stone")
|
||||
minetest.alias_tool("SteelSword", "default:sword_steel")
|
||||
|
||||
minetest.alias_craftitem("Stick", "default:stick")
|
||||
minetest.alias_craftitem("paper", "default:paper")
|
||||
minetest.alias_craftitem("book", "default:book")
|
||||
minetest.alias_craftitem("lump_of_coal", "default:coal_lump")
|
||||
minetest.alias_craftitem("lump_of_iron", "default:iron_lump")
|
||||
minetest.alias_craftitem("lump_of_clay", "default:clay_lump")
|
||||
minetest.alias_craftitem("steel_ingot", "default:steel_ingot")
|
||||
minetest.alias_craftitem("clay_brick", "default:clay_brick")
|
||||
minetest.alias_craftitem("scorched_stuff", "default:scorched_stuff")
|
||||
minetest.alias_craftitem("apple", "default:apple")
|
||||
|
||||
--
|
||||
-- Old items
|
||||
--
|
||||
|
||||
minetest.register_craftitem(":rat", {
|
||||
image = "rat.png",
|
||||
cookresult_itemstring = 'craft "cooked_rat" 1',
|
||||
on_drop = function(item, dropper, pos)
|
||||
minetest.env:add_rat(pos)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":cooked_rat", {
|
||||
image = "cooked_rat.png",
|
||||
cookresult_itemstring = 'craft "scorched_stuff" 1',
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
on_use = minetest.craftitem_eat(6),
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":firefly", {
|
||||
image = "firefly.png",
|
||||
on_drop = function(item, dropper, pos)
|
||||
minetest.env:add_firefly(pos)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
-- END
|
||||
|
Before Width: | Height: | Size: 207 B After Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 239 B |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 603 B After Width: | Height: | Size: 603 B |
|
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 952 B After Width: | Height: | Size: 952 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 250 B After Width: | Height: | Size: 250 B |
|
Before Width: | Height: | Size: 341 B After Width: | Height: | Size: 341 B |
|
Before Width: | Height: | Size: 920 B After Width: | Height: | Size: 920 B |
@@ -94,6 +94,7 @@ configure_file(
|
||||
)
|
||||
|
||||
set(common_SRCS
|
||||
inventorymanager.cpp
|
||||
mods.cpp
|
||||
serverremoteplayer.cpp
|
||||
content_abm.cpp
|
||||
@@ -158,7 +159,6 @@ endif()
|
||||
# Client sources
|
||||
set(minetest_SRCS
|
||||
${common_SRCS}
|
||||
MyBillboardSceneNode.cpp
|
||||
content_mapblock.cpp
|
||||
content_cao.cpp
|
||||
mesh.cpp
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
// Copyright (C) 2002-2010 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "MyBillboardSceneNode.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "ISceneManager.h"
|
||||
#include "ICameraSceneNode.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! constructor
|
||||
MyBillboardSceneNode::MyBillboardSceneNode(ISceneNode* parent,
|
||||
ISceneManager* mgr, s32 id,
|
||||
const core::vector3df& position, const core::dimension2d<f32>& size)
|
||||
: IBillboardSceneNode(parent, mgr, id, position)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("MyBillboardSceneNode");
|
||||
#endif
|
||||
|
||||
setSize(size);
|
||||
|
||||
indices[0] = 0;
|
||||
indices[1] = 2;
|
||||
indices[2] = 1;
|
||||
indices[3] = 0;
|
||||
indices[4] = 3;
|
||||
indices[5] = 2;
|
||||
|
||||
video::SColor colorTop = video::SColor(0xFFFFFFFF);
|
||||
video::SColor colorBottom = video::SColor(0xFFFFFFFF);
|
||||
|
||||
vertices[0].TCoords.set(1.0f, 1.0f);
|
||||
vertices[0].Color = colorBottom;
|
||||
|
||||
vertices[1].TCoords.set(1.0f, 0.0f);
|
||||
vertices[1].Color = colorTop;
|
||||
|
||||
vertices[2].TCoords.set(0.0f, 0.0f);
|
||||
vertices[2].Color = colorTop;
|
||||
|
||||
vertices[3].TCoords.set(0.0f, 1.0f);
|
||||
vertices[3].Color = colorBottom;
|
||||
}
|
||||
|
||||
|
||||
//! pre render event
|
||||
void MyBillboardSceneNode::OnRegisterSceneNode()
|
||||
{
|
||||
if (IsVisible)
|
||||
SceneManager->registerNodeForRendering(this);
|
||||
|
||||
ISceneNode::OnRegisterSceneNode();
|
||||
}
|
||||
|
||||
|
||||
//! render
|
||||
void MyBillboardSceneNode::render()
|
||||
{
|
||||
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||
ICameraSceneNode* camera = SceneManager->getActiveCamera();
|
||||
|
||||
if (!camera || !driver)
|
||||
return;
|
||||
|
||||
// make billboard look to camera
|
||||
|
||||
core::vector3df pos = getAbsolutePosition();
|
||||
|
||||
core::vector3df campos = camera->getAbsolutePosition();
|
||||
core::vector3df target = camera->getTarget();
|
||||
core::vector3df up = camera->getUpVector();
|
||||
core::vector3df view = target - campos;
|
||||
view.normalize();
|
||||
|
||||
core::vector3df horizontal = up.crossProduct(view);
|
||||
if ( horizontal.getLength() == 0 )
|
||||
{
|
||||
horizontal.set(up.Y,up.X,up.Z);
|
||||
}
|
||||
horizontal.normalize();
|
||||
horizontal *= 0.5f * Size.Width;
|
||||
|
||||
core::vector3df vertical = horizontal.crossProduct(view);
|
||||
vertical.normalize();
|
||||
vertical *= 0.5f * Size.Height;
|
||||
|
||||
view *= -1.0f;
|
||||
|
||||
for (s32 i=0; i<4; ++i)
|
||||
vertices[i].Normal = view;
|
||||
|
||||
vertices[0].Pos = pos + horizontal + vertical;
|
||||
vertices[1].Pos = pos + horizontal - vertical;
|
||||
vertices[2].Pos = pos - horizontal - vertical;
|
||||
vertices[3].Pos = pos - horizontal + vertical;
|
||||
|
||||
// draw
|
||||
|
||||
if ( DebugDataVisible & scene::EDS_BBOX )
|
||||
{
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
video::SMaterial m;
|
||||
m.Lighting = false;
|
||||
driver->setMaterial(m);
|
||||
driver->draw3DBox(BBox, video::SColor(0,208,195,152));
|
||||
}
|
||||
|
||||
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
|
||||
|
||||
driver->setMaterial(Material);
|
||||
|
||||
driver->drawIndexedTriangleList(vertices, 4, indices, 2);
|
||||
}
|
||||
|
||||
|
||||
//! returns the axis aligned bounding box of this node
|
||||
const core::aabbox3d<f32>& MyBillboardSceneNode::getBoundingBox() const
|
||||
{
|
||||
return BBox;
|
||||
}
|
||||
|
||||
|
||||
//! sets the size of the billboard
|
||||
void MyBillboardSceneNode::setSize(const core::dimension2d<f32>& size)
|
||||
{
|
||||
Size = size;
|
||||
|
||||
if (Size.Width == 0.0f)
|
||||
Size.Width = 1.0f;
|
||||
|
||||
if (Size.Height == 0.0f )
|
||||
Size.Height = 1.0f;
|
||||
|
||||
f32 avg = (size.Width + size.Height)/6;
|
||||
BBox.MinEdge.set(-avg,-avg,-avg);
|
||||
BBox.MaxEdge.set(avg,avg,avg);
|
||||
}
|
||||
|
||||
|
||||
video::SMaterial& MyBillboardSceneNode::getMaterial(u32 i)
|
||||
{
|
||||
return Material;
|
||||
}
|
||||
|
||||
|
||||
//! returns amount of materials used by this scene node.
|
||||
u32 MyBillboardSceneNode::getMaterialCount() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//! gets the size of the billboard
|
||||
const core::dimension2d<f32>& MyBillboardSceneNode::getSize() const
|
||||
{
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
||||
//! Set the color of all vertices of the billboard
|
||||
//! \param overallColor: the color to set
|
||||
void MyBillboardSceneNode::setColor(const video::SColor & overallColor)
|
||||
{
|
||||
for(u32 vertex = 0; vertex < 4; ++vertex)
|
||||
vertices[vertex].Color = overallColor;
|
||||
}
|
||||
|
||||
|
||||
//! Set the color of the top and bottom vertices of the billboard
|
||||
//! \param topColor: the color to set the top vertices
|
||||
//! \param bottomColor: the color to set the bottom vertices
|
||||
void MyBillboardSceneNode::setColor(const video::SColor & topColor, const video::SColor & bottomColor)
|
||||
{
|
||||
vertices[0].Color = bottomColor;
|
||||
vertices[1].Color = topColor;
|
||||
vertices[2].Color = topColor;
|
||||
vertices[3].Color = bottomColor;
|
||||
}
|
||||
|
||||
|
||||
//! Gets the color of the top and bottom vertices of the billboard
|
||||
//! \param[out] topColor: stores the color of the top vertices
|
||||
//! \param[out] bottomColor: stores the color of the bottom vertices
|
||||
void MyBillboardSceneNode::getColor(video::SColor & topColor, video::SColor & bottomColor) const
|
||||
{
|
||||
bottomColor = vertices[0].Color;
|
||||
topColor = vertices[1].Color;
|
||||
}
|
||||
|
||||
void MyBillboardSceneNode::setTCoords(u32 i, core::vector2d<f32> c)
|
||||
{
|
||||
vertices[i].TCoords = c;
|
||||
}
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
// Copyright (C) 2002-2010 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_BILLBOARD_SCENE_NODE_H_INCLUDED__
|
||||
#define __C_BILLBOARD_SCENE_NODE_H_INCLUDED__
|
||||
|
||||
#include "IBillboardSceneNode.h"
|
||||
#include "S3DVertex.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
|
||||
//! Scene node which is a billboard. A billboard is like a 3d sprite: A 2d element,
|
||||
//! which always looks to the camera.
|
||||
class MyBillboardSceneNode : virtual public IBillboardSceneNode
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
MyBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
|
||||
const core::vector3df& position, const core::dimension2d<f32>& size);
|
||||
|
||||
//! pre render event
|
||||
virtual void OnRegisterSceneNode();
|
||||
|
||||
//! render
|
||||
virtual void render();
|
||||
|
||||
//! returns the axis aligned bounding box of this node
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
||||
|
||||
//! sets the size of the billboard
|
||||
virtual void setSize(const core::dimension2d<f32>& size);
|
||||
|
||||
//! gets the size of the billboard
|
||||
virtual const core::dimension2d<f32>& getSize() const;
|
||||
|
||||
virtual video::SMaterial& getMaterial(u32 i);
|
||||
|
||||
//! returns amount of materials used by this scene node.
|
||||
virtual u32 getMaterialCount() const;
|
||||
|
||||
//! Set the color of all vertices of the billboard
|
||||
//! \param overallColor: the color to set
|
||||
virtual void setColor(const video::SColor & overallColor);
|
||||
|
||||
//! Set the color of the top and bottom vertices of the billboard
|
||||
//! \param topColor: the color to set the top vertices
|
||||
//! \param bottomColor: the color to set the bottom vertices
|
||||
virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor);
|
||||
|
||||
//! Gets the color of the top and bottom vertices of the billboard
|
||||
//! \param[out] topColor: stores the color of the top vertices
|
||||
//! \param[out] bottomColor: stores the color of the bottom vertices
|
||||
virtual void getColor(video::SColor& topColor, video::SColor& bottomColor) const;
|
||||
|
||||
virtual void setTCoords(u32 i, core::vector2d<f32> c);
|
||||
|
||||
private:
|
||||
|
||||
core::dimension2d<f32> Size;
|
||||
core::aabbox3d<f32> BBox;
|
||||
video::SMaterial Material;
|
||||
|
||||
video::S3DVertex vertices[4];
|
||||
u16 indices[6];
|
||||
};
|
||||
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
223
src/client.cpp
@@ -36,6 +36,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "tooldef.h"
|
||||
#include "craftitemdef.h"
|
||||
#include <IFileSystem.h>
|
||||
#include "sha1.h"
|
||||
#include "base64.h"
|
||||
|
||||
static std::string getTextureCacheDir()
|
||||
{
|
||||
return porting::path_userdata + DIR_DELIM + "cache" + DIR_DELIM + "texture";
|
||||
}
|
||||
|
||||
struct TextureRequest
|
||||
{
|
||||
std::string name;
|
||||
|
||||
TextureRequest(const std::string &name_=""):
|
||||
name(name_)
|
||||
{}
|
||||
};
|
||||
|
||||
/*
|
||||
QueuedMeshUpdate
|
||||
@@ -1232,6 +1248,162 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
event.deathscreen.camera_point_target_z = camera_point_target.Z;
|
||||
m_client_event_queue.push_back(event);
|
||||
}
|
||||
else if(command == TOCLIENT_ANNOUNCE_TEXTURES)
|
||||
{
|
||||
io::IFileSystem *irrfs = m_device->getFileSystem();
|
||||
video::IVideoDriver *vdrv = m_device->getVideoDriver();
|
||||
|
||||
std::string datastring((char*)&data[2], datasize-2);
|
||||
std::istringstream is(datastring, std::ios_base::binary);
|
||||
|
||||
|
||||
// Stop threads while updating content definitions
|
||||
m_mesh_update_thread.setRun(false);
|
||||
// Process the remaining TextureSource queue to let MeshUpdateThread
|
||||
// get it's remaining textures and thus let it stop
|
||||
while(m_mesh_update_thread.IsRunning()){
|
||||
m_tsrc->processQueue();
|
||||
}
|
||||
|
||||
int num_textures = readU16(is);
|
||||
|
||||
core::list<TextureRequest> texture_requests;
|
||||
|
||||
for(int i=0; i<num_textures; i++){
|
||||
|
||||
bool texture_found = false;
|
||||
|
||||
//read texture from cache
|
||||
std::string name = deSerializeString(is);
|
||||
std::string sha1_texture = deSerializeString(is);
|
||||
|
||||
// if name contains illegal characters, ignore the texture
|
||||
if(!string_allowed(name, TEXTURENAME_ALLOWED_CHARS)){
|
||||
errorstream<<"Client: ignoring illegal texture name "
|
||||
<<"sent by server: \""<<name<<"\""<<std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string tpath = getTextureCacheDir() + DIR_DELIM + name;
|
||||
// Read data
|
||||
std::ifstream fis(tpath.c_str(), std::ios_base::binary);
|
||||
|
||||
|
||||
if(fis.good() == false){
|
||||
infostream<<"Client::Texture not found in cache: "
|
||||
<<name << " expected it at: "<<tpath<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream tmp_os(std::ios_base::binary);
|
||||
bool bad = false;
|
||||
for(;;){
|
||||
char buf[1024];
|
||||
fis.read(buf, 1024);
|
||||
std::streamsize len = fis.gcount();
|
||||
tmp_os.write(buf, len);
|
||||
if(fis.eof())
|
||||
break;
|
||||
if(!fis.good()){
|
||||
bad = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(bad){
|
||||
infostream<<"Client: Failed to read texture from cache\""
|
||||
<<name<<"\""<<std::endl;
|
||||
}
|
||||
else {
|
||||
|
||||
SHA1 sha1;
|
||||
sha1.addBytes(tmp_os.str().c_str(), tmp_os.str().length());
|
||||
|
||||
unsigned char *digest = sha1.getDigest();
|
||||
|
||||
std::string digest_string = base64_encode(digest, 20);
|
||||
|
||||
if (digest_string == sha1_texture) {
|
||||
// Silly irrlicht's const-incorrectness
|
||||
Buffer<char> data_rw(tmp_os.str().c_str(), tmp_os.str().size());
|
||||
|
||||
// Create an irrlicht memory file
|
||||
io::IReadFile *rfile = irrfs->createMemoryReadFile(
|
||||
*data_rw, tmp_os.str().size(), "_tempreadfile");
|
||||
assert(rfile);
|
||||
// Read image
|
||||
video::IImage *img = vdrv->createImageFromFile(rfile);
|
||||
if(!img){
|
||||
infostream<<"Client: Cannot create image from data of "
|
||||
<<"received texture \""<<name<<"\""<<std::endl;
|
||||
rfile->drop();
|
||||
}
|
||||
else {
|
||||
m_tsrc->insertSourceImage(name, img);
|
||||
img->drop();
|
||||
rfile->drop();
|
||||
|
||||
texture_found = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
infostream<<"Client::Texture cached sha1 hash not matching server hash: "
|
||||
<<name << ": server ->"<<sha1_texture <<" client -> "<<digest_string<<std::endl;
|
||||
}
|
||||
|
||||
free(digest);
|
||||
}
|
||||
}
|
||||
|
||||
//add texture request
|
||||
if (!texture_found) {
|
||||
infostream<<"Client: Adding texture to request list: \""
|
||||
<<name<<"\""<<std::endl;
|
||||
texture_requests.push_back(TextureRequest(name));
|
||||
}
|
||||
|
||||
}
|
||||
// Resume threads
|
||||
m_mesh_update_thread.setRun(true);
|
||||
m_mesh_update_thread.Start();
|
||||
|
||||
ClientEvent event;
|
||||
event.type = CE_TEXTURES_UPDATED;
|
||||
m_client_event_queue.push_back(event);
|
||||
|
||||
|
||||
//send Texture request
|
||||
/*
|
||||
u16 command
|
||||
u16 number of textures requested
|
||||
for each texture {
|
||||
u16 length of name
|
||||
string name
|
||||
}
|
||||
*/
|
||||
std::ostringstream os(std::ios_base::binary);
|
||||
u8 buf[12];
|
||||
|
||||
|
||||
// Write command
|
||||
writeU16(buf, TOSERVER_REQUEST_TEXTURES);
|
||||
os.write((char*)buf, 2);
|
||||
|
||||
writeU16(buf,texture_requests.size());
|
||||
os.write((char*)buf, 2);
|
||||
|
||||
|
||||
for(core::list<TextureRequest>::Iterator i = texture_requests.begin();
|
||||
i != texture_requests.end(); i++) {
|
||||
os<<serializeString(i->name);
|
||||
}
|
||||
|
||||
// Make data buffer
|
||||
std::string s = os.str();
|
||||
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
|
||||
// Send as reliable
|
||||
Send(0, data, true);
|
||||
infostream<<"Client: Sending request list to server " <<std::endl;
|
||||
}
|
||||
else if(command == TOCLIENT_TEXTURES)
|
||||
{
|
||||
io::IFileSystem *irrfs = m_device->getFileSystem();
|
||||
@@ -1272,6 +1444,14 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
for(int i=0; i<num_textures; i++){
|
||||
std::string name = deSerializeString(is);
|
||||
std::string data = deSerializeLongString(is);
|
||||
|
||||
// if name contains illegal characters, ignore the texture
|
||||
if(!string_allowed(name, TEXTURENAME_ALLOWED_CHARS)){
|
||||
errorstream<<"Client: ignoring illegal texture name "
|
||||
<<"sent by server: \""<<name<<"\""<<std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Silly irrlicht's const-incorrectness
|
||||
Buffer<char> data_rw(data.c_str(), data.size());
|
||||
// Create an irrlicht memory file
|
||||
@@ -1286,6 +1466,20 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
rfile->drop();
|
||||
continue;
|
||||
}
|
||||
|
||||
fs::CreateAllDirs(getTextureCacheDir());
|
||||
|
||||
std::string filename = getTextureCacheDir() + DIR_DELIM + name;
|
||||
std::ofstream outfile(filename.c_str(), std::ios_base::binary | std::ios_base::trunc);
|
||||
|
||||
if (outfile.good()) {
|
||||
outfile.write(data.c_str(),data.length());
|
||||
outfile.close();
|
||||
}
|
||||
else {
|
||||
errorstream<<"Client: Unable to open cached texture file "<< filename <<std::endl;
|
||||
}
|
||||
|
||||
m_tsrc->insertSourceImage(name, img);
|
||||
img->drop();
|
||||
rfile->drop();
|
||||
@@ -1782,6 +1976,34 @@ InventoryContext *Client::getInventoryContext()
|
||||
return &m_inventory_context;
|
||||
}
|
||||
|
||||
Inventory* Client::getInventory(const InventoryLocation &loc)
|
||||
{
|
||||
switch(loc.type){
|
||||
case InventoryLocation::UNDEFINED:
|
||||
{}
|
||||
break;
|
||||
case InventoryLocation::PLAYER:
|
||||
{
|
||||
Player *player = m_env.getPlayer(loc.name.c_str());
|
||||
if(!player)
|
||||
return NULL;
|
||||
return &player->inventory;
|
||||
}
|
||||
break;
|
||||
case InventoryLocation::NODEMETA:
|
||||
{
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(loc.p);
|
||||
if(!meta)
|
||||
return NULL;
|
||||
return meta->getInventory();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#if 0
|
||||
Inventory* Client::getInventory(InventoryContext *c, std::string id)
|
||||
{
|
||||
if(id == "current_player")
|
||||
@@ -1810,6 +2032,7 @@ Inventory* Client::getInventory(InventoryContext *c, std::string id)
|
||||
infostream<<__FUNCTION_NAME<<": unknown id "<<id<<std::endl;
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
void Client::inventoryAction(InventoryAction *a)
|
||||
{
|
||||
sendInventoryAction(a);
|
||||
|
||||
@@ -30,6 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "clientobject.h"
|
||||
#include "utility.h" // For IntervalLimiter
|
||||
#include "gamedef.h"
|
||||
#include "inventorymanager.h"
|
||||
#include "filesys.h"
|
||||
|
||||
struct MeshMakeData;
|
||||
class IGameDef;
|
||||
@@ -245,7 +247,9 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
|
||||
|
||||
InventoryContext *getInventoryContext();
|
||||
|
||||
Inventory* getInventory(InventoryContext *c, std::string id);
|
||||
/* InventoryManager interface */
|
||||
Inventory* getInventory(const InventoryLocation &loc);
|
||||
//Inventory* getInventory(InventoryContext *c, std::string id);
|
||||
void inventoryAction(InventoryAction *a);
|
||||
|
||||
// Gets closest object pointed by the shootline
|
||||
|
||||