Mod update 2019-12-12 (#21)
* add digistuff * add digiterms * add missions * add morelights * add nixie_tubes * add mob_horse * change digiterms: add cyrillic letter, change recipes for scifi monitors * add missing recipe for decatron * add craft recipes for digistuff * Separate mod for missing craft recipes * new mod: bees * add advtrains_luaautomation with craft recipes * add ham_radio * add christmas_decor * jumpdrive: ham_radio compat * fix christmas decor
7
MineStead_modpack/add_craft_recipes/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# MineSTEAD craft recipes
|
||||
|
||||
Adding missing craft recipes for items from these mods:
|
||||
|
||||
* digilines
|
||||
* digistuff
|
||||
* nixie_tubes
|
@ -0,0 +1,34 @@
|
||||
local plastic = "basic_materials:plastic_sheet"
|
||||
local wire = "digilines:wire_std_00000000"
|
||||
|
||||
local glass = "default:glass"
|
||||
|
||||
minetest.register_craft({
|
||||
type="shapeless",
|
||||
output = 'advtrains_luaautomation:dtrack_placer',
|
||||
recipe = {
|
||||
"advtrains:dtrack_placer",
|
||||
"technic:control_logic_unit",
|
||||
wire,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'advtrains_luaautomation:oppanel',
|
||||
recipe = {
|
||||
{plastic, plastic, plastic},
|
||||
{glass, "mesecons_luacontroller:luacontroller0000", glass},
|
||||
{wire, wire, wire},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'advtrains_luaautomation:pcnaming',
|
||||
recipe = {
|
||||
{"default:diamond"},
|
||||
{"screwdriver:screwdriver"},
|
||||
{"default:gold_ingot"},
|
||||
},
|
||||
})
|
||||
|
@ -17,4 +17,3 @@ minetest.register_craft({
|
||||
"basic_materials:ic", wire
|
||||
}
|
||||
})
|
||||
|
42
MineStead_modpack/add_craft_recipes/craft/digistuff.lua
Normal file
@ -0,0 +1,42 @@
|
||||
local wire = 'digilines:wire_std_00000000'
|
||||
|
||||
if minetest.get_modpath("mesecons_noteblock") then
|
||||
-- digistuff noteblock
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "digistuff:noteblock",
|
||||
recipe = {
|
||||
"mesecons_noteblock:noteblock", wire
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("homedecor_electronics") then
|
||||
-- digistuff piezo
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "digistuff:piezo",
|
||||
recipe = {
|
||||
"homedecor:speaker_driver", wire
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("mesecons_mvps") then
|
||||
-- digistuff piston
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "digistuff:piston",
|
||||
recipe = {
|
||||
"mesecons_pistons:piston_normal_off", wire
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "digistuff:wall_knob",
|
||||
recipe = {
|
||||
"digistuff:button", wire
|
||||
}
|
||||
})
|
@ -0,0 +1,8 @@
|
||||
minetest.register_craft({
|
||||
output = "nixie_tubes:decatron_off 4",
|
||||
recipe = {
|
||||
{ "", "default:glass", "" },
|
||||
{ "default:glass", "default:mese_crystal_fragment", "default:glass" },
|
||||
{ "default:glass", "default:mese_crystal_fragment", "default:glass" }
|
||||
},
|
||||
})
|
11
MineStead_modpack/add_craft_recipes/depends.txt
Normal file
@ -0,0 +1,11 @@
|
||||
default
|
||||
basic_materials?
|
||||
digilines?
|
||||
digistuff?
|
||||
nixie_tubes?
|
||||
mesecons_noteblock?
|
||||
mesecons_mvps?
|
||||
homedecor_electronics?
|
||||
advtrains_luaautomation?
|
||||
|
||||
|
18
MineStead_modpack/add_craft_recipes/init.lua
Normal file
@ -0,0 +1,18 @@
|
||||
-- MineSTEAD craft recipes
|
||||
local MP = minetest.get_modpath("add_craft_recipes")
|
||||
|
||||
if minetest.get_modpath("digilines") then
|
||||
dofile(MP.."/craft/digilines.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath("digistuff") then
|
||||
dofile(MP.."/craft/digistuff.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath("nixie_tubes") then
|
||||
dofile(MP.."/craft/nixie_tubes.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath("advtrains_luaautomation") then
|
||||
dofile(MP.."/craft/advtrains_luaautomation.lua")
|
||||
end
|
1
MineStead_modpack/add_craft_recipes/mod.conf
Normal file
@ -0,0 +1 @@
|
||||
name = add_craft_recipes
|
246
advtrains_modpack/advtrains_luaautomation/README.txt
Normal file
@ -0,0 +1,246 @@
|
||||
|
||||
#### Advtrains - Lua Automation features
|
||||
|
||||
This mod offers components that run LUA code and interface with each other through a global environment. It makes complex automated railway systems possible.
|
||||
|
||||
### atlatc
|
||||
The mod is sometimes abbreviated as 'atlatc'. This stands for AdvTrainsLuaATC. This short name has been chosen for user convenience, since the name of this mod ('advtrains_luaautomation') is very long.
|
||||
|
||||
### Privilege
|
||||
To perform any operations using this mod (except executing operation panels), players need the "atlatc" privilege.
|
||||
This privilege should never be granted to anyone except trusted administrators. Even though the LUA environment is sandboxed, it is still possible to DoS the server by coding infinite loops or requesting expotentially growing interrupts.
|
||||
|
||||
### Active and passive
|
||||
Active components are these who have LUA code running in them. They are triggered on specific events. Passive components are dumb, they only have a state and can be set to another state, they can't perform actions themselves.
|
||||
|
||||
### Environments
|
||||
|
||||
Each active component is assigned to an environment. This is where all data are held. Components in different environments can't inferface with each other.
|
||||
This system allows multiple independent automation systems to run simultaneously without polluting each other's environment.
|
||||
|
||||
/env_create <env_name>
|
||||
Create environment with the given name. To be able to do anything, you first need to create an environment. Choose the name wisely, you can't change it afterwards.
|
||||
|
||||
/env_setup <env_name>
|
||||
Invoke the form to edit the environment's initialization code. For more information, see the section on active components. You can also delete an environment from here.
|
||||
|
||||
### Active components
|
||||
|
||||
The code of every active component is run on specific events which are explained soon. When run, every variable written that is not local and is no function or userdata is saved over code re-runs and over server restarts. Additionally, the following global variables are defined:
|
||||
|
||||
# event
|
||||
The variable 'event' contains a table with information on the current event. How this table can look is explained below.
|
||||
|
||||
# S
|
||||
The variable 'S' contains a table which is shared between all components of the environment. Its contents are persistent over server restarts. May not contain functions, every other value is allowed.
|
||||
Example:
|
||||
Component 1: S.stuff="foo"
|
||||
Component 2: print(S.stuff)
|
||||
-> foo
|
||||
|
||||
# F
|
||||
The variable 'F' also contains a table which is shared between all components of the environment. Its contents are discarded on server shutdown or when the init code gets re-run. Every data type is allowed, even functions.
|
||||
The purpose of this table is not to save data, but to provide static value and function definitions. The table should be populated by the init code.
|
||||
|
||||
# Standard Lua functions
|
||||
The following standard Lua libraries are available:
|
||||
string, math, table, os
|
||||
The following standard Lua functions are available:
|
||||
assert, error, ipairs, pairs, next, select, tonumber, tostring, type, unpack
|
||||
|
||||
Every attempt to overwrite any of the predefined values results in an error.
|
||||
|
||||
# LuaAutomation-specific global functions
|
||||
|
||||
POS(x,y,z)
|
||||
Shorthand function to create a position vector {x=?, y=?, z=?} with less characters
|
||||
|
||||
In the following functions, all parameters named 'pos' designate a position. You can use either:
|
||||
- a default Minetest position vector (like {x=34, y=2, z=-18})
|
||||
- the POS(34,2,-18) shorthand
|
||||
- A string, the passive component name. See 'passive component naming'.
|
||||
|
||||
getstate(pos)
|
||||
Get the state of the passive component at position 'pos'. See section on passive components for more info.
|
||||
pos can be either a position vector (created by POS()) or a string, the name of this passive component.
|
||||
|
||||
setstate(pos, newstate)
|
||||
Set the state of the passive component at position 'pos'.
|
||||
|
||||
is_passive(pos)
|
||||
Checks whether there is a passive component at the position pos (and/or whether a passive component with this name exists)
|
||||
|
||||
interrupt(time, message)
|
||||
Cause LuaAutomation to trigger an 'int' event on this component after the given time in seconds with the specified 'message' field. 'message' can be of any Lua data type.
|
||||
Not available in init code!
|
||||
|
||||
interrupt_pos(pos, message)
|
||||
Immediately trigger an 'ext_int' event on the active component at position pos. 'message' is like in interrupt().
|
||||
USE WITH CARE, or better don't use! Incorrect use can result in expotential growth of interrupts.
|
||||
|
||||
digiline_send(channel, message)
|
||||
Make this active component send a digiline message on the specified channel.
|
||||
Not available in init code!
|
||||
|
||||
-- The next 4 functions are available when advtrains_interlocking is enabled: --
|
||||
|
||||
can_set_route(pos, route_name)
|
||||
Returns whether it is possible to set the route designated by route_name from the signal at pos.
|
||||
|
||||
set_route(pos, route_name)
|
||||
Requests the given route from the signal at pos. Has the same effect as clicking "Set Route" in the signalling dialog.
|
||||
|
||||
cancel_route(pos)
|
||||
Cancels the route that is set from the signal at pos. Has the same effect as clicking "Cancel Route" in the signalling dialog.
|
||||
|
||||
get_aspect(pos)
|
||||
Returns the signal aspect of the signal at pos. A signal aspect has the following format:
|
||||
aspect = {
|
||||
main = { -- the next track section in line. Shows blocked for shunt routes
|
||||
free = <boolean>,
|
||||
speed = <int km/h>,
|
||||
},
|
||||
shunt = { -- whether a "shunting allowed" aspect should be shown
|
||||
free = <boolean>,
|
||||
}
|
||||
dst = { -- the aspect of the next main signal on (at end of) route
|
||||
free = <boolean>,
|
||||
speed = <int km/h>,
|
||||
}
|
||||
info = {
|
||||
call_on = <boolean>, -- Call-on route, expect train in track ahead
|
||||
dead_end = <boolean>, -- Route ends on a dead end (e.g. bumper)
|
||||
}
|
||||
}
|
||||
As of August 2018, only the aspect.main.free field is ever used by the interlocking system.
|
||||
|
||||
# Lines
|
||||
|
||||
The advtrains_line_automation component adds a few contraptions that should make creating timeable systems easier.
|
||||
Part of its functionality is also available in LuaATC:
|
||||
|
||||
- rwt.* - all Railway Time functions are included as documented in https://advtrains.de/wiki/doku.php?id=dev:lines:rwt
|
||||
|
||||
- schedule(rw_time, msg)
|
||||
- schedule_in(rw_dtime, msg)
|
||||
Schedules an event of type {type="schedule", schedule=true, msg=msg} at (resp. after) the specified railway time.
|
||||
(which can be in any format). You can only schedule one event this way. (uses the new lines-internal scheduler)
|
||||
|
||||
## Components and events
|
||||
|
||||
The event table is a table of the following format:
|
||||
{
|
||||
type = "<type>",
|
||||
<type> = true,
|
||||
... additional content ...
|
||||
}
|
||||
You can check for the event type by either using
|
||||
if event.type == "wanted" then ...do stuff... end
|
||||
or
|
||||
if event.wanted then ...do stuff... end
|
||||
(if 'wanted' is the event type to check for)
|
||||
|
||||
# Init code
|
||||
The initialization code is not a component as such, but rather a part of the whole environment. It can (and should) be used to make definitions that other components can refer to.
|
||||
Examples:
|
||||
A function to define behavior for trains in subway stations:
|
||||
function F.station()
|
||||
if event.train then atc_send("B0WOL") end
|
||||
if event.int and event.message="depart" then atc_send("OCD1SM") end
|
||||
end
|
||||
|
||||
The init code is run whenever the F table needs to be refilled with data. This is the case on server startup and whenever the init code is changed and you choose to run it.
|
||||
Functions are run in the environment of the currently active node, regardless of where they were defined. So, the 'event' table always reflects the state of the calling node.
|
||||
|
||||
The 'event' table of the init code is always {type="init", init=true}.
|
||||
|
||||
# ATC rails
|
||||
The Lua-controlled ATC rails are the only components that can actually interface with trains. The following event types are generated:
|
||||
|
||||
{type="train", train=true, id="<train_id>"}
|
||||
This event is fired when a train enters the rail. The field 'id' is the unique train ID, which is 6-digit random numerical string.
|
||||
If the world contains trains from an older advtrains version, this string may be longer and contain a dot (.)
|
||||
|
||||
{type="int", int=true, msg=<message>}
|
||||
Fired when an interrupt set by the 'interrupt' function runs out. 'message' is the message passed to the interrupt function.
|
||||
For backwards compatiblity reasons, <message> is also contained in an event.message field.
|
||||
{type="ext_int", ext_int=true, message=<message>}
|
||||
Fired when another node called 'interrupt_pos' on this position. 'message' is the message passed to the interrupt_pos function.
|
||||
|
||||
{type="digiline", digiline=true, channel=<channel>, msg=<message>}
|
||||
Fired when the controller receives a digiline message.
|
||||
|
||||
In addition to the default environment functions, the following functions are available:
|
||||
|
||||
atc_send(<atc_command>)
|
||||
Sends the specified ATC command to the train and returns true. If there is no train, returns false and does nothing.
|
||||
atc_reset()
|
||||
Resets the train's current ATC command. If there is no train, returns false and does nothing.
|
||||
atc_arrow
|
||||
Boolean, true when the train is driving in the direction of the arrows of the ATC rail. Nil if there is no train.
|
||||
atc_id
|
||||
Train ID of the train currently passing the controller. Nil if there's no train.
|
||||
atc_speed
|
||||
Speed of the train, or nil if there is no train.
|
||||
atc_set_text_outside(text)
|
||||
Set text shown on the outside of the train. Pass nil to show no text.
|
||||
atc_set_text_inside(text)
|
||||
Set text shown to train passengers. Pass nil to show no text.
|
||||
get_line()
|
||||
Returns the "Line" property of the train (a string).
|
||||
This can be used to distinguish between trains of different lines and route them appropriately.
|
||||
The interlocking system also uses this property for Automatic Routesetting.
|
||||
set_line(line)
|
||||
Sets the "Line" property of the train (a string).
|
||||
If the first digit of this string is a number (0-9), any subway wagons on the train will have this one displayed as line number
|
||||
(where "0" is actually shown as Line 10 on the train)
|
||||
get_rc()
|
||||
Returns the "Routingcode" property of the train (a string).
|
||||
The interlocking system uses this property for Automatic Routesetting.
|
||||
set_rc(routingcode)
|
||||
Sets the "Routingcode" property of the train (a string).
|
||||
The interlocking system uses this property for Automatic Routesetting.
|
||||
split_at_index(index, command)
|
||||
Splits the train at the specified index, into a train with index-1 wagons and a second train starting with the index-th wagon.
|
||||
command specifies an atc command to be sent to the second train after decoupling.
|
||||
|
||||
# Operator panel
|
||||
This simple node executes its actions when punched. It can be used to change a switch and update the corresponding signals or similar applications.
|
||||
|
||||
The event fired is {type="punch", punch=true} by default. In case of an interrupt or a digiline message, the events are similar to the ones of the ATC rail.
|
||||
|
||||
### Passive components
|
||||
|
||||
All passive components can be interfaced with the setstate and getstate functions(see above).
|
||||
Below, each apperance is mapped to the "state" of that node.
|
||||
|
||||
## Signals
|
||||
The light signals are interfaceable, the analog signals are not.
|
||||
"green" - Signal shows green light
|
||||
"red" - Signal shows red light
|
||||
|
||||
## Switches
|
||||
All default rail switches are interfaceable, independent of orientation.
|
||||
"cr" - The switch is set in the direction that is not straight.
|
||||
"st" - The switch is set in the direction that is straight.
|
||||
|
||||
## Mesecon Switch
|
||||
The Mesecon switch can be switched using LuaAutomation. Note that this is not possible on levers, only the full-node 'Switch' block.
|
||||
"on" - the switch is switched on
|
||||
"off" - the switch is switched off
|
||||
|
||||
##Andrew's Cross
|
||||
"on" - it blinks
|
||||
"off" - it does not blink
|
||||
|
||||
### Passive component naming
|
||||
You can assign names to passive components using the Passive Component Naming tool.
|
||||
Once you set a name for any component, you can reference it by that name in the getstate() and setstate() functions, like this:
|
||||
(Imagine a signal that you have named "Stn_P1_out" at position (1,2,3) )
|
||||
setstate("Stn_P1_out", "green") instead of setstate(POS(1,2,3), "green")
|
||||
This way, you don't need to memorize positions.
|
||||
|
||||
PC-Naming can also be used to name interlocking signals for route setting via the set_route() functions. IMPORTANT: The "Signal Name" set in the
|
||||
signalling formspec is completely independent and can NOT be used to look up the position, you need to explicitly use the PCNaming tool.
|
||||
|
||||
--TODO: Ein paar mehr Codebeispiele wären schön, insbesondere mit os.date und so...
|
163
advtrains_modpack/advtrains_luaautomation/active_common.lua
Normal file
@ -0,0 +1,163 @@
|
||||
|
||||
|
||||
local ac = {nodes={}}
|
||||
|
||||
function ac.load(data)
|
||||
if data then
|
||||
ac.nodes=data.nodes
|
||||
end
|
||||
end
|
||||
function ac.save()
|
||||
return {nodes = ac.nodes}
|
||||
end
|
||||
|
||||
function ac.after_place_node(pos, player)
|
||||
local meta=minetest.get_meta(pos)
|
||||
meta:set_string("formspec", ac.getform(pos, meta))
|
||||
meta:set_string("infotext", "LuaAutomation component, unconfigured.")
|
||||
local ph=minetest.pos_to_string(pos)
|
||||
--just get first available key!
|
||||
for en,_ in pairs(atlatc.envs) do
|
||||
ac.nodes[ph]={env=en}
|
||||
return
|
||||
end
|
||||
end
|
||||
function ac.getform(pos, meta_p)
|
||||
local meta = meta_p or minetest.get_meta(pos)
|
||||
local envs_asvalues={}
|
||||
|
||||
local ph=minetest.pos_to_string(pos)
|
||||
local nodetbl = ac.nodes[ph]
|
||||
local env, code, err = nil, "", ""
|
||||
if nodetbl then
|
||||
code=nodetbl.code or ""
|
||||
err=nodetbl.err or ""
|
||||
env=nodetbl.env or ""
|
||||
end
|
||||
local sel = 1
|
||||
for n,_ in pairs(atlatc.envs) do
|
||||
envs_asvalues[#envs_asvalues+1]=n
|
||||
if n==env then
|
||||
sel=#envs_asvalues
|
||||
end
|
||||
end
|
||||
local form = "size[10,10]dropdown[0,0;3;env;"..table.concat(envs_asvalues, ",")..";"..sel.."]"
|
||||
.."button[4,0;2,1;save;Save]button[7,0;2,1;cle;Clear local env] textarea[0.2,1;10,10;code;Code;"..minetest.formspec_escape(code).."]"
|
||||
.."label[0,9.8;"..err.."]"
|
||||
return form
|
||||
end
|
||||
|
||||
function ac.after_dig_node(pos, node, player)
|
||||
advtrains.invalidate_all_paths(pos)
|
||||
advtrains.ndb.clear(pos)
|
||||
local ph=minetest.pos_to_string(pos)
|
||||
ac.nodes[ph]=nil
|
||||
end
|
||||
|
||||
function ac.on_receive_fields(pos, formname, fields, player)
|
||||
if not minetest.check_player_privs(player:get_player_name(), {atlatc=true}) then
|
||||
minetest.chat_send_player(player:get_player_name(), "Missing privilege: atlatc - Operation cancelled!")
|
||||
return
|
||||
end
|
||||
|
||||
local meta=minetest.get_meta(pos)
|
||||
local ph=minetest.pos_to_string(pos)
|
||||
local nodetbl = ac.nodes[ph] or {}
|
||||
--if fields.quit then return end
|
||||
if fields.env then
|
||||
nodetbl.env=fields.env
|
||||
end
|
||||
if fields.code then
|
||||
nodetbl.code=fields.code
|
||||
end
|
||||
if fields.save then
|
||||
nodetbl.err=nil
|
||||
end
|
||||
if fields.cle then
|
||||
nodetbl.data={}
|
||||
end
|
||||
|
||||
ac.nodes[ph]=nodetbl
|
||||
|
||||
meta:set_string("formspec", ac.getform(pos, meta))
|
||||
if nodetbl.env then
|
||||
meta:set_string("infotext", "LuaAutomation component, assigned to environment '"..nodetbl.env.."'")
|
||||
else
|
||||
meta:set_string("infotext", "LuaAutomation component, invalid enviroment set!")
|
||||
end
|
||||
end
|
||||
|
||||
function ac.run_in_env(pos, evtdata, customfct_p)
|
||||
local ph=minetest.pos_to_string(pos)
|
||||
local nodetbl = ac.nodes[ph]
|
||||
if not nodetbl then
|
||||
atwarn("LuaAutomation component at",ph,": Data not in memory! Please visit component and click 'Save'!")
|
||||
return
|
||||
end
|
||||
|
||||
local meta
|
||||
if minetest.get_node_or_nil(pos) then
|
||||
meta=minetest.get_meta(pos)
|
||||
end
|
||||
|
||||
if not nodetbl.env or not atlatc.envs[nodetbl.env] then
|
||||
atwarn("LuaAutomation component at",ph,": Not an existing environment: "..(nodetbl.env or "<nil>"))
|
||||
return false
|
||||
end
|
||||
if not nodetbl.code or nodetbl.code=="" then
|
||||
atwarn("LuaAutomation component at",ph,": No code to run! (insert -- to suppress warning)")
|
||||
return false
|
||||
end
|
||||
|
||||
local customfct=customfct_p or {}
|
||||
-- add interrupt function
|
||||
customfct.interrupt=function(t, imesg)
|
||||
assertt(t, "number")
|
||||
assert(t >= 0)
|
||||
atlatc.interrupt.add(t, pos, {type="int", int=true, message=imesg, msg=imesg}) --Compatiblity "message" field.
|
||||
end
|
||||
-- add digiline_send function, if digiline is loaded
|
||||
if minetest.global_exists("digiline") then
|
||||
customfct.digiline_send=function(channel, msg)
|
||||
assertt(channel, "string")
|
||||
digiline:receptor_send(pos, digiline.rules.default, channel, msg)
|
||||
end
|
||||
end
|
||||
-- add lines scheduler if enabled
|
||||
if advtrains.lines and advtrains.lines.sched then
|
||||
customfct.schedule = function(rwtime, msg)
|
||||
advtrains.lines.sched.enqueue(rwtime, "atlatc_env", {pos=pos, msg=msg}, advtrains.encode_pos(pos), 1)
|
||||
end
|
||||
customfct.schedule_in = function(rwtime, msg)
|
||||
advtrains.lines.sched.enqueue_in(rwtime, "atlatc_env", {pos=pos, msg=msg}, advtrains.encode_pos(pos), 1)
|
||||
end
|
||||
end
|
||||
|
||||
local datain=nodetbl.data or {}
|
||||
local succ, dataout = atlatc.envs[nodetbl.env]:execute_code(datain, nodetbl.code, evtdata, customfct)
|
||||
if succ then
|
||||
atlatc.active.nodes[ph].data=atlatc.remove_invalid_data(dataout)
|
||||
else
|
||||
atlatc.active.nodes[ph].err=dataout
|
||||
atwarn("LuaAutomation ATC interface rail at",ph,": LUA Error:",dataout)
|
||||
if meta then
|
||||
meta:set_string("infotext", "LuaAutomation ATC interface rail, ERROR:"..dataout)
|
||||
end
|
||||
end
|
||||
if meta then
|
||||
meta:set_string("formspec", ac.getform(pos, meta))
|
||||
end
|
||||
end
|
||||
|
||||
function ac.on_digiline_receive(pos, node, channel, msg)
|
||||
atlatc.interrupt.add(0, pos, {type="digiline", digiline=true, channel = channel, msg = msg})
|
||||
end
|
||||
|
||||
if advtrains.lines and advtrains.lines.sched then
|
||||
advtrains.lines.sched.register_callback("atlatc_env", function(data)
|
||||
-- This adds another interrupt to the atlatc queue... there might be a better way
|
||||
atlatc.interrupt.add(0, data.pos, {type="schedule",schedule=true, msg=data.msg})
|
||||
end)
|
||||
end
|
||||
|
||||
atlatc.active=ac
|
165
advtrains_modpack/advtrains_luaautomation/atc_rail.lua
Normal file
@ -0,0 +1,165 @@
|
||||
-- atc_rail.lua
|
||||
-- registers and handles the ATC rail. Active component.
|
||||
-- This is the only component that can interface with trains, so train interface goes here too.
|
||||
|
||||
--Using subtable
|
||||
local r={}
|
||||
|
||||
function r.fire_event(pos, evtdata)
|
||||
|
||||
local ph=minetest.pos_to_string(pos)
|
||||
local railtbl = atlatc.active.nodes[ph]
|
||||
|
||||
if not railtbl then
|
||||
atwarn("LuaAutomation ATC interface rail at",ph,": Data not in memory! Please visit position and click 'Save'!")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local arrowconn = railtbl.arrowconn
|
||||
if not arrowconn then
|
||||
atwarn("LuaAutomation ATC interface rail at",ph,": Incomplete Data! Please visit position and click 'Save'!")
|
||||
return
|
||||
end
|
||||
|
||||
--prepare ingame API for ATC. Regenerate each time since pos needs to be known
|
||||
--If no train, then return false.
|
||||
local train_id=advtrains.get_train_at_pos(pos)
|
||||
local train, atc_arrow, tvel
|
||||
if train_id then train=advtrains.trains[train_id] end
|
||||
if train then
|
||||
if not train.path then
|
||||
--we happened to get in between an invalidation step
|
||||
--delay
|
||||
atlatc.interrupt.add(0,pos,evtdata)
|
||||
return
|
||||
end
|
||||
local index = advtrains.path_lookup(train, pos)
|
||||
|
||||
local iconnid = 1
|
||||
if index then
|
||||
iconnid = train.path_cn[index]
|
||||
else
|
||||
atwarn("ATC rail at", pos, ": Rail not on train's path! Can't determine arrow direction. Assuming +!")
|
||||
end
|
||||
atc_arrow = iconnid == 1
|
||||
|
||||
tvel=train.velocity
|
||||
end
|
||||
local customfct={
|
||||
atc_send = function(cmd)
|
||||
if not train_id then return false end
|
||||
assertt(cmd, "string")
|
||||
advtrains.atc.train_set_command(train, cmd, atc_arrow)
|
||||
return true
|
||||
end,
|
||||
split_at_index = function(index, cmd)
|
||||
if not train_id then return false end
|
||||
assertt(cmd, "string")
|
||||
if type(index) ~= "number" then
|
||||
return false
|
||||
end
|
||||
local new_id = advtrains.split_train_at_index(train, index)
|
||||
if new_id then
|
||||
minetest.after(1,advtrains.atc.train_set_command,advtrains.trains[new_id], cmd, atc_arrow)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
set_shunt = function()
|
||||
-- enable shunting mode
|
||||
if not train_id then return false end
|
||||
train.is_shunt = true
|
||||
end,
|
||||
set_line = function(line)
|
||||
if type(line)~="string" and type(line)~="number" then
|
||||
return false
|
||||
end
|
||||
train.line = line .. ""
|
||||
minetest.after(0, advtrains.invalidate_path, train_id)
|
||||
return true
|
||||
end,
|
||||
get_line = function()
|
||||
return train.line
|
||||
end,
|
||||
set_rc = function(rc)
|
||||
if type(rc)~="string"then
|
||||
return false
|
||||
end
|
||||
train.routingcode = rc
|
||||
minetest.after(0, advtrains.invalidate_path, train_id)
|
||||
return true
|
||||
end,
|
||||
get_rc = function()
|
||||
return train.routingcode
|
||||
end,
|
||||
atc_reset = function(cmd)
|
||||
if not train_id then return false end
|
||||
assertt(cmd, "string")
|
||||
advtrains.atc.train_reset_command(train)
|
||||
return true
|
||||
end,
|
||||
atc_arrow = atc_arrow,
|
||||
atc_id = train_id,
|
||||
atc_speed = tvel,
|
||||
atc_set_text_outside = function(text)
|
||||
if not train_id then return false end
|
||||
if text then assertt(text, "string") end
|
||||
advtrains.trains[train_id].text_outside=text
|
||||
return true
|
||||
end,
|
||||
atc_set_text_inside = function(text)
|
||||
if not train_id then return false end
|
||||
if text then assertt(text, "string") end
|
||||
advtrains.trains[train_id].text_inside=text
|
||||
return true
|
||||
end,
|
||||
}
|
||||
|
||||
atlatc.active.run_in_env(pos, evtdata, customfct)
|
||||
|
||||
end
|
||||
|
||||
advtrains.register_tracks("default", {
|
||||
nodename_prefix="advtrains_luaautomation:dtrack",
|
||||
texture_prefix="advtrains_dtrack_atc",
|
||||
models_prefix="advtrains_dtrack",
|
||||
models_suffix=".b3d",
|
||||
shared_texture="advtrains_dtrack_shared_atc.png",
|
||||
description=atltrans("LuaAutomation ATC Rail"),
|
||||
formats={},
|
||||
get_additional_definiton = function(def, preset, suffix, rotation)
|
||||
return {
|
||||
after_place_node = atlatc.active.after_place_node,
|
||||
after_dig_node = atlatc.active.after_dig_node,
|
||||
|
||||
on_receive_fields = function(pos, ...)
|
||||
atlatc.active.on_receive_fields(pos, ...)
|
||||
|
||||
--set arrowconn (for ATC)
|
||||
local ph=minetest.pos_to_string(pos)
|
||||
local _, conns=advtrains.get_rail_info_at(pos, advtrains.all_tracktypes)
|
||||
atlatc.active.nodes[ph].arrowconn=conns[1].c
|
||||
end,
|
||||
|
||||
advtrains = {
|
||||
on_train_enter = function(pos, train_id)
|
||||
--do async. Event is fired in train steps
|
||||
atlatc.interrupt.add(0, pos, {type="train", train=true, id=train_id})
|
||||
end,
|
||||
},
|
||||
luaautomation = {
|
||||
fire_event=r.fire_event
|
||||
},
|
||||
digiline = {
|
||||
receptor = {},
|
||||
effector = {
|
||||
action = atlatc.active.on_digiline_receive
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
}, advtrains.trackpresets.t_30deg_straightonly)
|
||||
|
||||
|
||||
atlatc.rail = r
|
84
advtrains_modpack/advtrains_luaautomation/chatcmds.lua
Normal file
@ -0,0 +1,84 @@
|
||||
--chatcmds.lua
|
||||
--Registers commands to modify the init and step code for LuaAutomation
|
||||
|
||||
--position helper.
|
||||
--punching a node will result in that position being saved and inserted into a text field on the top of init form.
|
||||
local punchpos={}
|
||||
|
||||
minetest.register_on_punchnode(function(pos, node, player, pointed_thing)
|
||||
local pname=player:get_player_name()
|
||||
punchpos[pname]=pos
|
||||
end)
|
||||
|
||||
local function get_init_form(env, pname)
|
||||
local err = env.init_err or ""
|
||||
local code = env.init_code or ""
|
||||
local ppos=punchpos[pname]
|
||||
local pp=""
|
||||
if ppos then
|
||||
pp="POS"..minetest.pos_to_string(ppos)
|
||||
end
|
||||
local form = "size[10,10]button[0,0;2,1;run;Run InitCode]button[2,0;2,1;cls;Clear S]"
|
||||
.."button[4,0;2,1;save;Save] button[6,0;2,1;del;Delete Env.] field[8.1,0.5;2,1;punchpos;Last punched position;"..pp.."]"
|
||||
.."textarea[0.2,1;10,10;code;Environment initialization code;"..minetest.formspec_escape(code).."]"
|
||||
.."label[0,9.8;"..err.."]"
|
||||
return form
|
||||
end
|
||||
|
||||
core.register_chatcommand("env_setup", {
|
||||
params = "<environment name>",
|
||||
description = "Set up and modify AdvTrains LuaAutomation environment",
|
||||
privs = {atlatc=true},
|
||||
func = function(name, param)
|
||||
local env=atlatc.envs[param]
|
||||
if not env then return false,"Invalid environment name!" end
|
||||
minetest.show_formspec(name, "atlatc_envsetup_"..param, get_init_form(env, name))
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("env_create", {
|
||||
params = "<environment name>",
|
||||
description = "Create an AdvTrains LuaAutomation environment",
|
||||
privs = {atlatc=true},
|
||||
func = function(name, param)
|
||||
if not param or param=="" then return false, "Name required!" end
|
||||
if atlatc.envs[param] then return false, "Environment already exists!" end
|
||||
atlatc.envs[param] = atlatc.env_new(param)
|
||||
return true, "Created environment '"..param.."'. Use '/env_setup "..param.."' to define global initialization code, or start building LuaATC components!"
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
local pname=player:get_player_name()
|
||||
if not minetest.check_player_privs(pname, {atlatc=true}) then return end
|
||||
|
||||
local envname=string.match(formname, "^atlatc_delconfirm_(.+)$")
|
||||
if envname and fields.sure=="YES" then
|
||||
atlatc.envs[envname]=nil
|
||||
minetest.chat_send_player(pname, "Environment deleted!")
|
||||
return
|
||||
end
|
||||
|
||||
envname=string.match(formname, "^atlatc_envsetup_(.+)$")
|
||||
if not envname then return end
|
||||
|
||||
local env=atlatc.envs[envname]
|
||||
if not env then return end
|
||||
|
||||
if fields.del then
|
||||
minetest.show_formspec(pname, "atlatc_delconfirm_"..envname, "field[sure;"..minetest.formspec_escape("SURE TO DELETE ENVIRONMENT "..envname.."? Type YES (all uppercase) to continue or just quit form to cancel.")..";]")
|
||||
return
|
||||
end
|
||||
|
||||
env.init_err=nil
|
||||
if fields.code then
|
||||
env.init_code=fields.code
|
||||
end
|
||||
if fields.run then
|
||||
env:run_initcode()
|
||||
minetest.show_formspec(pname, formname, get_init_form(env, pname))
|
||||
end
|
||||
end)
|
4
advtrains_modpack/advtrains_luaautomation/depends.txt
Normal file
@ -0,0 +1,4 @@
|
||||
advtrains
|
||||
advtrains_interlocking?
|
||||
advtrains_line_automation?
|
||||
mesecons_switch?
|
362
advtrains_modpack/advtrains_luaautomation/environment.lua
Normal file
@ -0,0 +1,362 @@
|
||||
-------------
|
||||
-- lua sandboxed environment
|
||||
|
||||
-- function to cross out functions and userdata.
|
||||
-- modified from dump()
|
||||
function atlatc.remove_invalid_data(o, nested)
|
||||
if o==nil then return nil end
|
||||
local valid_dt={["nil"]=true, boolean=true, number=true, string=true}
|
||||
if type(o) ~= "table" then
|
||||
--check valid data type
|
||||
if not valid_dt[type(o)] then
|
||||
return nil
|
||||
end
|
||||
return o
|
||||
end
|
||||
-- Contains table -> true/nil of currently nested tables
|
||||
nested = nested or {}
|
||||
if nested[o] then
|
||||
return nil
|
||||
end
|
||||
nested[o] = true
|
||||
for k, v in pairs(o) do
|
||||
v = atlatc.remove_invalid_data(v, nested)
|
||||
end
|
||||
nested[o] = nil
|
||||
return o
|
||||
end
|
||||
|
||||
|
||||
local env_proto={
|
||||
load = function(self, envname, data)
|
||||
self.name=envname
|
||||
self.sdata=data.sdata and atlatc.remove_invalid_data(data.sdata) or {}
|
||||
self.fdata={}
|
||||
self.init_code=data.init_code or ""
|
||||
self.step_code=data.step_code or ""
|
||||
end,
|
||||
save = function(self)
|
||||
-- throw any function values out of the sdata table
|
||||
self.sdata = atlatc.remove_invalid_data(self.sdata)
|
||||
return {sdata = self.sdata, init_code=self.init_code, step_code=self.step_code}
|
||||
end,
|
||||
}
|
||||
|
||||
--Environment
|
||||
--Code modified from mesecons_luacontroller (credit goes to Jeija and mesecons contributors)
|
||||
|
||||
local safe_globals = {
|
||||
"assert", "error", "ipairs", "next", "pairs", "select",
|
||||
"tonumber", "tostring", "type", "unpack", "_VERSION"
|
||||
}
|
||||
|
||||
--print is actually minetest.chat_send_all()
|
||||
--using advtrains.print_concat_table because it's cool
|
||||
local function safe_print(t, ...)
|
||||
local str=advtrains.print_concat_table({t, ...})
|
||||
minetest.log("action", "[atlatc] "..str)
|
||||
minetest.chat_send_all(str)
|
||||
end
|
||||
|
||||
local function safe_date(f, t)
|
||||
if not f then
|
||||
-- fall back to old behavior
|
||||
return(os.date("*t",os.time()))
|
||||
else
|
||||
--pass parameters
|
||||
return os.date(f,t)
|
||||
end
|
||||
end
|
||||
|
||||
-- string.rep(str, n) with a high value for n can be used to DoS
|
||||
-- the server. Therefore, limit max. length of generated string.
|
||||
local function safe_string_rep(str, n)
|
||||
if #str * n > 2000 then
|
||||
debug.sethook() -- Clear hook
|
||||
error("string.rep: string length overflow", 2)
|
||||
end
|
||||
|
||||
return string.rep(str, n)
|
||||
end
|
||||
|
||||
-- string.find with a pattern can be used to DoS the server.
|
||||
-- Therefore, limit string.find to patternless matching.
|
||||
-- Note: Disabled security since there are enough security leaks and this would be unneccessary anyway to DoS the server
|
||||
local function safe_string_find(...)
|
||||
--if (select(4, ...)) ~= true then
|
||||
-- debug.sethook() -- Clear hook
|
||||
-- error("string.find: 'plain' (fourth parameter) must always be true for security reasons.")
|
||||
--end
|
||||
|
||||
return string.find(...)
|
||||
end
|
||||
|
||||
local mp=minetest.get_modpath("advtrains_luaautomation")
|
||||
|
||||
local static_env = {
|
||||
--core LUA functions
|
||||
print = safe_print,
|
||||
string = {
|
||||
byte = string.byte,
|
||||
char = string.char,
|
||||
format = string.format,
|
||||
len = string.len,
|
||||
lower = string.lower,
|
||||
upper = string.upper,
|
||||
rep = safe_string_rep,
|
||||
reverse = string.reverse,
|
||||
sub = string.sub,
|
||||
find = safe_string_find,
|
||||
},
|
||||
math = {
|
||||
abs = math.abs,
|
||||
acos = math.acos,
|
||||
asin = math.asin,
|
||||
atan = math.atan,
|
||||
atan2 = math.atan2,
|
||||
ceil = math.ceil,
|
||||
cos = math.cos,
|
||||
cosh = math.cosh,
|
||||
deg = math.deg,
|
||||
exp = math.exp,
|
||||
floor = math.floor,
|
||||
fmod = math.fmod,
|
||||
frexp = math.frexp,
|
||||
huge = math.huge,
|
||||
ldexp = math.ldexp,
|
||||
log = math.log,
|
||||
log10 = math.log10,
|
||||
max = math.max,
|
||||
min = math.min,
|
||||
modf = math.modf,
|
||||
pi = math.pi,
|
||||
pow = math.pow,
|
||||
rad = math.rad,
|
||||
random = math.random,
|
||||
sin = math.sin,
|
||||
sinh = math.sinh,
|
||||
sqrt = math.sqrt,
|
||||
tan = math.tan,
|
||||
tanh = math.tanh,
|
||||
},
|
||||
table = {
|
||||
concat = table.concat,
|
||||
insert = table.insert,
|
||||
maxn = table.maxn,
|
||||
remove = table.remove,
|
||||
sort = table.sort,
|
||||
},
|
||||
os = {
|
||||
clock = os.clock,
|
||||
difftime = os.difftime,
|
||||
time = os.time,
|
||||
date = safe_date,
|
||||
},
|
||||
POS = function(x,y,z) return {x=x, y=y, z=z} end,
|
||||
getstate = advtrains.getstate,
|
||||
setstate = advtrains.setstate,
|
||||
is_passive = advtrains.is_passive,
|
||||
--interrupts are handled per node, position unknown. (same goes for digilines)
|
||||
--however external interrupts can be set here.
|
||||
interrupt_pos = function(parpos, imesg)
|
||||
local pos=atlatc.pcnaming.resolve_pos(parpos)
|
||||
atlatc.interrupt.add(0, pos, {type="ext_int", ext_int=true, message=imesg})
|
||||
end,
|
||||
}
|
||||
|
||||
-- If interlocking is present, enable route setting functions
|
||||
if advtrains.interlocking then
|
||||
local function gen_checks(signal, route_name, noroutesearch)
|
||||
assertt(route_name, "string")
|
||||
local pos = atlatc.pcnaming.resolve_pos(signal)
|
||||
local sigd = advtrains.interlocking.db.get_sigd_for_signal(pos)
|
||||
if not sigd then
|
||||
error("There's no signal at "..minetest.pos_to_string(pos))
|
||||
end
|
||||
local tcbs = advtrains.interlocking.db.get_tcbs(sigd)
|
||||
if not tcbs then
|
||||
error("Inconsistent configuration, no tcbs for signal at "..minetest.pos_to_string(pos))
|
||||
end
|
||||
|
||||
local routeid, route
|
||||
if not noroutesearch then
|
||||
for routeidt, routet in ipairs(tcbs.routes) do
|
||||
if routet.name == route_name then
|
||||
routeid = routeidt
|
||||
route = routet
|
||||
break
|
||||
end
|
||||
end
|
||||
if not route then
|
||||
error("No route called "..route_name.." at "..minetest.pos_to_string(pos))
|
||||
end
|
||||
end
|
||||
return pos, sigd, tcbs, routeid, route
|
||||
end
|
||||
|
||||
|
||||
static_env.can_set_route = function(signal, route_name)
|
||||
local pos, sigd, tcbs, routeid, route = gen_checks(signal, route_name)
|
||||
-- if route is already set on signal, return whether it's committed
|
||||
if tcbs.routeset == routeid then
|
||||
return tcbs.route_committed
|
||||
end
|
||||
-- actually try setting route (parameter 'true' designates try-run
|
||||
local ok = advtrains.interlocking.route.set_route(sigd, route, true)
|
||||
return ok
|
||||
end
|
||||
static_env.set_route = function(signal, route_name)
|
||||
local pos, sigd, tcbs, routeid, route = gen_checks(signal, route_name)
|
||||
return advtrains.interlocking.route.update_route(sigd, tcbs, routeid)
|
||||
end
|
||||
static_env.cancel_route = function(signal)
|
||||
local pos, sigd, tcbs, routeid, route = gen_checks(signal, "", true)
|
||||
return advtrains.interlocking.route.update_route(sigd, tcbs, nil, true)
|
||||
end
|
||||
static_env.get_aspect = function(signal)
|
||||
local pos = atlatc.pcnaming.resolve_pos(signal)
|
||||
return advtrains.interlocking.signal_get_aspect(pos)
|
||||
end
|
||||
static_env.set_aspect = function(signal, asp)
|
||||
local pos = atlatc.pcnaming.resolve_pos(signal)
|
||||
return advtrains.interlocking.signal_set_aspect(pos)
|
||||
end
|
||||
end
|
||||
|
||||
-- Lines-specific:
|
||||
if advtrains.lines then
|
||||
local atlrwt = advtrains.lines.rwt
|
||||
static_env.rwt = {
|
||||
now = atlrwt.now,
|
||||
new = atlrwt.new,
|
||||
copy = atlrwt.copy,
|
||||
to_table = atlrwt.to_table,
|
||||
to_secs = atlrwt.to_secs,
|
||||
to_string = atlrwt.to_string,
|
||||
add = atlrwt.add,
|
||||
diff = atlrwt.diff,
|
||||
sub = atlrwt.sub,
|
||||
adj_diff = atlrwt.adj_diff,
|
||||
adjust_cycle = atlrwt.adjust_cycle,
|
||||
adjust = atlrwt.adjust,
|
||||
to_string = atlrwt.to_string,
|
||||
get_time_until = atlrwt.get_time_until,
|
||||
next_rpt = atlrwt.next_rpt,
|
||||
last_rpt = atlrwt.last_rpt,
|
||||
time_from_last_rpt = atlrwt.time_from_last_rpt,
|
||||
time_to_next_rpt = atlrwt.time_to_next_rpt,
|
||||
}
|
||||
end
|
||||
|
||||
for _, name in pairs(safe_globals) do
|
||||
static_env[name] = _G[name]
|
||||
end
|
||||
|
||||
|
||||
--The environment all code calls get is a table that has set static_env as metatable.
|
||||
--In general, every variable is local to a single code chunk, but kept persistent over code re-runs. Data is also saved, but functions and userdata and circular references are removed
|
||||
--Init code and step code's environments are not saved
|
||||
-- S - Table that can contain any save data global to the environment. Will be saved statically. Can't contain functions or userdata or circular references.
|
||||
-- F - Table global to the environment, can contain volatile data that is deleted when server quits.
|
||||
-- The init code should populate this table with functions and other definitions.
|
||||
|
||||
local proxy_env={}
|
||||
--proxy_env gets a new metatable in every run, but is the shared environment of all functions ever defined.
|
||||
|
||||
-- returns: true, fenv if successful; nil, error if error
|
||||
function env_proto:execute_code(localenv, code, evtdata, customfct)
|
||||
local metatbl ={
|
||||
__index = function(t, i)
|
||||
if i=="S" then
|
||||
return self.sdata
|
||||
elseif i=="F" then
|
||||
return self.fdata
|
||||
elseif i=="event" then
|
||||
return evtdata
|
||||
elseif customfct and customfct[i] then
|
||||
return customfct[i]
|
||||
elseif localenv and localenv[i] then
|
||||
return localenv[i]
|
||||
end
|
||||
return static_env[i]
|
||||
end,
|
||||
__newindex = function(t, i, v)
|
||||
if i=="S" or i=="F" or i=="event" or (customfct and customfct[i]) or static_env[i] then
|
||||
debug.sethook()
|
||||
error("Trying to overwrite environment contents")
|
||||
end
|
||||
localenv[i]=v
|
||||
end,
|
||||
}
|
||||
setmetatable(proxy_env, metatbl)
|
||||
local fun, err=loadstring(code)
|
||||
if not fun then
|
||||
return false, err
|
||||
end
|
||||
|
||||
setfenv(fun, proxy_env)
|
||||
local succ, data = pcall(fun)
|
||||
if succ then
|
||||
data=localenv
|
||||
end
|
||||
return succ, data
|
||||
end
|
||||
|
||||
function env_proto:run_initcode()
|
||||
if self.init_code and self.init_code~="" then
|
||||
local old_fdata=self.fdata
|
||||
self.fdata = {}
|
||||
atprint("[atlatc]Running initialization code for environment '"..self.name.."'")
|
||||
local succ, err = self:execute_code({}, self.init_code, {type="init", init=true})
|
||||
if not succ then
|
||||
atwarn("[atlatc]Executing InitCode for '"..self.name.."' failed:"..err)
|
||||
self.init_err=err
|
||||
if old_fdata then
|
||||
self.fdata=old_fdata
|
||||
atwarn("[atlatc]The 'F' table has been restored to the previous state.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function env_proto:run_stepcode()
|
||||
if self.step_code and self.step_code~="" then
|
||||
local succ, err = self:execute_code({}, self.step_code, nil, {})
|
||||
if not succ then
|
||||
--TODO
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- class interface
|
||||
|
||||
function atlatc.env_new(name)
|
||||
local newenv={
|
||||
name=name,
|
||||
init_code="",
|
||||
step_code="",
|
||||
sdata={}
|
||||
}
|
||||
setmetatable(newenv, {__index=env_proto})
|
||||
return newenv
|
||||
end
|
||||
function atlatc.env_load(name, data)
|
||||
local newenv={}
|
||||
setmetatable(newenv, {__index=env_proto})
|
||||
newenv:load(name, data)
|
||||
return newenv
|
||||
end
|
||||
|
||||
function atlatc.run_initcode()
|
||||
for envname, env in pairs(atlatc.envs) do
|
||||
env:run_initcode()
|
||||
end
|
||||
end
|
||||
function atlatc.run_stepcode()
|
||||
for envname, env in pairs(atlatc.envs) do
|
||||
env:run_stepcode()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
110
advtrains_modpack/advtrains_luaautomation/init.lua
Normal file
@ -0,0 +1,110 @@
|
||||
-- advtrains_luaautomation/init.lua
|
||||
-- Lua automation features for advtrains
|
||||
-- Uses global table 'atlatc' (AdvTrains_LuaATC)
|
||||
|
||||
-- Boilerplate to support localized strings if intllib mod is installed.
|
||||
if minetest.get_modpath("intllib") then
|
||||
atltrans = intllib.Getter()
|
||||
else
|
||||
atltrans = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
|
||||
end
|
||||
|
||||
--Privilege
|
||||
--Only trusted players should be enabled to build stuff which can break the server.
|
||||
|
||||
atlatc = { envs = {}}
|
||||
|
||||
minetest.register_privilege("atlatc", { description = "Player can place and modify LUA ATC components. Grant with care! Allows to execute bad LUA code.", give_to_singleplayer = false, default= false })
|
||||
|
||||
--assertt helper. error if a variable is not of a type
|
||||
function assertt(var, typ)
|
||||
if type(var)~=typ then
|
||||
error("Assertion failed, variable has to be of type "..typ)
|
||||
end
|
||||
end
|
||||
|
||||
local mp=minetest.get_modpath("advtrains_luaautomation")
|
||||
if not mp then
|
||||
error("Mod name error: Mod folder is not named 'advtrains_luaautomation'!")
|
||||
end
|
||||
dofile(mp.."/environment.lua")
|
||||
dofile(mp.."/interrupt.lua")
|
||||
dofile(mp.."/active_common.lua")
|
||||
dofile(mp.."/atc_rail.lua")
|
||||
dofile(mp.."/operation_panel.lua")
|
||||
dofile(mp.."/pcnaming.lua")
|
||||
if mesecon then
|
||||
dofile(mp.."/p_mesecon_iface.lua")
|
||||
end
|
||||
dofile(mp.."/chatcmds.lua")
|
||||
|
||||
|
||||
local filename=minetest.get_worldpath().."/advtrains_luaautomation"
|
||||
|
||||
function atlatc.load()
|
||||
local file, err = io.open(filename, "r")
|
||||
if not file then
|
||||
minetest.log("error", " Failed to read advtrains_luaautomation save data from file "..filename..": "..(err or "Unknown Error"))
|
||||
else
|
||||
atprint("luaautomation reading file:",filename)
|
||||
local tbl = minetest.deserialize(file:read("*a"))
|
||||
if type(tbl) == "table" then
|
||||
if tbl.version==1 then
|
||||
for envname, data in pairs(tbl.envs) do
|
||||
atlatc.envs[envname]=atlatc.env_load(envname, data)
|
||||
end
|
||||
atlatc.active.load(tbl.active)
|
||||
atlatc.interrupt.load(tbl.interrupt)
|
||||
atlatc.pcnaming.load(tbl.pcnaming)
|
||||
end
|
||||
else
|
||||
minetest.log("error", " Failed to read advtrains_luaautomation save data from file "..filename..": Not a table!")
|
||||
end
|
||||
file:close()
|
||||
end
|
||||
-- run init code of all environments
|
||||
atlatc.run_initcode()
|
||||
end
|
||||
|
||||
|
||||
atlatc.save = function()
|
||||
--versions:
|
||||
-- 1 - Initial save format.
|
||||
|
||||
local envdata={}
|
||||
for envname, env in pairs(atlatc.envs) do
|
||||
envdata[envname]=env:save()
|
||||
end
|
||||
local save_tbl={
|
||||
version = 1,
|
||||
envs=envdata,
|
||||
active = atlatc.active.save(),
|
||||
interrupt = atlatc.interrupt.save(),
|
||||
pcnaming = atlatc.pcnaming.save(),
|
||||
}
|
||||
|
||||
local datastr = minetest.serialize(save_tbl)
|
||||
if not datastr then
|
||||
minetest.log("error", " Failed to save advtrains_luaautomation save data to file "..filename..": Can't serialize!")
|
||||
return
|
||||
end
|
||||
local file, err = io.open(filename, "w")
|
||||
if err then
|
||||
minetest.log("error", " Failed to save advtrains_luaautomation save data to file "..filename..": "..(err or "Unknown Error"))
|
||||
return
|
||||
end
|
||||
file:write(datastr)
|
||||
file:close()
|
||||
end
|
||||
|
||||
|
||||
-- globalstep for step code
|
||||
local timer, step_int=0, 2
|
||||
|
||||
function atlatc.mainloop_stepcode(dtime)
|
||||
timer=timer+dtime
|
||||
if timer>step_int then
|
||||
timer=0
|
||||
atlatc.run_stepcode()
|
||||
end
|
||||
end
|
46
advtrains_modpack/advtrains_luaautomation/interrupt.lua
Normal file
@ -0,0 +1,46 @@
|
||||
-- interrupt.lua
|
||||
-- implements interrupt queue
|
||||
|
||||
--to be saved: pos and evtdata
|
||||
local iq={}
|
||||
local queue={}
|
||||
local timer=0
|
||||
local run=false
|
||||
|
||||
function iq.load(data)
|
||||
local d=data or {}
|
||||
queue = d.queue or {}
|
||||
timer = d.timer or 0
|
||||
end
|
||||
function iq.save()
|
||||
return {queue = queue, timer=timer}
|
||||
end
|
||||
|
||||
function iq.add(t, pos, evtdata)
|
||||
queue[#queue+1]={t=t+timer, p=pos, e=evtdata}
|
||||
run=true
|
||||
end
|
||||
|
||||
function iq.mainloop(dtime)
|
||||
timer=timer + math.min(dtime, 0.2)
|
||||
for i=1,#queue do
|
||||
local qe=queue[i]
|
||||
if not qe then
|
||||
table.remove(queue, i)
|
||||
i=i-1
|
||||
elseif timer>qe.t then
|
||||
local pos, evtdata=queue[i].p, queue[i].e
|
||||
local node=advtrains.ndb.get_node(pos)
|
||||
local ndef=minetest.registered_nodes[node.name]
|
||||
if ndef and ndef.luaautomation and ndef.luaautomation.fire_event then
|
||||
ndef.luaautomation.fire_event(pos, evtdata)
|
||||
end
|
||||
table.remove(queue, i)
|
||||
i=i-1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
atlatc.interrupt=iq
|
@ -0,0 +1,28 @@
|
||||
|
||||
local function on_punch(pos, player)
|
||||
atlatc.interrupt.add(0, pos, {type="punch", punch=true})
|
||||
end
|
||||
|
||||
|
||||
minetest.register_node("advtrains_luaautomation:oppanel", {
|
||||
drawtype = "normal",
|
||||
tiles={"atlatc_oppanel.png"},
|
||||
description = "LuaAutomation operation panel",
|
||||
groups = {
|
||||
cracky = 1,
|
||||
save_in_nodedb=1,
|
||||
},
|
||||
after_place_node = atlatc.active.after_place_node,
|
||||
after_dig_node = atlatc.active.after_dig_node,
|
||||
on_receive_fields = atlatc.active.on_receive_fields,
|
||||
on_punch = on_punch,
|
||||
luaautomation = {
|
||||
fire_event=atlatc.active.run_in_env
|
||||
},
|
||||
digiline = {
|
||||
receptor = {},
|
||||
effector = {
|
||||
action = atlatc.active.on_digiline_receive
|
||||
},
|
||||
},
|
||||
})
|
@ -0,0 +1,53 @@
|
||||
-- p_mesecon_iface.lua
|
||||
-- Mesecons interface by overriding the switch
|
||||
|
||||
if not mesecon then return end
|
||||
|
||||
minetest.override_item("mesecons_switch:mesecon_switch_off", {
|
||||
groups = {
|
||||
dig_immediate=2,
|
||||
save_in_nodedb=1,
|
||||
},
|
||||
on_rightclick = function (pos, node)
|
||||
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_on", param2=node.param2})
|
||||
mesecon.receptor_on(pos)
|
||||
minetest.sound_play("mesecons_switch", {pos=pos})
|
||||
end,
|
||||
on_updated_from_nodedb = function(pos, node)
|
||||
mesecon.receptor_off(pos)
|
||||
end,
|
||||
luaautomation = {
|
||||
getstate = "off",
|
||||
setstate = function(pos, node, newstate)
|
||||
if newstate=="on" then
|
||||
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_on", param2=node.param2})
|
||||
mesecon.receptor_on(pos)
|
||||
end
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
minetest.override_item("mesecons_switch:mesecon_switch_on", {
|
||||
groups = {
|
||||
dig_immediate=2,
|
||||
save_in_nodedb=1,
|
||||
not_in_creative_inventory=1,
|
||||
},
|
||||
on_rightclick = function (pos, node)
|
||||
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2})
|
||||
mesecon.receptor_off(pos)
|
||||
minetest.sound_play("mesecons_switch", {pos=pos})
|
||||
end,
|
||||
on_updated_from_nodedb = function(pos, node)
|
||||
mesecon.receptor_on(pos)
|
||||
end,
|
||||
luaautomation = {
|
||||
getstate = "on",
|
||||
setstate = function(pos, node, newstate)
|
||||
if newstate=="off" then
|
||||
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2})
|
||||
mesecon.receptor_off(pos)
|
||||
end
|
||||
end,
|
||||
},
|
||||
})
|
24
advtrains_modpack/advtrains_luaautomation/passive_api.txt
Normal file
@ -0,0 +1,24 @@
|
||||
Lua Automation - Passive Component API
|
||||
|
||||
Passive components are nodes that do not have code running in them. However, active components can query these and request actions from them. Examples:
|
||||
Switches
|
||||
Signals
|
||||
Displays
|
||||
Mesecon Transmitter
|
||||
Those passive components can also be used inside interlocking systems.
|
||||
|
||||
All passive components have a table called 'advtrains' in their node definition and have the group 'save_in_nodedb' set, so they work in unloaded chunks.
|
||||
Example for a switch:
|
||||
advtrains = {
|
||||
getstate = function(pos, node)
|
||||
return "st"
|
||||
end,
|
||||
-- OR
|
||||
getstate = "st",
|
||||
|
||||
setstate = function(pos, node, newstate)
|
||||
if newstate=="cr" then
|
||||
advtrains.ndb.swap_node(pos, <corresponding switch alt>)
|
||||
end
|
||||
end
|
||||
}
|
76
advtrains_modpack/advtrains_luaautomation/pcnaming.lua
Normal file
@ -0,0 +1,76 @@
|
||||
--pcnaming.lua
|
||||
--a.k.a Passive component naming
|
||||
--Allows to assign names to passive components, so they can be called like:
|
||||
--setstate("iamasignal", "green")
|
||||
atlatc.pcnaming={name_map={}}
|
||||
function atlatc.pcnaming.load(stuff)
|
||||
if type(stuff)=="table" then
|
||||
atlatc.pcnaming.name_map=stuff
|
||||
end
|
||||
end
|
||||
function atlatc.pcnaming.save()
|
||||
return atlatc.pcnaming.name_map
|
||||
end
|
||||
|
||||
function atlatc.pcnaming.resolve_pos(pos, func_name)
|
||||
if type(pos)=="string" then
|
||||
local e = atlatc.pcnaming.name_map[pos]
|
||||
if e then return e end
|
||||
elseif type(pos)=="table" and pos.x and pos.y and pos.z then
|
||||
return pos
|
||||
end
|
||||
error("Invalid position supplied to " .. (func_name or "???")..": " .. dump(pos))
|
||||
end
|
||||
|
||||
minetest.register_craftitem("advtrains_luaautomation:pcnaming",{
|
||||
description = attrans("Passive Component Naming Tool\n\nRight-click to name a passive component."),
|
||||
groups = {cracky=1}, -- key=name, value=rating; rating=1..3.
|
||||
inventory_image = "atlatc_pcnaming.png",
|
||||
wield_image = "atlatc_pcnaming.png",
|
||||
stack_max = 1,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pname = placer:get_player_name()
|
||||
if not pname then
|
||||
return
|
||||
end
|
||||
if not minetest.check_player_privs(pname, {atlatc=true}) then
|
||||
minetest.chat_send_player(pname, "Missing privilege: atlatc")
|
||||
return
|
||||
end
|
||||
if pointed_thing.type=="node" then
|
||||
local pos=pointed_thing.under
|
||||
if advtrains.is_protected(pos, pname) then
|
||||
minetest.record_protection_violation(pos, pname)
|
||||
return
|
||||
end
|
||||
local node = advtrains.ndb.get_node(pos)
|
||||
if node.name and (minetest.get_item_group(node.name, "advtrains_signal")>0 or advtrains.is_passive(pos)) then
|
||||
--look if this one already has a name
|
||||
local pn=""
|
||||
for name, npos in pairs(atlatc.pcnaming.name_map) do
|
||||
if vector.equals(npos, pos) then
|
||||
pn=name
|
||||
end
|
||||
end
|
||||
minetest.show_formspec(pname, "atlatc_naming_"..minetest.pos_to_string(pos), "field[pn;Set name of component (empty to clear);"..pn.."]")
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local pts=string.match(formname, "^atlatc_naming_(.+)")
|
||||
if pts then
|
||||
local pos=minetest.string_to_pos(pts)
|
||||
if fields.pn then
|
||||
--first remove all occurences
|
||||
for name, npos in pairs(atlatc.pcnaming.name_map) do
|
||||
if vector.equals(npos, pos) then
|
||||
atlatc.pcnaming.name_map[name]=nil
|
||||
end
|
||||
end
|
||||
if fields.pn~="" then
|
||||
atlatc.pcnaming.name_map[fields.pn]=pos
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
After Width: | Height: | Size: 631 B |
After Width: | Height: | Size: 329 B |
3
bees/depends.txt
Normal file
@ -0,0 +1,3 @@
|
||||
default
|
||||
intllib?
|
||||
lucky_block?
|
1
bees/description.txt
Normal file
@ -0,0 +1 @@
|
||||
This mod adds bees and beehives into minetest
|
1243
bees/init.lua
Normal file
21
bees/license.txt
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 TenPlus1
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
22
bees/locale/template.txt
Normal file
@ -0,0 +1,22 @@
|
||||
# Template
|
||||
|
||||
Bees =
|
||||
Honey Extractor =
|
||||
Wild Bee Hive =
|
||||
Artificial Bee Hive =
|
||||
Industrial Bee Hive =
|
||||
Colony died, not enough flowers in area! =
|
||||
Requires Queen bee to function =
|
||||
Progress =
|
||||
Does not have empty frame(s) =
|
||||
Queen inserted, now for empty frames =
|
||||
Bees are aclimating =
|
||||
Empty hive frame =
|
||||
Filled hive frame =
|
||||
Honey Bottle =
|
||||
Bees wax =
|
||||
Honey comb =
|
||||
Queen Bee =
|
||||
Smoker =
|
||||
Grafting tool =
|
||||
[MOD] Bees Loaded! =
|
1
bees/mod.conf
Normal file
@ -0,0 +1 @@
|
||||
name = bees
|
104
bees/readme.txt
Normal file
@ -0,0 +1,104 @@
|
||||
BEES MOD V2.3
|
||||
-------------
|
||||
|
||||
FEATURES
|
||||
--------
|
||||
|
||||
2.3
|
||||
- protection check when opening artificial/industrial hives
|
||||
- protection check when removing items from extractor
|
||||
- Intllib support (template added)
|
||||
- Wild hives are removed if found floating in mid air
|
||||
- Change compatibility abm to lbm
|
||||
- Change from WTFPL to MIT license
|
||||
- Make wild hive abm less intensive (thanks VanessaE)
|
||||
- Added 9x Lucky Blocks
|
||||
- Smokers have 200 uses before breaking
|
||||
|
||||
2.2.2
|
||||
- Pipeworks compatibility (Industrial beehive)
|
||||
|
||||
2.2.1
|
||||
- removed steel dependency temporarily
|
||||
- fixed the craft for the extractor (and added alias for)
|
||||
|
||||
2.2
|
||||
- craft for extractor
|
||||
- extractor texture update
|
||||
- a craft for the smoker
|
||||
|
||||
2.1
|
||||
- bees polinate flowers nearby, causing them to multiply
|
||||
- add formspec to wild and artificial hive when using grafting tool
|
||||
- smoke, flying wax and bee particles
|
||||
- smokers to calm down the bees before opening the hive
|
||||
- a centrifuge to extract the honey and from the filled frames
|
||||
- grab eatable honeycomb from wild hives
|
||||
- craft a grafting tool to extract queen bees from wild hives
|
||||
- craft artificial hives and frames
|
||||
|
||||
1.0
|
||||
- spawn wild bee hives on tree leaves
|
||||
- use the queen bee to populate artificial hives
|
||||
- plant flowers near hives to increase their productivity
|
||||
- spawning bee colonies
|
||||
|
||||
FUTURE
|
||||
------
|
||||
- more realistic spawning of wild bee hives
|
||||
|
||||
CONTRIBUTORS
|
||||
------------
|
||||
- bas080
|
||||
- VanessaE (wild bee hive nodebox)
|
||||
- Neuromancer (textures for wild bee hive and inspiration for other textures)
|
||||
- Novatux (enabled pipeworks compatibility)
|
||||
- TenPlus1 (tweaked and tidied code, protection check)
|
||||
|
||||
FORUM
|
||||
-----
|
||||
https://forum.minetest.net/viewtopic.php?pid=102905
|
||||
|
||||
LICENSE
|
||||
-------
|
||||
- codes is WTFPL
|
||||
- textures are CC BY-SA
|
||||
|
||||
CRAFTS
|
||||
------
|
||||
|
||||
Honey Extractor: S = steel ingot, T = stick, M = mese crystal
|
||||
|
||||
_ S _
|
||||
S T S
|
||||
M S M
|
||||
|
||||
Empty Frame: W = wood, S = stick
|
||||
|
||||
W W W
|
||||
S S S
|
||||
S S S
|
||||
|
||||
Grafting Tool: S = steel ingot, T = stick
|
||||
|
||||
_ S
|
||||
T _
|
||||
|
||||
Artificial Beehive: W = wood, S = stick
|
||||
|
||||
W W W
|
||||
W S W
|
||||
W S W
|
||||
|
||||
Smoker: S = steel ingot, T = torch, R = red wool
|
||||
|
||||
S R
|
||||
_ T
|
||||
_ S
|
||||
|
||||
Industrial Beehive: S = steel ingot, P = plastic sheeting, H = artificial hive,
|
||||
P = pipeworks tube
|
||||
|
||||
S P S
|
||||
T H T
|
||||
S P S
|
BIN
bees/screenshot.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
bees/sounds/bees.1.ogg
Normal file
BIN
bees/sounds/bees.2.ogg
Normal file
BIN
bees/sounds/bees.3.ogg
Normal file
BIN
bees/textures/bees_bottle_honey.png
Normal file
After Width: | Height: | Size: 460 B |
BIN
bees/textures/bees_comb.png
Normal file
After Width: | Height: | Size: 628 B |
BIN
bees/textures/bees_extractor.png
Normal file
After Width: | Height: | Size: 366 B |
BIN
bees/textures/bees_extractor_front.png
Normal file
After Width: | Height: | Size: 445 B |
BIN
bees/textures/bees_frame_empty.png
Normal file
After Width: | Height: | Size: 642 B |
BIN
bees/textures/bees_frame_full.png
Normal file
After Width: | Height: | Size: 543 B |
BIN
bees/textures/bees_grafting_tool.png
Normal file
After Width: | Height: | Size: 200 B |
BIN
bees/textures/bees_hive_artificial.png
Normal file
After Width: | Height: | Size: 477 B |
BIN
bees/textures/bees_hive_industrial.png
Normal file
After Width: | Height: | Size: 346 B |
BIN
bees/textures/bees_hive_wild.png
Normal file
After Width: | Height: | Size: 465 B |
BIN
bees/textures/bees_hive_wild_bottom.png
Normal file
After Width: | Height: | Size: 582 B |
BIN
bees/textures/bees_hive_wild_s.png
Normal file
After Width: | Height: | Size: 135 B |
BIN
bees/textures/bees_particle_bee.png
Normal file
After Width: | Height: | Size: 200 B |
BIN
bees/textures/bees_particle_bee_r.png
Normal file
After Width: | Height: | Size: 202 B |
BIN
bees/textures/bees_smoke_particle.png
Normal file
After Width: | Height: | Size: 378 B |
BIN
bees/textures/bees_smoker.png
Normal file
After Width: | Height: | Size: 697 B |
BIN
bees/textures/bees_strip.png
Normal file
After Width: | Height: | Size: 336 B |
BIN
bees/textures/bees_wax.png
Normal file
After Width: | Height: | Size: 502 B |
BIN
bees/textures/bees_wax_particle.png
Normal file
After Width: | Height: | Size: 255 B |
19
christmas_decor/LICENSE.txt
Normal file
@ -0,0 +1,19 @@
|
||||
MIT Copyright 2017 GreenDimond
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
135
christmas_decor/README.md
Normal file
@ -0,0 +1,135 @@
|
||||
____ _ _ _ _ ____
|
||||
/ ___| | | |_ __(_)___| |_ _ __ ___ __ _ ___ | _ \ ___ ___ ___ _ __
|
||||
| | | |_| | '__| / __| __| '_ ` _ \ / _` / __| | | | |/ _ \/ __/ _ \| '__|
|
||||
| |___| _ | | | \__ \ |_| | | | | | (_| \__ \ | |_| | __/ (_| (_) | |
|
||||
\____|_| |_|_| |_|___/\__|_| |_| |_|\__,_|___/ |____/ \___|\___\___/|_| ~By GreenDimond
|
||||
|
||||
'Tis the season!
|
||||
This mod adds some Christmas decorations :D
|
||||
|
||||
Depends on 3d_armor, homedecor, farming_redo, stairs_redo, mobs_redo, mobs_animal,
|
||||
dye, wool, bucket, vessels, xpanes, farming, and default.
|
||||
|
||||
This mod contains the following:
|
||||
* Stocking*
|
||||
* Christmas Lights (and craftitems)
|
||||
* White
|
||||
* Multicolor
|
||||
* Icicle (white)
|
||||
* Bulb (multicolor)
|
||||
* Pane version of above
|
||||
* Garland
|
||||
* Garland with lights
|
||||
* Gingerbread Cookies (and craftitems)
|
||||
* Plate of cookies (decorational)
|
||||
* Glass of milk (decorational)
|
||||
* Candycane (edible)
|
||||
* Santa Claus mob (non-moving)
|
||||
* Reindeer mob (non-moving, has animations)
|
||||
* Santa hat (wearable)
|
||||
* Candycane (placeable - noncraftable)
|
||||
* Frosting nodes (noncraftable)
|
||||
* Candycane nodes (noncraftable)
|
||||
* Mistletoe
|
||||
|
||||
*Stockings are pretty cool. They will automatically fill once Christmas arrives,
|
||||
or at least that is the idea. Extensive testing has supposedly confirmed this,
|
||||
but we'll see what happens :P The stocking by default is set to fill with
|
||||
200 gold ingots, 20 candycanes, and a full set of mese tools. These can
|
||||
be edited on lines 42-53 of stocking.lua. Each player is also only allowed
|
||||
to place one stocking, and there is bunches of stuff in place to make sure
|
||||
other players can't steal from stockings and can't dig other people's, etc...
|
||||
|
||||
This is the part where I have to type out all the craft recipes.
|
||||
|
||||
* Stocking:
|
||||
(r = red wool, w = white wool)
|
||||
```
|
||||
+-+-+-+
|
||||
|w|w| |
|
||||
+-+-+-+
|
||||
|r|r| |
|
||||
+-+-+-+
|
||||
|r|r|r|
|
||||
+-+-+-+
|
||||
```
|
||||
(reverse works too)
|
||||
|
||||
* Christmas lights:
|
||||
Forget it, just look on these lines in the init.lua:
|
||||
L 123-161
|
||||
L 290-324
|
||||
|
||||
* Garland:
|
||||
(p = pine needles)
|
||||
```
|
||||
+-+-+-+
|
||||
|p|p|p|
|
||||
+-+-+-+
|
||||
```
|
||||
(combine with 3 white LED's to make garland with lights)
|
||||
|
||||
* Ginger:
|
||||
(p = plastic sheeting, b = brown dye, o = orange dye)
|
||||
```
|
||||
+-+-+-+
|
||||
|p|o|p|
|
||||
+-+-+-+
|
||||
|p|b|p|
|
||||
+-+-+-+
|
||||
```
|
||||
(orange and brown dye can switch places)
|
||||
|
||||
* Cookiecutter:
|
||||
(s = steel ingot)
|
||||
```
|
||||
+-+-+-+
|
||||
| |s| |
|
||||
+-+-+-+
|
||||
|s|s|s|
|
||||
+-+-+-+
|
||||
|s| |s|
|
||||
+-+-+-+
|
||||
```
|
||||
|
||||
* Gingerbread dough:
|
||||
Combine ginger, bucket of water, flour, and sugar.
|
||||
|
||||
* Raw Gingerbread Man:
|
||||
Combine cookiecutter and gingerbread dough.
|
||||
Cook to obtain gingerbread man.
|
||||
Combine gingerbread man with cutlery set to get a plate of cookies.
|
||||
|
||||
* Glass of milk:
|
||||
Combine bucket of milk and a drinking glass.
|
||||
|
||||
* Candycane:
|
||||
Combine candycane base with red and white dye.
|
||||
|
||||
* Candycane base:
|
||||
(s = sugar)
|
||||
```
|
||||
+-+-+-+
|
||||
| |s| |
|
||||
+-+-+-+
|
||||
|s| |s|
|
||||
+-+-+-+
|
||||
|s| | |
|
||||
+-+-+-+
|
||||
```
|
||||
(reverse works too)
|
||||
|
||||
* Santa hat:
|
||||
(w = white wool, r = red wool)
|
||||
```
|
||||
+-+-+-+
|
||||
| |w| |
|
||||
+-+-+-+
|
||||
| |r| |
|
||||
+-+-+-+
|
||||
|r|r|r|
|
||||
+-+-+-+
|
||||
```
|
||||
|
||||
* Mistletoe:
|
||||
Combine 2 normal leaves and red dye.
|
11
christmas_decor/depends.txt
Normal file
@ -0,0 +1,11 @@
|
||||
default
|
||||
stairs
|
||||
xpanes
|
||||
3d_armor
|
||||
mobs
|
||||
wool
|
||||
bucket
|
||||
farming
|
||||
basic_materials
|
||||
vessels
|
||||
mobs_animal
|
1
christmas_decor/description.txt
Normal file
@ -0,0 +1 @@
|
||||
Adds Christmas-themed stuff :D
|
542
christmas_decor/init.lua
Normal file
@ -0,0 +1,542 @@
|
||||
local christmas_decor = {}
|
||||
|
||||
-- Candycane Blocks
|
||||
minetest.register_node("christmas_decor:candycane_block", {
|
||||
description = "Candycane Block",
|
||||
tiles = {"candycane_block.png", "candycane_block.png", "candycane_block.png", "candycane_block.png", "candycane_block.png^[transformFX", "candycane_block.png^[transformFX"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy = 3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
stairs.register_all("candycane", "christmas_decor:candycane_block",
|
||||
{snappy = 3},
|
||||
{"candycane_block.png", "candycane_block.png", "candycane_block.png", "candycane_block.png", "candycane_block.png^[transformFX", "candycane_block.png^[transformFX"},
|
||||
"Candycane",
|
||||
stairs.stone)
|
||||
|
||||
minetest.register_node("christmas_decor:candycane", {
|
||||
description = "Candycane (placeable)",
|
||||
drawtype = "mesh",
|
||||
mesh = "candycane.obj",
|
||||
tiles = {"candycane.png"},
|
||||
inventory_image = "inv_candycane.png",
|
||||
walkable = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3},
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3},
|
||||
},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy = 3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
-- Frosting Blocks
|
||||
minetest.register_node("christmas_decor:frosting_block", {
|
||||
description = "Frosting Block",
|
||||
tiles = {"frosting.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy = 3},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
stairs.register_all("frosting_block", "christmas_decor:frosting_block",
|
||||
{snappy = 3},
|
||||
{"frosting.png"},
|
||||
"Frosting",
|
||||
stairs.leaves)
|
||||
|
||||
-- Garland
|
||||
minetest.register_node("christmas_decor:garland", {
|
||||
description = "Garland",
|
||||
tiles = {"garland.png"},
|
||||
inventory_image = "garland.png",
|
||||
wield_image = "garland.png",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
climbable = false,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
},
|
||||
legacy_wallmounted = true,
|
||||
use_texture_alpha = true,
|
||||
drawtype = "signlike",
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
groups = {snappy = 3},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("christmas_decor:garland_lights", {
|
||||
description = "Garland with Lights",
|
||||
tiles = {
|
||||
{
|
||||
image = "garland_lights.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 64,
|
||||
aspect_h = 64,
|
||||
length = 16
|
||||
},
|
||||
}
|
||||
},
|
||||
inventory_image = "inv_garland_lights.png",
|
||||
wield_image = "inv_garland_lights.png",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
climbable = false,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
},
|
||||
legacy_wallmounted = true,
|
||||
use_texture_alpha = true,
|
||||
drawtype = "signlike",
|
||||
paramtype = "light",
|
||||
light_source = 8,
|
||||
paramtype2 = "wallmounted",
|
||||
groups = {snappy = 3},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:garland 3",
|
||||
recipe = {
|
||||
{"default:pine_needles", "default:pine_needles", "default:pine_needles"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:garland_lights",
|
||||
type = "shapeless",
|
||||
recipe = {"christmas_decor:garland", "christmas_decor:led_white", "christmas_decor:led_white", "christmas_decor:led_white"},
|
||||
})
|
||||
|
||||
-- Lights
|
||||
minetest.register_craftitem("christmas_decor:led_rgb", {
|
||||
description = "RGB Led Light",
|
||||
inventory_image = "led_rgb.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("christmas_decor:led_white", {
|
||||
description = "White Led Light",
|
||||
inventory_image = "led_white.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:led_rgb",
|
||||
type = "shapeless",
|
||||
recipe = {"christmas_decor:led_white", "dye:green", "dye:blue", "dye:red"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:led_white 8",
|
||||
recipe = {
|
||||
{"default:glass"},
|
||||
{"homedecor:power_crystal"},
|
||||
{"homedecor:plastic_sheeting"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("christmas_decor:wire", {
|
||||
description = "Wire",
|
||||
inventory_image = "wire.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:wire 16",
|
||||
recipe = {
|
||||
{"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting"},
|
||||
{"homedecor:copper_strip", "homedecor:copper_strip", "homedecor:copper_strip"},
|
||||
{"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting"},
|
||||
},
|
||||
})
|
||||
|
||||
local function register_lights(desc, nodename, aspect, length, def, craftitem, original_def)
|
||||
minetest.register_node("christmas_decor:lights_"..nodename, {
|
||||
description = desc.." Christmas Lights",
|
||||
tiles = {
|
||||
{
|
||||
image = "lights_"..nodename..".png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = aspect,
|
||||
aspect_h = aspect,
|
||||
length = length
|
||||
},
|
||||
}
|
||||
},
|
||||
inventory_image = "inv_lights_"..nodename..".png",
|
||||
wield_image = "inv_lights_"..nodename..".png",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
climbable = false,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
},
|
||||
legacy_wallmounted = true,
|
||||
use_texture_alpha = true,
|
||||
drawtype = "signlike",
|
||||
paramtype = "light",
|
||||
light_source = 10,
|
||||
paramtype2 = "wallmounted",
|
||||
groups = {snappy = 3},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
xpanes.register_pane("lights_"..nodename.."_pane", {
|
||||
description = desc.." Christmas Lights (pane)",
|
||||
textures = {
|
||||
{
|
||||
image = "lights_"..nodename..".png^[transformFX",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = aspect,
|
||||
aspect_h = aspect,
|
||||
length = length
|
||||
},
|
||||
},
|
||||
{
|
||||
image = "lights_"..nodename..".png^[transformFX",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = aspect,
|
||||
aspect_h = aspect,
|
||||
length = length
|
||||
},
|
||||
}, "xpanes_space.png"
|
||||
|
||||
},
|
||||
use_texture_alpha = true,
|
||||
groups = {snappy = 3},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
recipe = {
|
||||
{"christmas_decor:lights_"..nodename, "christmas_decor:lights_"..nodename, "christmas_decor:lights_"..nodename},
|
||||
{"christmas_decor:lights_"..nodename, "christmas_decor:lights_"..nodename, "christmas_decor:lights_"..nodename}
|
||||
}
|
||||
})
|
||||
|
||||
local tileFX = {
|
||||
name = "lights_"..nodename..".png^[transformFX",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.3
|
||||
}
|
||||
}
|
||||
|
||||
local tile = {
|
||||
name = "lights_"..nodename..".png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.3
|
||||
}
|
||||
}
|
||||
|
||||
for i = 1, 15 do
|
||||
minetest.override_item("xpanes:lights_" .. nodename .. "_pane_" .. i, {
|
||||
tiles = {"xpanes_space.png", "xpanes_space.png", tile, tile, tileFX, tile},
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
light_source = 10,
|
||||
})
|
||||
end
|
||||
|
||||
minetest.override_item("xpanes:lights_"..nodename.."_pane", {
|
||||
tiles = {"xpanes_space.png", "xpanes_space.png", tile, tile, tileFX, tile},
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
light_source = 10,
|
||||
})
|
||||
|
||||
minetest.override_item("xpanes:lights_"..nodename.."_pane_flat", {
|
||||
tiles = {"xpanes_space.png", "xpanes_space.png", tile, tile, tileFX, tile},
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
light_source = 10,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "xpanes:lights_" .. nodename .. "_pane_flat 6",
|
||||
recipe = {
|
||||
{"christmas_decor:lights_"..nodename, "christmas_decor:lights_"..nodename, "christmas_decor:lights_"..nodename},
|
||||
{"christmas_decor:lights_"..nodename, "christmas_decor:lights_"..nodename, "christmas_decor:lights_"..nodename}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
register_lights("White", "white", 16, 6)
|
||||
register_lights("White Icicle", "white_icicle", 16, 6)
|
||||
register_lights("Multicolor", "multicolor", 16, 6)
|
||||
register_lights("Multicolor Bulb", "multicolor_bulb", 8, 3)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:lights_white 6",
|
||||
recipe = {
|
||||
{"christmas_decor:led_white", "christmas_decor:led_white", "christmas_decor:led_white"},
|
||||
{"christmas_decor:wire", "christmas_decor:wire", "christmas_decor:wire"},
|
||||
{"christmas_decor:led_white", "christmas_decor:led_white", "christmas_decor:led_white"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:lights_white_icicle 6",
|
||||
recipe = {
|
||||
{"christmas_decor:wire", "christmas_decor:wire", "christmas_decor:wire"},
|
||||
{"christmas_decor:led_white", "christmas_decor:led_white", "christmas_decor:led_white"},
|
||||
{"christmas_decor:led_white", "christmas_decor:led_white", "christmas_decor:led_white"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:lights_multicolor 6",
|
||||
recipe = {
|
||||
{"christmas_decor:led_rgb", "christmas_decor:led_rgb", "christmas_decor:led_rgb"},
|
||||
{"christmas_decor:wire", "christmas_decor:wire", "christmas_decor:wire"},
|
||||
{"christmas_decor:led_rgb", "christmas_decor:led_rgb", "christmas_decor:led_rgb"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:lights_multicolor_bulb 6",
|
||||
recipe = {
|
||||
{"christmas_decor:led_rgb", "default:glass", "christmas_decor:led_rgb"},
|
||||
{"christmas_decor:wire", "christmas_decor:wire", "christmas_decor:wire"},
|
||||
{"christmas_decor:led_rgb", "default:glass", "christmas_decor:led_rgb"},
|
||||
},
|
||||
})
|
||||
|
||||
-- Stocking
|
||||
dofile(minetest.get_modpath("christmas_decor").."/stocking.lua")
|
||||
|
||||
-- Apparel
|
||||
minetest.register_tool("christmas_decor:helmet_santa_hat", {
|
||||
description = "Santa Hat",
|
||||
inventory_image = "inv_helmet_santa_hat.png",
|
||||
groups = {
|
||||
armor_head = 0,
|
||||
armor_heal = 0,
|
||||
armor_use = 0,
|
||||
},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:helmet_santa_hat",
|
||||
recipe = {
|
||||
{"", "wool:white", ""},
|
||||
{"", "wool:red", ""},
|
||||
{"wool:red", "wool:red", "wool:red"},
|
||||
},
|
||||
})
|
||||
|
||||
-- Eddibles
|
||||
minetest.register_craftitem("christmas_decor:candycane_edible", {
|
||||
description = "Candycane",
|
||||
inventory_image = "candycane_eddible.png",
|
||||
on_use = minetest.item_eat(4),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("christmas_decor:candycane_base", {
|
||||
description = "Candycane Base",
|
||||
inventory_image = "candycane_base.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("christmas_decor:gingerbread_man", {
|
||||
description = "Gingerbread Man",
|
||||
inventory_image = "gingerbread_man.png",
|
||||
on_use = minetest.item_eat(6),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("christmas_decor:gingerbread_man_raw", {
|
||||
description = "Gingerbread Man (raw)",
|
||||
inventory_image = "gingerbread_man_raw.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("christmas_decor:gingerbread_dough", {
|
||||
description = "Gingerbread Dough",
|
||||
inventory_image = "gingerbread_dough.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("christmas_decor:ginger", {
|
||||
description = "Ginger",
|
||||
inventory_image = "ginger.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("christmas_decor:cookiecutter", {
|
||||
description = "Cookiecutter",
|
||||
inventory_image = "cookie_cutter.png",
|
||||
})
|
||||
|
||||
minetest.register_node("christmas_decor:plate_with_cookies", {
|
||||
description = "Plate of Cookies (decorative)",
|
||||
tiles = {"plate_top.png"},
|
||||
inventory_image = "plate_top.png",
|
||||
wield_imagte = "plate_top.png",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
climbable = false,
|
||||
is_ground_content = false,
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
},
|
||||
legacy_wallmounted = true,
|
||||
use_texture_alpha = true,
|
||||
drawtype = "signlike",
|
||||
paramtype2 = "wallmounted",
|
||||
groups = {snappy = 3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("christmas_decor:milk_glass", {
|
||||
description = "Glass of Milk (decorative)",
|
||||
drawtype = "plantlike",
|
||||
tiles = {"milk_glass.png"},
|
||||
inventory_image = "milk_glass_inv.png",
|
||||
wield_image = "milk_glass.png",
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
|
||||
},
|
||||
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:plate_with_cookies",
|
||||
type = "shapeless",
|
||||
recipe = {"christmas_decor:gingerbread_man", "christmas_decor:gingerbread_man", "christmas_decor:gingerbread_man", "farming:cutting_board"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:milk_glass",
|
||||
type = "shapeless",
|
||||
recipe = {"vessels:drinking_glass", "mobs:bucket_milk"},
|
||||
replacements = {{"mobs:bucket_milk", "bucket:bucket_empty"}},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:ginger",
|
||||
recipe = {
|
||||
{"homedecor:plastic_sheeting", "dye:orange", "homedecor:plastic_sheeting"},
|
||||
{"homedecor:plastic_sheeting", "dye:brown", "homedecor:plastic_sheeting"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:ginger",
|
||||
recipe = {
|
||||
{"homedecor:plastic_sheeting", "dye:brown", "homedecor:plastic_sheeting"},
|
||||
{"homedecor:plastic_sheeting", "dye:orange", "homedecor:plastic_sheeting"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:gingerbread_dough",
|
||||
type = "shapeless",
|
||||
recipe = {"christmas_decor:ginger", "farming:flour", "bucket:bucket_water", "farming:sugar"},
|
||||
replacements = {{"bucket:bucket_water", "bucket:bucket_empty"}},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:cookiecutter 1",
|
||||
recipe = {
|
||||
{"", "default:steel_ingot", ""},
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:gingerbread_man_raw 5",
|
||||
type = "shapeless",
|
||||
recipe = {"christmas_decor:cookiecutter", "christmas_decor:gingerbread_dough"},
|
||||
replacements = {{"christmas_decor:cookiecutter", "christmas_decor:cookiecutter"}},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "christmas_decor:gingerbread_man",
|
||||
recipe = "christmas_decor:gingerbread_man_raw",
|
||||
cooktime = 10,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:candycane_base 2",
|
||||
recipe = {
|
||||
{"", "farming:sugar", ""},
|
||||
{"farming:sugar", "", "farming:sugar"},
|
||||
{"", "", "farming:sugar"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:candycane_base 2",
|
||||
recipe = {
|
||||
{"", "farming:sugar", ""},
|
||||
{"farming:sugar", "", "farming:sugar"},
|
||||
{"farming:sugar", "", ""},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:candycane_edible",
|
||||
type = "shapeless",
|
||||
recipe = {"christmas_decor:candycane_base", "dye:red", "dye:white"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:candycane_block",
|
||||
recipe = {
|
||||
{ "christmas_decor:candycane_edible", "christmas_decor:candycane_edible", "christmas_decor:candycane_edible" },
|
||||
{ "christmas_decor:candycane_edible", "christmas_decor:candycane_edible", "christmas_decor:candycane_edible" },
|
||||
{ "christmas_decor:candycane_edible", "christmas_decor:candycane_edible", "christmas_decor:candycane_edible" },
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:candycane_edible",
|
||||
type = "shapeless",
|
||||
recipe = {"christmas_decor:candycane_base", "dye:red", "dye:white"},
|
||||
})
|
||||
|
||||
|
||||
-- Mistletoe
|
||||
minetest.register_node("christmas_decor:mistletoe", {
|
||||
description = "Mistletoe",
|
||||
tiles = {"mistletoe.png"},
|
||||
drawtype = "plantlike",
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
use_texture_alpha = true,
|
||||
groups = {snappy = 3},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:mistletoe",
|
||||
type = "shapeless",
|
||||
recipe = {"default:leaves", "default:leaves", "dye:red"},
|
||||
})
|
1
christmas_decor/mod.conf
Normal file
@ -0,0 +1 @@
|
||||
name = christmas_decor
|
262
christmas_decor/models/candycane.obj
Normal file
@ -0,0 +1,262 @@
|
||||
# Blender v2.79 (sub 0) OBJ File: 'candycane.blend'
|
||||
# www.blender.org
|
||||
mtllib candycane.mtl
|
||||
o Torus
|
||||
v 0.250565 0.105750 0.000000
|
||||
v 0.225508 0.105750 0.045632
|
||||
v 0.175395 0.105750 0.045632
|
||||
v 0.150339 0.105750 0.000000
|
||||
v 0.175395 0.105750 -0.045632
|
||||
v 0.225508 0.105750 -0.045632
|
||||
v 0.250565 0.252294 0.000000
|
||||
v 0.225508 0.244153 0.045632
|
||||
v 0.175395 0.227870 0.045632
|
||||
v 0.150339 0.219729 0.000000
|
||||
v 0.175395 0.227870 -0.045632
|
||||
v 0.225508 0.244153 -0.045632
|
||||
v 0.154857 0.384024 0.000000
|
||||
v 0.139372 0.362710 0.045632
|
||||
v 0.108400 0.320081 0.045632
|
||||
v 0.092914 0.298767 0.000000
|
||||
v 0.108400 0.320081 -0.045632
|
||||
v 0.139372 0.362710 -0.045632
|
||||
v 0.000000 0.434340 0.000000
|
||||
v -0.000000 0.407994 0.045632
|
||||
v 0.000000 0.355302 0.045632
|
||||
v 0.000000 0.328957 0.000000
|
||||
v 0.000000 0.355302 -0.045632
|
||||
v 0.000000 0.407994 -0.045632
|
||||
v -0.154857 0.384024 -0.000000
|
||||
v -0.139372 0.362710 0.045632
|
||||
v -0.108400 0.320081 0.045632
|
||||
v -0.092914 0.298767 -0.000000
|
||||
v -0.108400 0.320081 -0.045632
|
||||
v -0.139372 0.362710 -0.045632
|
||||
v -0.250565 0.252294 -0.000000
|
||||
v -0.225508 0.244153 0.045632
|
||||
v -0.175395 0.227870 0.045632
|
||||
v -0.150339 0.219729 -0.000000
|
||||
v -0.175395 0.227870 -0.045632
|
||||
v -0.225508 0.244153 -0.045632
|
||||
v -0.250565 0.105750 -0.000000
|
||||
v -0.225508 0.105750 0.045632
|
||||
v -0.175395 0.105750 0.045632
|
||||
v -0.150339 0.105750 -0.000000
|
||||
v -0.175395 0.105750 -0.045632
|
||||
v -0.225508 0.105750 -0.045632
|
||||
v -0.250565 -0.499700 -0.000000
|
||||
v -0.225508 -0.499700 0.045632
|
||||
v -0.175395 -0.499700 0.045632
|
||||
v -0.150339 -0.499700 -0.000000
|
||||
v -0.175395 -0.499700 -0.045632
|
||||
v -0.225508 -0.499700 -0.045632
|
||||
v 0.200452 0.105750 0.000000
|
||||
v -0.200452 -0.499700 -0.000000
|
||||
vt 0.416667 1.416667
|
||||
vt 0.416667 1.041667
|
||||
vt 0.583333 1.041667
|
||||
vt 0.583333 1.416667
|
||||
vt 0.750000 1.041667
|
||||
vt 0.750000 1.416667
|
||||
vt 0.916667 1.041667
|
||||
vt 0.916667 1.416667
|
||||
vt -0.083333 1.416667
|
||||
vt -0.083333 1.041667
|
||||
vt 0.083333 1.041667
|
||||
vt 0.083333 1.416667
|
||||
vt 0.250000 1.041667
|
||||
vt 0.250000 1.416667
|
||||
vt 0.416667 0.666667
|
||||
vt 0.583333 0.666667
|
||||
vt 0.750000 0.666667
|
||||
vt 0.916667 0.666667
|
||||
vt -0.083333 0.666667
|
||||
vt 0.083333 0.666667
|
||||
vt 0.250000 0.666667
|
||||
vt 0.416667 0.291667
|
||||
vt 0.583333 0.291667
|
||||
vt 0.750000 0.291667
|
||||
vt 0.916667 0.291667
|
||||
vt -0.083333 0.291667
|
||||
vt 0.083333 0.291667
|
||||
vt 0.250000 0.291667
|
||||
vt 0.333333 1.333333
|
||||
vt 0.333333 0.958333
|
||||
vt 0.500000 0.958333
|
||||
vt 0.500000 1.333333
|
||||
vt 0.416667 0.458333
|
||||
vt 0.416667 0.041667
|
||||
vt 0.583333 0.041667
|
||||
vt 0.583333 0.458333
|
||||
vt 0.500000 0.541667
|
||||
vt 0.500000 0.125000
|
||||
vt 0.666667 0.125000
|
||||
vt 0.666667 0.541667
|
||||
vt 0.791667 0.416667
|
||||
vt 0.791667 0.000000
|
||||
vt 0.958333 0.000000
|
||||
vt 0.958333 0.416667
|
||||
vt 0.166667 1.208333
|
||||
vt 0.166667 0.791667
|
||||
vt 0.333333 0.791667
|
||||
vt 0.333333 1.208333
|
||||
vt 0.291667 1.250000
|
||||
vt 0.291667 0.833333
|
||||
vt 0.458333 0.833333
|
||||
vt 0.458333 1.250000
|
||||
vt 0.458333 0.500000
|
||||
vt 0.625000 0.500000
|
||||
vt 0.625000 0.833333
|
||||
vt 0.791667 0.500000
|
||||
vt 0.791667 0.833333
|
||||
vt 0.958333 0.500000
|
||||
vt 0.958333 0.833333
|
||||
vt -0.041667 0.833333
|
||||
vt -0.041667 0.500000
|
||||
vt 0.125000 0.500000
|
||||
vt 0.125000 0.833333
|
||||
vt 0.291667 0.500000
|
||||
vt 0.166667 0.958333
|
||||
vt 0.166667 0.625000
|
||||
vt 0.333333 0.625000
|
||||
vt 0.375000 0.583333
|
||||
vt 0.375000 0.208333
|
||||
vt 0.541667 0.208333
|
||||
vt 0.541667 0.583333
|
||||
vt 0.041667 1.083333
|
||||
vt 0.041667 0.708333
|
||||
vt 0.208333 0.708333
|
||||
vt 0.208333 1.083333
|
||||
vt 0.166667 1.125000
|
||||
vt 0.166667 0.750000
|
||||
vt 0.333333 0.750000
|
||||
vt 0.333333 1.125000
|
||||
vt -0.000000 0.458333
|
||||
vt -0.000000 0.083333
|
||||
vt 0.166667 0.083333
|
||||
vt 0.166667 0.458333
|
||||
vt 0.708333 0.916667
|
||||
vt 0.708333 0.541667
|
||||
vt 0.875000 0.541667
|
||||
vt 0.875000 0.916667
|
||||
vt 0.500000 0.291667
|
||||
vt 0.500000 -0.083333
|
||||
vt 0.666667 -0.083333
|
||||
vt 0.666667 0.291667
|
||||
vt 0.791667 1.291667
|
||||
vt 0.625000 1.291667
|
||||
vt 0.625000 -0.208333
|
||||
vt 0.791667 -0.208333
|
||||
vt 0.833333 1.083333
|
||||
vt 0.666667 1.083333
|
||||
vt 0.666667 -0.416667
|
||||
vt 0.833333 -0.416667
|
||||
vt 0.291667 1.291667
|
||||
vt 0.125000 1.291667
|
||||
vt 0.125000 -0.208333
|
||||
vt 0.291667 -0.208333
|
||||
vt 0.416667 1.333333
|
||||
vt 0.250000 1.333333
|
||||
vt 0.250000 -0.166667
|
||||
vt 0.416667 -0.166667
|
||||
vt 0.625000 1.625000
|
||||
vt 0.458333 1.625000
|
||||
vt 0.458333 0.125000
|
||||
vt 0.625000 0.125000
|
||||
vt 0.333333 1.083333
|
||||
vt 0.166667 1.083333
|
||||
vt 0.166667 -0.416667
|
||||
vt 0.333333 -0.416667
|
||||
vt 0.920544 0.538350
|
||||
vt 0.792915 0.617196
|
||||
vt 0.794883 0.467190
|
||||
vt 0.513294 0.488494
|
||||
vt 0.625091 0.516405
|
||||
vt 0.543776 0.604250
|
||||
vt 0.655573 0.632162
|
||||
vt 0.594609 0.400648
|
||||
vt 0.706405 0.428560
|
||||
vt 0.736887 0.544317
|
||||
vt 0.922512 0.388344
|
||||
vt 0.796851 0.317183
|
||||
vt 0.669222 0.396029
|
||||
vt 0.667254 0.546035
|
||||
vn 0.8766 0.0000 0.4813
|
||||
vn -0.0000 0.0000 1.0000
|
||||
vn -0.8766 0.0000 0.4813
|
||||
vn -0.8766 0.0000 -0.4813
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
vn 0.8766 0.0000 -0.4813
|
||||
vn 0.7091 0.5152 0.4813
|
||||
vn -0.7091 -0.5152 0.4813
|
||||
vn -0.7091 -0.5152 -0.4813
|
||||
vn 0.7091 0.5152 -0.4813
|
||||
vn 0.2709 0.8336 0.4813
|
||||
vn -0.2709 -0.8336 0.4813
|
||||
vn -0.2709 -0.8336 -0.4813
|
||||
vn 0.2709 0.8336 -0.4813
|
||||
vn -0.2709 0.8336 0.4813
|
||||
vn 0.2709 -0.8336 0.4813
|
||||
vn 0.2709 -0.8336 -0.4813
|
||||
vn -0.2709 0.8336 -0.4813
|
||||
vn -0.7091 0.5152 0.4813
|
||||
vn 0.7091 -0.5152 0.4813
|
||||
vn 0.7091 -0.5152 -0.4813
|
||||
vn -0.7091 0.5152 -0.4813
|
||||
vn 0.0000 -1.0000 0.0000
|
||||
usemtl Material
|
||||
s off
|
||||
f 1/1/1 7/2/1 8/3/1 2/4/1
|
||||
f 2/4/2 8/3/2 9/5/2 3/6/2
|
||||
f 3/6/3 9/5/3 10/7/3 4/8/3
|
||||
f 4/9/4 10/10/4 11/11/4 5/12/4
|
||||
f 5/12/5 11/11/5 12/13/5 6/14/5
|
||||
f 6/14/6 12/13/6 7/2/6 1/1/6
|
||||
f 7/2/7 13/15/7 14/16/7 8/3/7
|
||||
f 8/3/2 14/16/2 15/17/2 9/5/2
|
||||
f 9/5/8 15/17/8 16/18/8 10/7/8
|
||||
f 10/10/9 16/19/9 17/20/9 11/11/9
|
||||
f 11/11/5 17/20/5 18/21/5 12/13/5
|
||||
f 12/13/10 18/21/10 13/15/10 7/2/10
|
||||
f 13/15/11 19/22/11 20/23/11 14/16/11
|
||||
f 14/16/2 20/23/2 21/24/2 15/17/2
|
||||
f 15/17/12 21/24/12 22/25/12 16/18/12
|
||||
f 16/19/13 22/26/13 23/27/13 17/20/13
|
||||
f 17/20/5 23/27/5 24/28/5 18/21/5
|
||||
f 18/21/14 24/28/14 19/22/14 13/15/14
|
||||
f 19/29/15 25/30/15 26/31/15 20/32/15
|
||||
f 20/33/2 26/34/2 27/35/2 21/36/2
|
||||
f 21/37/16 27/38/16 28/39/16 22/40/16
|
||||
f 22/41/17 28/42/17 29/43/17 23/44/17
|
||||
f 23/45/5 29/46/5 30/47/5 24/48/5
|
||||
f 24/49/18 30/50/18 25/51/18 19/52/18
|
||||
f 25/51/19 31/53/19 32/54/19 26/55/19
|
||||
f 26/55/2 32/54/2 33/56/2 27/57/2
|
||||
f 27/57/20 33/56/20 34/58/20 28/59/20
|
||||
f 28/60/21 34/61/21 35/62/21 29/63/21
|
||||
f 29/63/5 35/62/5 36/64/5 30/50/5
|
||||
f 30/65/22 36/66/22 31/67/22 25/30/22
|
||||
f 31/68/3 37/69/3 38/70/3 32/71/3
|
||||
f 32/72/2 38/73/2 39/74/2 33/75/2
|
||||
f 33/76/1 39/77/1 40/78/1 34/79/1
|
||||
f 34/80/6 40/81/6 41/82/6 35/83/6
|
||||
f 35/84/5 41/85/5 42/86/5 36/87/5
|
||||
f 36/88/4 42/89/4 37/90/4 31/91/4
|
||||
f 40/92/1 39/93/1 45/94/1 46/95/1
|
||||
f 39/96/2 38/97/2 44/98/2 45/99/2
|
||||
f 37/100/4 42/101/4 48/102/4 43/103/4
|
||||
f 38/104/3 37/105/3 43/106/3 44/107/3
|
||||
f 41/108/6 40/109/6 46/110/6 47/111/6
|
||||
f 42/112/5 41/113/5 47/114/5 48/115/5
|
||||
f 46/116/23 45/117/23 50/118/23
|
||||
f 1/119/23 49/120/23 6/121/23
|
||||
f 6/121/23 49/120/23 5/122/23
|
||||
f 49/120/23 2/123/23 3/124/23
|
||||
f 5/122/23 49/120/23 4/125/23
|
||||
f 49/120/23 1/119/23 2/123/23
|
||||
f 4/125/23 49/120/23 3/124/23
|
||||
f 47/126/23 50/118/23 48/127/23
|
||||
f 48/127/23 50/118/23 43/128/23
|
||||
f 50/118/23 45/117/23 44/129/23
|
||||
f 43/128/23 50/118/23 44/129/23
|
||||
f 50/118/23 47/126/23 46/116/23
|
181
christmas_decor/models/stocking.obj
Normal file
@ -0,0 +1,181 @@
|
||||
# Blender v2.79 (sub 0) OBJ File: 'stocking.blend'
|
||||
# www.blender.org
|
||||
mtllib stocking.mtl
|
||||
o Plane.001
|
||||
v 0.129377 0.450000 0.377819
|
||||
v 0.129377 0.250000 0.377819
|
||||
v -0.070623 0.450000 0.377819
|
||||
v -0.070623 0.250000 0.377819
|
||||
vt 0.666667 0.625000
|
||||
vt 0.666667 -0.000000
|
||||
vt 0.916667 -0.000000
|
||||
vt 0.916667 0.625000
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
usemtl Material
|
||||
s off
|
||||
f 1/1/1 2/2/1 4/3/1 3/4/1
|
||||
o Plane
|
||||
v 0.051900 0.510708 0.500000
|
||||
v 0.051900 0.310708 0.500000
|
||||
v 0.051900 0.510708 0.300000
|
||||
v 0.051900 0.310708 0.300000
|
||||
vt 0.812500 1.125000
|
||||
vt 0.812500 0.625000
|
||||
vt 0.979167 0.625000
|
||||
vt 0.979167 1.125000
|
||||
vn 1.0000 0.0000 0.0000
|
||||
usemtl Material
|
||||
s off
|
||||
f 5/5/2 6/6/2 8/7/2 7/8/2
|
||||
o Cube.001
|
||||
v 0.114759 -0.203590 0.462918
|
||||
v -0.114759 0.213580 0.462918
|
||||
v -0.058163 -0.248184 0.377819
|
||||
v -0.266335 0.130187 0.377819
|
||||
v 0.292921 -0.105569 0.377819
|
||||
v 0.063402 0.311601 0.377819
|
||||
v 0.114759 -0.203590 0.292720
|
||||
v -0.114759 0.213580 0.292720
|
||||
v -0.047172 0.090735 0.477512
|
||||
v -0.229301 -0.009469 0.377819
|
||||
v 0.161543 0.205565 0.377819
|
||||
v -0.047172 0.090735 0.278126
|
||||
v -0.089331 -0.315876 0.292720
|
||||
v 0.200788 -0.359955 0.462918
|
||||
v 0.318289 -0.276599 0.377819
|
||||
v 0.200788 -0.359955 0.292720
|
||||
v -0.089331 -0.315876 0.462918
|
||||
v -0.048571 -0.441585 0.462918
|
||||
v -0.048571 -0.441585 0.292720
|
||||
v -0.172480 -0.350102 0.377819
|
||||
v -0.128465 -0.468303 0.377819
|
||||
v 0.213693 -0.382983 0.377819
|
||||
v -0.045898 -0.479872 0.377819
|
||||
vt -0.000000 0.187500
|
||||
vt 0.145833 0.187500
|
||||
vt 0.145833 0.625000
|
||||
vt -0.000000 0.625000
|
||||
vt 0.145833 0.625000
|
||||
vt 0.145833 0.187500
|
||||
vt -0.000000 0.187500
|
||||
vt -0.000000 0.625000
|
||||
vt 0.208333 0.000000
|
||||
vt 0.333333 0.000000
|
||||
vt 0.333333 0.437500
|
||||
vt 0.208333 0.437500
|
||||
vt 0.333333 0.437500
|
||||
vt 0.333333 0.000000
|
||||
vt 0.208333 0.000000
|
||||
vt 0.208333 0.437500
|
||||
vt 0.333333 1.000000
|
||||
vt 0.333333 0.750000
|
||||
vt 0.062500 0.750000
|
||||
vt 0.062500 1.000000
|
||||
vt 0.666667 0.000000
|
||||
vt 0.333333 0.500000
|
||||
vt 0.666667 0.500000
|
||||
vt 0.666667 0.500000
|
||||
vt 0.333333 0.500000
|
||||
vt 0.333333 1.000000
|
||||
vt 0.666667 1.000000
|
||||
vt 0.666667 0.000000
|
||||
vt 0.333333 0.500000
|
||||
vt 0.666667 0.500000
|
||||
vt 0.666667 0.500000
|
||||
vt 0.333333 0.500000
|
||||
vt 0.333333 1.000000
|
||||
vt 0.666667 1.000000
|
||||
vt 0.291667 0.500000
|
||||
vt 0.145833 0.500000
|
||||
vt 0.145833 0.250000
|
||||
vt 0.291667 0.250000
|
||||
vt 0.145833 0.250000
|
||||
vt 0.291667 0.250000
|
||||
vt 0.291667 0.000000
|
||||
vt 0.145833 0.000000
|
||||
vt 0.333333 0.500000
|
||||
vt 0.333333 0.750000
|
||||
vt 0.062500 0.750000
|
||||
vt 0.062500 0.500000
|
||||
vt 0.333333 0.312500
|
||||
vt 0.229167 0.312500
|
||||
vt 0.229167 0.625000
|
||||
vt 0.333333 0.625000
|
||||
vt 0.125000 0.312500
|
||||
vt 0.229167 0.312500
|
||||
vt 0.229167 0.625000
|
||||
vt 0.125000 0.625000
|
||||
vt 0.145833 0.625000
|
||||
vt -0.000000 0.625000
|
||||
vt -0.000000 0.812500
|
||||
vt 0.145833 0.812500
|
||||
vt 0.145833 0.812500
|
||||
vt -0.000000 0.812500
|
||||
vt -0.000000 1.000000
|
||||
vt 0.145833 1.000000
|
||||
vt 0.020833 0.187500
|
||||
vt 0.145833 0.125000
|
||||
vt 0.145833 0.187500
|
||||
vt 0.062500 0.000000
|
||||
vt 0.062500 0.062500
|
||||
vt -0.000000 0.062500
|
||||
vt 0.125000 0.437500
|
||||
vt 0.062500 0.437500
|
||||
vt 0.062500 0.000000
|
||||
vt 0.125000 0.000000
|
||||
vt 0.020833 0.125000
|
||||
vt 0.020833 0.187500
|
||||
vt 0.145833 0.125000
|
||||
vt -0.000000 0.000000
|
||||
vt -0.000000 0.062500
|
||||
vt 0.062500 0.000000
|
||||
vt 0.062500 0.000000
|
||||
vt -0.000000 0.000000
|
||||
vt -0.000000 0.437500
|
||||
vt 0.062500 0.437500
|
||||
vn -0.3867 -0.2128 0.8973
|
||||
vn -0.3867 -0.2128 -0.8973
|
||||
vn 0.3382 0.1861 -0.9225
|
||||
vn 0.3382 0.1861 0.9225
|
||||
vn 0.0000 0.0000 1.0000
|
||||
vn -0.2906 -0.2690 0.9183
|
||||
vn 0.4290 0.1212 -0.8951
|
||||
vn -0.2906 -0.2690 -0.9183
|
||||
vn 0.4290 0.1212 0.8951
|
||||
vn -0.4254 -0.1448 -0.8933
|
||||
vn -0.4254 -0.1448 0.8933
|
||||
vn -0.0000 -0.0000 -1.0000
|
||||
vn -0.5080 0.7551 0.4146
|
||||
vn -0.5080 0.7551 -0.4146
|
||||
vn 0.6605 0.2296 0.7149
|
||||
vn 0.6605 0.2296 -0.7149
|
||||
vn -0.6834 0.6719 0.2855
|
||||
vn 0.1270 0.9061 -0.4037
|
||||
vn -0.3104 0.8849 0.3472
|
||||
vn -0.6834 0.6719 -0.2855
|
||||
vn 0.1270 0.9061 0.4037
|
||||
vn -0.3104 0.8849 -0.3472
|
||||
usemtl Material
|
||||
s off
|
||||
f 9/9/3 10/10/3 12/11/3 11/12/3
|
||||
f 11/13/4 12/14/4 16/15/4 15/16/4
|
||||
f 15/17/5 16/18/5 14/19/5 13/20/5
|
||||
f 13/21/6 14/22/6 10/23/6 9/24/6
|
||||
f 24/25/7 15/26/7 21/27/7 27/28/7
|
||||
f 14/29/8 16/18/8 20/30/8 19/31/8
|
||||
f 12/32/9 10/33/9 17/34/9 18/35/9
|
||||
f 10/36/10 14/22/10 19/37/10 17/38/10
|
||||
f 16/39/11 12/40/11 18/41/11 20/42/11
|
||||
f 9/43/12 13/44/12 23/45/12 22/46/12
|
||||
f 13/47/13 15/48/13 24/49/13 23/50/13
|
||||
f 9/51/14 22/52/14 26/53/14 25/54/14
|
||||
f 11/55/15 28/56/15 25/57/15 9/58/15
|
||||
f 11/59/16 15/60/16 21/61/16 28/62/16
|
||||
f 27/63/17 21/64/17 28/65/17 29/66/17
|
||||
f 26/67/18 29/68/18 28/69/18 25/70/18
|
||||
f 23/71/19 24/72/19 30/73/19
|
||||
f 26/74/20 31/75/20 29/76/20
|
||||
f 30/77/21 24/78/21 27/79/21 31/80/21
|
||||
f 30/81/22 22/82/22 23/83/22
|
||||
f 31/84/23 27/85/23 29/86/23
|
||||
f 31/87/24 26/88/24 22/89/24 30/90/24
|
BIN
christmas_decor/screenshot.png
Normal file
After Width: | Height: | Size: 188 KiB |
243
christmas_decor/stocking.lua
Normal file
@ -0,0 +1,243 @@
|
||||
local stocking = {}
|
||||
local stuffer = {}
|
||||
stuffer.stuffers = {}
|
||||
|
||||
function stuffer.register_stuff(name, count)
|
||||
if count == nil then count = 1 end
|
||||
local stuff = {
|
||||
name = name,
|
||||
count = count,
|
||||
metadata = "",
|
||||
}
|
||||
table.insert(stuffer.stuffers, stuff)
|
||||
end
|
||||
|
||||
function stuffer.select_stuffers(count)
|
||||
local p_stuffers = {}
|
||||
for i=1,#stuffer.stuffers do
|
||||
table.insert(p_stuffers, stuffer.stuffers[i])
|
||||
end
|
||||
local itemstacks = {}
|
||||
for i=1,#stuffer.stuffers do
|
||||
itemstacks[i] = stuffer.stuff_to_itemstack(stuffer.stuffers[i])
|
||||
end
|
||||
return itemstacks
|
||||
end
|
||||
|
||||
function stuffer.stuff_to_itemstack(stuff)
|
||||
local itemstack = {}
|
||||
itemstack.name = stuff.name
|
||||
itemstack.count = stuffer.determine_count(stuff)
|
||||
itemstack.metadata = stuff.metadata
|
||||
|
||||
return ItemStack(itemstack)
|
||||
end
|
||||
|
||||
function stuffer.determine_count(stuff)
|
||||
if(type(stuff.count)=="number") then
|
||||
return stuff.count
|
||||
end
|
||||
end
|
||||
|
||||
-- REGISTER STUFFERS BELOW HERE
|
||||
|
||||
--stuffer.register_stuff("modname:nodename", amount)
|
||||
stuffer.register_stuff("default:gold_ingot", 200)
|
||||
stuffer.register_stuff("christmas_decor:candycane_edible", 20)
|
||||
stuffer.register_stuff("default:pick_mese", 1)
|
||||
stuffer.register_stuff("default:sword_mese", 1)
|
||||
stuffer.register_stuff("default:axe_mese", 1)
|
||||
stuffer.register_stuff("default:shovel_mese", 1)
|
||||
stuffer.register_stuff("farming:hoe_mese", 1)
|
||||
|
||||
-- REGISTER STUFFERS ABOVE HERE
|
||||
|
||||
function stocking.get_stocking_formspec(pos)
|
||||
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||
local formspec =
|
||||
"size[9,9]"..
|
||||
"background[-0.8,-0.4;10,10;stocking_bg.png]"..
|
||||
"image_button_exit[7.75,1;1,1;exit_button.png;exit;]"..
|
||||
"listcolors[#D4393C;#d45658]"..
|
||||
"list[nodemeta:".. spos .. ";main;-0.2,2;8,2;]"..
|
||||
"list[current_player;main;-0.2,5;8,4;]" ..
|
||||
"listring[current_player;main]"
|
||||
return formspec
|
||||
end
|
||||
|
||||
stocking.can_dig_function = function(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local name = player and player:get_player_name()
|
||||
local owner = meta:get_string("owner")
|
||||
local inv = meta:get_inventory()
|
||||
return name == owner and inv:is_empty("main")
|
||||
end
|
||||
|
||||
local days_elapsed_in_year = function(year, month, day)
|
||||
local days_elapsed_in_month = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}
|
||||
local days_elapsed_in_leapyear_month = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}
|
||||
|
||||
local function is_leap_year(year)
|
||||
return year % 4 == 0 and (year % 100 ~= 0 or year % 400 == 0)
|
||||
end
|
||||
|
||||
if is_leap_year(year) then
|
||||
return (days_elapsed_in_leapyear_month[month] + (day - 1))
|
||||
else
|
||||
return (days_elapsed_in_month[month] + (day - 1))
|
||||
end
|
||||
end
|
||||
|
||||
local date_in_seconds = function()
|
||||
local year = tonumber(os.date("%Y"))
|
||||
local month = tonumber(os.date("%m"))
|
||||
local day = tonumber(os.date("%d"))
|
||||
local second = tonumber(os.date("%S"))
|
||||
local minute = tonumber(os.date("%M"))
|
||||
local hour = tonumber(os.date("%H"))
|
||||
return ((days_elapsed_in_year(year, month, day) * 86400) + (hour * 3600) + (minute * 60) + second)
|
||||
end
|
||||
|
||||
local christmas_date = 30931200 --Christmas date in seconds
|
||||
|
||||
check_fillable = function(pos)
|
||||
local year = tonumber(os.date("%Y"))
|
||||
local meta = minetest.get_meta(pos)
|
||||
if year == meta:get_int("fill_year") then
|
||||
if date_in_seconds() > christmas_date then
|
||||
return true
|
||||
elseif date_in_seconds() <= christmas_date then
|
||||
return false
|
||||
end
|
||||
elseif year > meta:get_int("fill_year") then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
minetest.register_node("christmas_decor:stocking", {
|
||||
description = "Stocking",
|
||||
drawtype = "mesh",
|
||||
mesh = "stocking.obj",
|
||||
tiles = {"velvet_fluff.png"},
|
||||
use_texture_alpha = true,
|
||||
inventory_image = "inv_stocking.png",
|
||||
wield_image = "inv_stocking.png",
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.4, -0.5, 0.5, 0.4, 0.5, 0.2},
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.4, -0.5, 0.5, 0.4, 0.5, 0.2},
|
||||
},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy = 3},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if player then
|
||||
minetest.chat_send_player(player:get_player_name(), "Wait until Christmas Eve for Santa to fill your stocking!")
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if minetest.is_yes(placer:get_attribute("has_placed_stocking")) then
|
||||
minetest.chat_send_player(placer:get_player_name(), "Santa won't fill more than one stocking!")
|
||||
return itemstack
|
||||
else
|
||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||
end
|
||||
end,
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local owner = placer:get_player_name()
|
||||
meta:set_string("owner", owner)
|
||||
meta:set_string("infotext", owner.."'s Stocking")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*2)
|
||||
placer:set_attribute("has_placed_stocking", "true")
|
||||
local year = tonumber(os.date("%Y"))
|
||||
if date_in_seconds() >= christmas_date then
|
||||
meta:set_int("fill_year", year + 1)
|
||||
elseif date_in_seconds() < christmas_date then
|
||||
meta:set_int("fill_year", year)
|
||||
end
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local player = clicker:get_player_name()
|
||||
local stuffers = stuffer.select_stuffers()
|
||||
local year = tonumber(os.date("%Y"))
|
||||
local owner = meta:get_string("owner")
|
||||
if owner == player then
|
||||
if check_fillable(pos) == true or clicker:get_attribute("needs_fill") == "true" then
|
||||
for i=1, #stuffers do
|
||||
inv:set_stack("main", i, stuffers[i])
|
||||
end
|
||||
if date_in_seconds() >= christmas_date then
|
||||
meta:set_int("fill_year", year + 1)
|
||||
elseif date_in_seconds() < christmas_date then
|
||||
meta:set_int("fill_year", year)
|
||||
end
|
||||
clicker:set_attribute("needs_fill", "false")
|
||||
end
|
||||
if owner == player then
|
||||
minetest.show_formspec(
|
||||
clicker:get_player_name(),
|
||||
"default:chest_locked",
|
||||
stocking.get_stocking_formspec(pos))
|
||||
else
|
||||
return itemstack
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
end,
|
||||
can_dig = stocking.can_dig_function,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index,
|
||||
to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" moves stuff in stocking at " .. minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" moves stuff to stocking at " .. minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name() ..
|
||||
" takes stuff from stocking at " .. minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_dig = function(pos, node, digger)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = digger:get_inventory()
|
||||
if stocking.can_dig_function(pos, digger) then
|
||||
if minetest.is_yes(check_fillable(pos)) then
|
||||
digger:set_attribute("needs_fill", "true")
|
||||
end
|
||||
digger:set_attribute("has_placed_stocking", "false")
|
||||
minetest.remove_node(pos)
|
||||
inv:add_item("main", "christmas_decor:stocking")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- Crafts
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:stocking",
|
||||
recipe = {
|
||||
{"", "wool:white", "wool:white"},
|
||||
{"", "wool:red", "wool:red"},
|
||||
{"wool:red", "wool:red", "wool:red"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "christmas_decor:stocking",
|
||||
recipe = {
|
||||
{"wool:white", "wool:white", ""},
|
||||
{"wool:red", "wool:red", ""},
|
||||
{"wool:red", "wool:red", "wool:red"},
|
||||
}
|
||||
})
|
BIN
christmas_decor/textures/candycane.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
christmas_decor/textures/candycane_base.png
Normal file
After Width: | Height: | Size: 264 B |
BIN
christmas_decor/textures/candycane_block.png
Normal file
After Width: | Height: | Size: 568 B |
BIN
christmas_decor/textures/candycane_eddible.png
Normal file
After Width: | Height: | Size: 314 B |
BIN
christmas_decor/textures/christmas_decor_helmet_santa_hat.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 295 B |
BIN
christmas_decor/textures/cookie_cutter.png
Normal file
After Width: | Height: | Size: 300 B |
BIN
christmas_decor/textures/exit_button.png
Normal file
After Width: | Height: | Size: 171 B |
BIN
christmas_decor/textures/frosting.png
Normal file
After Width: | Height: | Size: 542 B |
BIN
christmas_decor/textures/frosting_line.png
Normal file
After Width: | Height: | Size: 323 B |
BIN
christmas_decor/textures/frosting_trim.png
Normal file
After Width: | Height: | Size: 412 B |
BIN
christmas_decor/textures/garland.png
Normal file
After Width: | Height: | Size: 245 B |
BIN
christmas_decor/textures/garland_lights.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
christmas_decor/textures/ginger.png
Normal file
After Width: | Height: | Size: 419 B |
BIN
christmas_decor/textures/gingerbread_dough.png
Normal file
After Width: | Height: | Size: 438 B |
BIN
christmas_decor/textures/gingerbread_man.png
Normal file
After Width: | Height: | Size: 483 B |
BIN
christmas_decor/textures/gingerbread_man_raw.png
Normal file
After Width: | Height: | Size: 357 B |
BIN
christmas_decor/textures/inv_candycane.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
christmas_decor/textures/inv_garland_lights.png
Normal file
After Width: | Height: | Size: 266 B |
BIN
christmas_decor/textures/inv_helmet_santa_hat.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
christmas_decor/textures/inv_lights_multicolor.png
Normal file
After Width: | Height: | Size: 280 B |
BIN
christmas_decor/textures/inv_lights_multicolor_bulb.png
Normal file
After Width: | Height: | Size: 365 B |
BIN
christmas_decor/textures/inv_lights_white.png
Normal file
After Width: | Height: | Size: 267 B |
BIN
christmas_decor/textures/inv_lights_white_icicle.png
Normal file
After Width: | Height: | Size: 409 B |
BIN
christmas_decor/textures/inv_stocking.png
Normal file
After Width: | Height: | Size: 427 B |
BIN
christmas_decor/textures/led_rgb.png
Normal file
After Width: | Height: | Size: 220 B |
BIN
christmas_decor/textures/led_white.png
Normal file
After Width: | Height: | Size: 208 B |
BIN
christmas_decor/textures/lights_multicolor.png
Normal file
After Width: | Height: | Size: 676 B |
BIN
christmas_decor/textures/lights_multicolor_bulb.png
Normal file
After Width: | Height: | Size: 906 B |
BIN
christmas_decor/textures/lights_white.png
Normal file
After Width: | Height: | Size: 807 B |
BIN
christmas_decor/textures/lights_white_icicle.png
Normal file
After Width: | Height: | Size: 882 B |
BIN
christmas_decor/textures/milk_glass.png
Normal file
After Width: | Height: | Size: 328 B |
BIN
christmas_decor/textures/milk_glass_inv.png
Normal file
After Width: | Height: | Size: 283 B |
BIN
christmas_decor/textures/mistletoe.png
Normal file
After Width: | Height: | Size: 392 B |
BIN
christmas_decor/textures/plate_top.png
Normal file
After Width: | Height: | Size: 713 B |
BIN
christmas_decor/textures/reindeer.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
christmas_decor/textures/santa.png
Normal file
After Width: | Height: | Size: 2.0 KiB |