diff --git a/README.md b/README.md index 133c777..0dd185c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This mod provides a server-wide trading exchange for items. It is available under GNU GPL version 3 or any later version. lsqlite3 is required by this mod, -and can be installed through luarocks. +and can be installed through luarocks. ($ sudo luarocks install lsqlite3) Nodes ===== @@ -98,4 +98,4 @@ is a sell offer for 5 cobblestone 3 credits each, it will give you 5 cobble immediately, and leave an order on the exchange for 5 more cobblestone. Once your offer is on the exchange, you can view or cancel it from the "Your -Orders" menu. \ No newline at end of file +Orders" menu. diff --git a/atm.lua b/atm.lua index 9c64eb4..8cd31a7 100644 --- a/atm.lua +++ b/atm.lua @@ -1,4 +1,3 @@ - -- A telling machine. Call this file with the exchange argument. local exchange = ... @@ -173,18 +172,127 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end) -minetest.register_node("global_exchange:atm", { +minetest.register_node("global_exchange:atm_bottom", { description = "ATM", - tiles = {"global_exchange_box.png", - "global_exchange_box.png", - "global_exchange_box.png^global_exchange_atm_side.png", + inventory_image = "global_exchange_atm_icon.png", + wield_image = "global_exchange_atm_hi_front.png", + drawtype = "nodebox", + tiles = { + "global_exchange_atm_lo_top.png", + "global_exchange_atm_side.png", + "global_exchange_atm_side.png", + "global_exchange_atm_side.png", + "global_exchange_atm_back.png^[transform2", + "global_exchange_atm_lo_front.png", }, - groups = {cracky=2}, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + stack_max = 1, + light_source = 3, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, + } + }, + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, + {-0.5, 0.5, -0.5, -0.375, 1.125, -0.25}, + {0.375, 0.5, -0.5, 0.5, 1.125, -0.25}, + {-0.5, 0.5, -0.25, 0.5, 1.5, 0.5}, + {-0.5, 1.125, -0.4375, -0.375, 1.25, -0.25}, + {0.375, 1.125, -0.4375, 0.5, 1.25, -0.25}, + {-0.5, 1.25, -0.375, -0.375, 1.375, -0.25}, + {0.375, 1.25, -0.375, 0.5, 1.375, -0.25}, + {-0.5, 1.375, -0.3125, -0.375, 1.5, -0.25}, + {0.375, 1.375, -0.3125, 0.5, 1.5, -0.25}, + }, + }, + on_place = function(itemstack, placer, pointed_thing) + local under = pointed_thing.under + local pos + if minetest.registered_items[minetest.get_node(under).name].buildable_to then + pos = under + else + pos = pointed_thing.above + end + if minetest.is_protected(pos, placer:get_player_name()) and + not minetest.check_player_privs(placer, "protection_bypass") then + minetest.record_protection_violation(pos, placer:get_player_name()) + return itemstack + end + local def = minetest.registered_nodes[minetest.get_node(pos).name] + if not def or not def.buildable_to then + minetest.remove_node(pos) + return itemstack + end + local dir = minetest.dir_to_facedir(placer:get_look_dir()) + local pos2 = {x = pos.x, y = pos.y + 1, z = pos.z} + local def2 = minetest.registered_nodes[minetest.get_node(pos2).name] + if not def2 or not def2.buildable_to then + return itemstack + end + minetest.set_node(pos, {name = "global_exchange:atm_bottom", param2 = dir}) + minetest.set_node(pos2, {name = "global_exchange:atm_top", param2 = dir}) + if not minetest.setting_getbool("creative_mode") then + itemstack:take_item() + return itemstack + end + end, + on_destruct = function(pos) + local pos2 = {x = pos.x, y = pos.y + 1, z = pos.z} + local n2 = minetest.get_node(pos2) + if minetest.get_item_group(n2.name, "atm") == 2 then + minetest.remove_node(pos2) + end + end, + groups = {cracky=2, atm = 1}, on_rightclick = function(pos, _, clicker) + minetest.sound_play("atm_beep", {pos = pos}) minetest.show_formspec(clicker:get_player_name(), atm_form, main_menu) end, }) +minetest.register_node("global_exchange:atm_top", { + drawtype = "nodebox", + tiles = { + "global_exchange_atm_hi_top.png", + "global_exchange_atm_side.png",--not visible anyway + "global_exchange_atm_side.png", + "global_exchange_atm_side.png", + "global_exchange_atm_back.png", + "global_exchange_atm_hi_front.png", + }, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + light_source = 3, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, -0.375, 0.125, -0.25}, + {0.375, -0.5, -0.5, 0.5, 0.125, -0.25}, + {-0.5, -0.5, -0.25, 0.5, 0.5, 0.5}, + {-0.5, 0.125, -0.4375, -0.375, 0.25, -0.25}, + {0.375, 0.125, -0.4375, 0.5, 0.25, -0.25}, + {-0.5, 0.25, -0.375, -0.375, 0.375, -0.25}, + {0.375, 0.25, -0.375, 0.5, 0.375, -0.25}, + {-0.5, 0.375, -0.3125, -0.375, 0.5, -0.25}, + {0.375, 0.375, -0.3125, 0.5, 0.5, -0.25}, + } + }, + selection_box = { + type = "fixed", + fixed = {0, 0, 0, 0, 0, 0}, + }, + groups = { + atm = 2, + not_in_creative_inventory = 1 + }, +}) minetest.register_craft( { output = "global_exchange:atm", @@ -194,3 +302,5 @@ minetest.register_craft( { { "default:stone", "default:stone", "default:stone" }, } }) + +minetest.register_alias("global_exchange:atm", "global_exchange:atm_bottom") diff --git a/sounds/LICENSE b/sounds/LICENSE new file mode 100644 index 0000000..3a7dcbe --- /dev/null +++ b/sounds/LICENSE @@ -0,0 +1,2 @@ +File atm_beep.ogg is a derivative work from a sound file 'dialing 3.aiff' uploaded by 'benjaminharveydesign' to http://freesound.org under a Creative Commons 0 license. +File atm_cash.ogg is a derivative work from a sound file 'ATM.wav' uploaded by 'LG' to http://freesound.org under a Creative Commons Attribution license. \ No newline at end of file diff --git a/sounds/atm_beep.ogg b/sounds/atm_beep.ogg new file mode 100644 index 0000000..e448eb4 Binary files /dev/null and b/sounds/atm_beep.ogg differ diff --git a/textures/global_exchange_atm_back.png b/textures/global_exchange_atm_back.png new file mode 100644 index 0000000..f7825d5 Binary files /dev/null and b/textures/global_exchange_atm_back.png differ diff --git a/textures/global_exchange_atm_hi_front.png b/textures/global_exchange_atm_hi_front.png new file mode 100644 index 0000000..f28e5c6 Binary files /dev/null and b/textures/global_exchange_atm_hi_front.png differ diff --git a/textures/global_exchange_atm_hi_top.png b/textures/global_exchange_atm_hi_top.png new file mode 100644 index 0000000..bb716e5 Binary files /dev/null and b/textures/global_exchange_atm_hi_top.png differ diff --git a/textures/global_exchange_atm_icon.png b/textures/global_exchange_atm_icon.png new file mode 100644 index 0000000..4d4cc7f Binary files /dev/null and b/textures/global_exchange_atm_icon.png differ diff --git a/textures/global_exchange_atm_lo_front.png b/textures/global_exchange_atm_lo_front.png new file mode 100644 index 0000000..070c351 Binary files /dev/null and b/textures/global_exchange_atm_lo_front.png differ diff --git a/textures/global_exchange_atm_lo_top.png b/textures/global_exchange_atm_lo_top.png new file mode 100644 index 0000000..4931879 Binary files /dev/null and b/textures/global_exchange_atm_lo_top.png differ diff --git a/textures/global_exchange_atm_side.png b/textures/global_exchange_atm_side.png index 17e2273..563b47c 100644 Binary files a/textures/global_exchange_atm_side.png and b/textures/global_exchange_atm_side.png differ diff --git a/textures/global_exchange_atm_top.png b/textures/global_exchange_atm_top.png new file mode 100644 index 0000000..8b30dba Binary files /dev/null and b/textures/global_exchange_atm_top.png differ