added support for farming plus, and tidied code.

master
NathanSalapat 2016-11-12 19:29:58 -06:00
parent 3911613e3b
commit 566be67928
8 changed files with 160 additions and 103 deletions

View File

@ -4,3 +4,4 @@ vessels
hunger?
thirsty?
plantlife?
farming_plus?

View File

@ -18,6 +18,15 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = 'drinks:liquid_silo',
recipe = {
{'drinks:liquid_barrel'},
{'drinks:liquid_barrel'},
{'drinks:liquid_barrel'}
}
})
minetest.register_node('drinks:juice_press', {
description = 'Juice Press',
drawtype = 'mesh',
@ -58,7 +67,10 @@ minetest.register_node('drinks:juice_press', {
local timer = minetest.get_node_timer(pos)
local instack = inv:get_stack("src", 1)
local fruitstack = instack:get_name()
local mod, fruit = fruitstack:match("([^:]+):([^:]+)")
local mod, fruit, trash = fruitstack:match("([^:]+):([^:]+)_([^:]+)")
print (mod)
print (fruit)
print (trash)
if drinks.juiceable[fruit] then
meta:set_string('fruit', fruit)
local outstack = inv:get_stack("dst", 1)
@ -141,7 +153,7 @@ minetest.register_node('drinks:juice_press', {
local fullness = fullness + 2
meta_u:set_string('fullness', fullness)
meta_u:set_string('infotext', 'Barrel of '..fruit..' juice. '..(math.floor((fullness/128)*100))..' % full.')
meta_u:set_string('formspec', drinks.liquid_storage_formspec(fullness, 128))
meta_u:set_string('formspec', drinks.liquid_storage_formspec(fruit, fullness, 128))
if instack:get_count() >= 2 then
timer:start(4)
else
@ -191,10 +203,10 @@ function drinks.drinks_liquid_sub(liq_vol, ves_typ, ves_vol, pos)
meta:set_string('fullness', fullness)
meta:set_string('infotext', (math.floor((fullness/ves_vol)*100))..' % full of '..fruit..' juice.')
if ves_vol == 128 then
meta:set_string('formspec', drinks.liquid_storage_formspec(fullness, 128))
meta:set_string('formspec', drinks.liquid_storage_formspec(fruit, fullness, 128))
end
if ves_vol == 256 then
meta:set_string('formspec', drinks.liquid_storage_formspec(fullness, 256))
meta:set_string('formspec', drinks.liquid_storage_formspec(fruit, fullness, 256))
end
if ves_typ == 'jcu' or ves_typ == 'jbo' or ves_typ == 'jbu' then
inv:set_stack('dst', 1, 'drinks:'..ves_typ..'_'..fruit)
@ -221,10 +233,10 @@ function drinks.drinks_liquid_add(liq_vol, ves_typ, ves_vol, pos)
inv:set_stack('src', 1, ves_typ)
meta:set_string('infotext', (math.floor((fullness/ves_vol)*100))..' % full of '..fruit..' juice.')
if ves_vol == 256 then
meta:set_string('formspec', drinks.liquid_storage_formspec(fullness, 128))
meta:set_string('formspec', drinks.liquid_storage_formspec(fruit, fullness, 256))
end
if ves_vol == 128 then
meta:set_string('formspec', drinks.liquid_storage_formspec(fullness, 256))
meta:set_string('formspec', drinks.liquid_storage_formspec(fruit, fullness, 128))
end
end
end
@ -283,7 +295,7 @@ minetest.register_node('drinks:liquid_barrel', {
meta:set_string('fruit', 'empty')
meta:set_string('infotext', 'Empty Drink Barrel')
meta:set_string('formspec', 'size[8,8]'..
'label[0,0;Fill the barrel with the drink of your choice,]'..
'label[0,0;Fill with the drink of your choice,]'..
'label[0,.4;you can only add more of the same type of drink.]'..
'label[4.5,1.2;Add liquid ->]'..
'label[.75,1.75;The barrel is empty]'..
@ -332,10 +344,22 @@ minetest.register_node('drinks:liquid_barrel', {
if fields['purge'] then
local meta = minetest.env:get_meta(pos)
local fullness = 0
local fruit = 'no'
meta:set_string('fullness', 0)
meta:set_string('fruit', 'empty')
meta:set_string('infotext', 'Empty Drink Barrel')
meta:set_string('formspec', drinks.liquid_storage_formspec(fullness, 128))
meta:set_string('formspec', drinks.liquid_storage_formspec(fruit, fullness, 128))
end
end,
can_dig = function(pos)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if inv:is_empty("src") and
inv:is_empty("dst") and
tonumber(meta:get_string('fullness')) == 0 then
return true
else
return false
end
end,
})
@ -366,7 +390,7 @@ minetest.register_node('drinks:liquid_silo', {
meta:set_string('fruit', 'empty')
meta:set_string('infotext', 'Empty Drink Silo')
meta:set_string('formspec', 'size[8,8]'..
'label[0,0;Fill the silo with the drink of your choice,]'..
'label[0,0;Fill with the drink of your choice,]'..
'label[0,.4;you can only add more of the same type of drink.]'..
'label[4.5,1.2;Add liquid ->]'..
'label[.75,1.75;The Silo is empty]'..
@ -415,10 +439,22 @@ minetest.register_node('drinks:liquid_silo', {
if fields['purge'] then
local meta = minetest.env:get_meta(pos)
local fullness = 0
local fruit = 'no'
meta:set_string('fullness', 0)
meta:set_string('fruit', 'empty')
meta:set_string('infotext', 'Empty Drink Silo')
meta:set_string('formspec', drinks.liquid_storage_formspec(fullness, 256))
meta:set_string('formspec', drinks.liquid_storage_formspec(fruit, fullness, 256))
end
end,
can_dig = function(pos)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if inv:is_empty("src") and
inv:is_empty("dst") and
tonumber(meta:get_string('fullness')) == 0 then
return true
else
return false
end
end,
})

View File

@ -25,7 +25,6 @@ minetest.register_craftitem('drinks:jbo_'..desc, {
local eat_func = minetest.item_eat(.5, 'vessels:glass_bottle')
return eat_func(itemstack, user, pointed_thing)
end,
print ('registered bottle of '..desc.. ' juice.')
})
minetest.register_craftitem('drinks:jbu_'..desc, {

View File

@ -24,7 +24,6 @@ minetest.register_craftitem('drinks:jbo_'..desc, {
local eat_func = minetest.item_eat(.5, 'vessels:glass_bottle')
return eat_func(itemstack, user, pointed_thing)
end,
print ('registered bottle of '..desc.. ' juice.')
})
minetest.register_craftitem('drinks:jbu_'..desc, {

View File

@ -1,10 +1,11 @@
function drinks.liquid_storage_formspec(fullness, max)
local formspec = -- Used for the liquid storing barrels.
function drinks.liquid_storage_formspec(fruit, fullness, max)
local formspec =
'size[8,8]'..
'label[0,0;Fill with the drink of your choice,]'..
'label[0,.4;you can only add more of the same type of drink.]'..
'label[4.5,1.2;Add liquid ->]'..
'label[.75,1.75;This is '..((fullness/max)*100)..'% full]'..
'label[.5,1.2;Storing '..fruit..' juice.]'..
'label[.5,1.65;Holding '..(fullness/2)..' of '..(max/2)..' cups.]'..
'label[4.5,2.25;Take liquid ->]'..
'label[2,3.2;(This empties the container completely)]'..
'button[0,3;2,1;purge;Purge]'..

View File

@ -30,6 +30,27 @@ if minetest.get_modpath('bushes_classic') then
table.insert(drinks.drink_table, {'strawberry', 'Strawberry', '#ff3636'})
end
if minetest.get_modpath('farming_plus') then
drinks.juiceable['banana'] = true
drinks.juiceable['lemon'] = true
drinks.juiceable['melon'] = true
drinks.juiceable['orange'] = true
drinks.juiceable['peach'] = true
drinks.juiceable['rhubarb'] = true
drinks.juiceable['tomato'] = true
drinks.juiceable['strawberry'] = true
drinks.juiceable['raspberry'] = true
table.insert(drinks.drink_table, {'banana', 'Banana', '#eced9f'})
table.insert(drinks.drink_table, {'lemon', 'Lemon', '#feffaa'})
table.insert(drinks.drink_table, {'melon', 'Melon', '#ef4646'})
table.insert(drinks.drink_table, {'orange', 'Orange', '#ffc417'})
table.insert(drinks.drink_table, {'peach', 'Peach', '#f2bc1e'})
table.insert(drinks.drink_table, {'rhubarb', 'Rhubarb', '#fb8461'})
table.insert(drinks.drink_table, {'tomato', 'Tomato', '#d03a0e'})
table.insert(drinks.drink_table, {'strawberry', 'Strawberry', '#ff3636'})
table.insert(drinks.drink_table, {'raspberry', 'Raspberry', '#C70039'})
end
if minetest.get_modpath('thirsty') then
dofile(minetest.get_modpath('drinks')..'/drinks.lua')
else

View File

@ -81,26 +81,17 @@ v -0.355973 0.030000 0.287346
v -0.285263 0.030000 0.358056
v -0.296242 0.036360 0.369036
v -0.366953 0.036360 0.298326
v -0.123715 1.404509 -0.298674
v -0.200174 -0.154509 -0.483264
v 0.000000 -0.350000 0.000000
v 0.123715 1.404509 -0.298674
v 0.200174 1.154508 -0.483264
v 0.200174 -0.154509 -0.483264
v 0.123715 -0.304509 -0.298673
v 0.298674 1.404509 -0.123715
v 0.483264 1.154508 -0.200174
v 0.483264 -0.154509 -0.200174
v 0.298674 -0.304509 -0.123715
v 0.000000 -0.350000 0.000000
v 0.298674 1.404509 0.123715
v 0.483264 1.154508 0.200175
v 0.483264 1.154508 0.200174
v 0.483264 -0.154509 0.200174
v 0.298674 -0.304509 0.123715
v 0.123715 1.404509 0.298674
v 0.200174 1.154508 0.483264
v 0.200174 -0.154509 0.483264
v 0.200175 1.154508 0.483264
v 0.200175 -0.154509 0.483264
v 0.123715 -0.304509 0.298674
v -0.000000 1.500000 0.000000
v -0.123715 1.404509 0.298674
v -0.200174 1.154508 0.483264
v -0.200174 -0.154509 0.483264
@ -109,12 +100,21 @@ v -0.298674 1.404509 0.123715
v -0.483264 1.154508 0.200175
v -0.483264 -0.154509 0.200175
v -0.298673 -0.304509 0.123715
v -0.000000 1.500000 0.000000
v -0.298674 1.404509 -0.123715
v -0.483264 1.154508 -0.200174
v -0.483264 -0.154509 -0.200174
v -0.298673 -0.304509 -0.123715
v -0.123715 1.404509 -0.298674
v -0.200174 1.154508 -0.483264
v -0.200174 -0.154509 -0.483264
v -0.123715 -0.304509 -0.298673
v 0.123715 1.404509 -0.298674
v 0.200175 1.154508 -0.483264
v 0.200175 -0.154509 -0.483264
v 0.123715 -0.304509 -0.298673
v 0.483264 1.154508 -0.200174
v 0.298673 -0.304509 -0.123715
vt 1.000000 0.008414
vt 0.978921 0.399028
vt 0.894297 0.383031
@ -235,64 +235,64 @@ vt 0.651986 0.586137
vt 0.974085 0.425479
vt 0.885915 0.409359
vt 0.712088 0.441124
vt 0.458192 0.984779
vt 0.416249 0.876077
vt 0.492200 0.829133
vt 0.577701 0.901340
vt 0.398986 0.746077
vt 0.371685 0.623173
vt 0.461508 0.642253
vt 0.611408 0.000000
vt 0.611408 0.499779
vt 0.458556 0.499779
vt 0.458556 0.000000
vt 0.401059 0.746160
vt 0.364561 0.526338
vt 0.515364 0.565244
vt 0.603345 0.690487
vt 0.513970 0.712258
vt 0.522330 0.752969
vt 0.633687 0.763133
vt 0.305704 0.499779
vt 0.305704 0.000000
vt 0.586447 0.840659
vt 0.506303 0.797843
vt 0.500258 0.675850
vt 0.595875 0.616286
vt 0.152852 0.499779
vt 0.152852 0.000000
vt 0.474776 0.940516
vt 0.443899 0.855822
vt 0.435323 0.628715
vt 0.474696 0.521813
vt 0.000000 0.499779
vt -0.000000 0.000000
vt 0.325985 0.940516
vt 0.359167 0.857264
vt 0.354410 0.631967
vt 0.318943 0.521813
vt 0.611519 0.000111
vt 0.611519 0.499889
vt 0.458667 0.499889
vt 0.458667 0.000111
vt 0.215537 0.842251
vt 0.295143 0.801929
vt 0.291947 0.685733
vt 0.193933 0.619083
vt 0.305815 0.499889
vt 0.305815 0.000111
vt 0.197065 0.696779
vt 0.283780 0.717322
vt 0.275822 0.769647
vt 0.152658 0.775742
vt 0.152963 0.499889
vt 0.152963 0.000111
vt 0.274084 0.573260
vt 0.332759 0.642608
vt 0.317258 0.853505
vt 0.211645 0.931220
vt 0.000111 0.499889
vt 0.000111 0.000111
vt 0.350770 0.992591
vt 0.308827 0.883889
vt 0.384778 0.836945
vt 0.470279 0.909152
vt 0.776139 0.791890
vt 0.748838 0.668985
vt 0.838661 0.688066
vt 0.613361 0.001953
vt 0.613361 0.501732
vt 0.460509 0.501732
vt 0.460509 0.001953
vt 0.293637 0.753973
vt 0.741714 0.572150
vt 0.892517 0.611056
vt 0.980498 0.736300
vt 0.891124 0.758070
vt 0.414908 0.760781
vt 0.526265 0.770946
vt 0.307657 0.501732
vt 0.307657 0.001953
vt 0.963601 0.886471
vt 0.883457 0.843656
vt 0.392837 0.683662
vt 0.488453 0.624099
vt 0.154805 0.501732
vt 0.154805 0.001953
vt 0.851929 0.986328
vt 0.821052 0.901634
vt 0.327901 0.636527
vt 0.367274 0.529625
vt 0.001953 0.501732
vt 0.001953 0.001953
vt 0.703139 0.986328
vt 0.736320 0.903076
vt 0.246988 0.639780
vt 0.211521 0.529625
vt 0.613472 0.002064
vt 0.613472 0.501843
vt 0.460620 0.501842
vt 0.460620 0.002064
vt 0.592690 0.888063
vt 0.672296 0.847742
vt 0.184525 0.693546
vt 0.086511 0.626896
vt 0.307768 0.501842
vt 0.307768 0.002064
vt 0.574219 0.742591
vt 0.660933 0.763134
vt 0.168400 0.777459
vt 0.045236 0.783554
vt 0.154916 0.501842
vt 0.154916 0.002064
vt 0.651237 0.619072
vt 0.709912 0.688420
vt 0.209836 0.861318
vt 0.104223 0.939033
vt 0.002064 0.501842
vt 0.002064 0.002064
vn -0.7071 0.0000 0.7071
vn -0.7071 0.0000 -0.7071
vn 0.7071 0.0000 -0.7071
@ -305,20 +305,11 @@ vn 0.3162 0.8944 -0.3162
vn -0.2796 0.9185 -0.2796
vn 0.2796 0.9185 0.2796
vn -0.2796 0.9185 0.2796
vn -0.0000 0.5940 -0.8045
vn -0.0000 -0.9886 -0.1506
vn -0.0000 -0.0000 -1.0000
vn 0.0000 0.9525 -0.3045
vn -0.0000 -0.7761 -0.6306
vn 0.4459 -0.7761 -0.4459
vn 0.5688 0.5940 -0.5688
vn 0.1065 -0.9886 -0.1065
vn 0.2153 0.9525 -0.2153
vn 0.6306 -0.7761 0.0000
vn 0.8045 0.5940 0.0000
vn 0.1506 -0.9886 0.0000
vn 1.0000 -0.0000 0.0000
vn 1.0000 0.0000 -0.0000
vn 0.3045 0.9525 0.0000
vn 0.6306 -0.7761 -0.0000
vn 0.4459 -0.7761 0.4459
vn 0.5688 0.5940 0.5688
vn 0.1065 -0.9886 0.1065
@ -326,7 +317,7 @@ vn 0.2153 0.9525 0.2153
vn 0.0000 -0.7761 0.6306
vn 0.0000 0.5940 0.8045
vn 0.0000 -0.9886 0.1506
vn 0.0000 0.0000 1.0000
vn 0.0000 -0.0000 1.0000
vn 0.0000 0.9525 0.3045
vn -0.4459 -0.7761 0.4459
vn -0.5688 0.5940 0.5688
@ -334,13 +325,22 @@ vn -0.1065 -0.9886 0.1065
vn -0.2153 0.9525 0.2153
vn -0.6306 -0.7761 0.0000
vn -0.8045 0.5940 0.0000
vn -0.1506 -0.9886 -0.0000
vn -0.1506 -0.9886 0.0000
vn -1.0000 0.0000 0.0000
vn -0.3045 0.9525 0.0000
vn -0.4459 -0.7761 -0.4459
vn -0.5688 0.5940 -0.5688
vn -0.1065 -0.9886 -0.1065
vn -0.2153 0.9525 -0.2153
vn -0.0000 -0.7761 -0.6306
vn -0.0000 0.5940 -0.8045
vn -0.0000 -0.9886 -0.1506
vn -0.0000 0.0000 -1.0000
vn -0.0000 0.9525 -0.3045
vn 0.4459 -0.7761 -0.4459
vn 0.5688 0.5940 -0.5688
vn 0.1065 -0.9886 -0.1065
vn 0.2153 0.9525 -0.2153
g Sphere_Sphere.001_None
s off
f 1/1/1 2/2/1 4/3/1 3/4/1
@ -415,7 +415,7 @@ f 114/126/17 82/133/17 86/134/17 87/127/17
f 87/127/18 86/134/18 90/135/18 91/136/18
f 85/124/19 84/123/19 88/137/19 89/138/19
f 83/125/20 87/127/20 91/136/20
f 86/131/3 85/130/3 89/139/3 90/140/3
f 86/131/4 85/130/4 89/139/4 90/140/4
f 84/123/21 100/132/21 88/137/21
f 91/136/22 90/135/22 94/141/22 95/142/22
f 89/138/23 88/137/23 92/143/23 93/144/23
@ -425,7 +425,7 @@ f 88/137/26 100/132/26 92/143/26
f 95/142/27 94/141/27 98/147/27 99/148/27
f 93/144/28 92/143/28 96/149/28 97/150/28
f 83/125/29 95/142/29 99/148/29
f 94/146/4 93/145/4 97/151/4 98/152/4
f 94/146/1 93/145/1 97/151/1 98/152/1
f 92/143/30 100/132/30 96/149/30
f 99/148/31 98/147/31 103/153/31 104/154/31
f 97/150/32 96/149/32 101/155/32 102/156/32
@ -435,7 +435,7 @@ f 96/149/35 100/132/35 101/155/35
f 104/154/36 103/153/36 107/161/36 108/162/36
f 102/156/37 101/155/37 105/163/37 106/164/37
f 83/125/38 104/154/38 108/162/38
f 103/160/1 102/159/1 106/165/1 107/166/1
f 103/160/2 102/159/2 106/165/2 107/166/2
f 101/155/39 100/132/39 105/163/39
f 108/162/40 107/161/40 111/167/40 112/168/40
f 106/164/41 105/163/41 109/169/41 110/170/41
@ -445,5 +445,5 @@ f 105/163/44 100/132/44 109/169/44
f 112/168/45 111/167/45 82/173/45 114/174/45
f 110/170/46 109/169/46 81/175/46 113/176/46
f 83/125/47 112/168/47 114/174/47
f 111/172/2 110/171/2 113/177/2 82/178/2
f 111/172/3 110/171/3 113/177/3 82/178/3
f 109/169/48 100/132/48 81/175/48

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 56 KiB