Added multiplayer support (player sprites and messages saying who purchased an item). Added background images for formspec scroll containers.
parent
ce5d16a989
commit
e18588b06a
|
@ -2,4 +2,5 @@ train sound (CC0): https://freesound.org/people/SGAK/sounds/467839/
|
|||
factory sound (CC BY 3.0): https://freesound.org/people/The%20Baron/sounds/98444/
|
||||
collector sound (CC BY 3.0): https://freesound.org/people/The%20Baron/sounds/98435/
|
||||
crowd sound (CC0): https://freesound.org/people/sonically_sound/sounds/625112/
|
||||
farm sound (CC0): https://freesound.org/people/Mystikuum/sounds/401636/
|
||||
farm sound (CC0): https://freesound.org/people/Mystikuum/sounds/401636/
|
||||
player drone sprite (CC BY 4.0): https://opengameart.org/content/big-drone
|
|
@ -25,10 +25,10 @@ dofile(minetest.get_modpath("minegistics") .. DIR_DELIM .. "src" .. DIR_DELIM ..
|
|||
minetest.register_on_joinplayer(function(player)
|
||||
player:hud_set_flags({hotbar = true, healthbar = false})
|
||||
player:set_properties({
|
||||
textures = { "blank.png", "blank.png" },
|
||||
textures = { "player_drone.png", "player_drone.png" },
|
||||
visual = "upright_sprite",
|
||||
visual_size = { x = 1, y = 2 },
|
||||
collisionbox = {-0.49, 0, -0.49, 0.49, 2, 0.49 },
|
||||
visual_size = { x = 1, y = 1 },
|
||||
collisionbox = {-0.49, 0, -0.49, 0.49, 1, 0.49 },
|
||||
initial_sprite_basepos = {x = 0, y = 0}
|
||||
})
|
||||
skybox.set(player, 1)
|
||||
|
@ -91,3 +91,12 @@ end)
|
|||
minetest.register_globalstep(function(dtime)
|
||||
update_shared_hud()
|
||||
end)
|
||||
|
||||
--gets the size of a table
|
||||
function get_table_size(table)
|
||||
local size = 0
|
||||
for k,v in pairs(table) do
|
||||
size = size + 1
|
||||
end
|
||||
return size
|
||||
end
|
||||
|
|
|
@ -155,15 +155,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
if money >= item_prices[item_name] then
|
||||
if player:get_inventory():add_item("main", stack) then
|
||||
money = money - item_prices[item_name]
|
||||
minetest.chat_send_player(
|
||||
player_name,"You bought a " .. item_name .. "! " ..
|
||||
"$" .. money .. " remaining."
|
||||
local players = minetest.get_connected_players()
|
||||
local player_count = get_table_size(players)
|
||||
local purchaser = player_count > 1 and player_name or "You"
|
||||
minetest.chat_send_all(purchaser .. " bought a " ..
|
||||
item_name .. "! " .. "$" .. money .. " remaining."
|
||||
)
|
||||
local formspec = shop_formspec(player)
|
||||
player:set_inventory_formspec(table.concat(formspec, ""))
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(player_name, "You can't afford that!")
|
||||
minetest.chat_send_player(player_name, "Insufficient funds!")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
]]--
|
||||
|
||||
local abm_timer = 0
|
||||
local background = "form_bg.png"
|
||||
|
||||
minetest.register_node("minegistics:Factory", {
|
||||
description = "Factory: Combines products to create more advanced items.",
|
||||
|
@ -28,11 +29,12 @@ minetest.register_node("minegistics:Factory", {
|
|||
local formspec = {
|
||||
"size[8,9]",
|
||||
"list[context;main;0,0;8,4;]",
|
||||
"list[current_player;main;0,5;8,4;]",
|
||||
"list[current_player;main;0,5.25;8,4;]",
|
||||
"image[0,1;9,4.75;"..background.."]",
|
||||
"scroll_container[1,2;12,4;recipe_scroll;vertical;0.05]",
|
||||
"label[0,0;" .. recipe_list .. "]",
|
||||
"scroll_container_end[]",
|
||||
"scrollbar[7,1;0.25,4;vertical;recipe_scroll;0]",
|
||||
"scrollbar[6.75,1.2;0.25,3.75;vertical;recipe_scroll;0]",
|
||||
"button[3.5,10;4,2;Back;Back]"
|
||||
}
|
||||
meta:set_string("formspec", table.concat(formspec, ""))
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
--TODO Create demands of specific items
|
||||
|
||||
local abm_timer = 0
|
||||
local background = "form_bg.png"
|
||||
|
||||
minetest.register_node("minegistics:Market", {
|
||||
description = "Market: Changes any item into money.\n" ..
|
||||
|
@ -33,11 +34,12 @@ minetest.register_node("minegistics:Market", {
|
|||
local formspec = {
|
||||
"size[8,9]",
|
||||
"list[context;main;0,0;8,4;]",
|
||||
"list[current_player;main;0,5;8,4;]",
|
||||
"list[current_player;main;0,5.25;8,4;]",
|
||||
"image[0,1;9,4.75;"..background.."]",
|
||||
"scroll_container[1,2;12,4;recipe_scroll;vertical;0.05]",
|
||||
"label[0,0;" .. price_list .. "]",
|
||||
"scroll_container_end[]",
|
||||
"scrollbar[7,1;0.25,4;vertical;recipe_scroll;0]",
|
||||
"scrollbar[6.75,1.2;0.25,3.75;vertical;recipe_scroll;0]",
|
||||
"button[3.5,10;4,2;Back;Back]"
|
||||
}
|
||||
meta:set_string("formspec", table.concat(formspec, ""))
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
]]--
|
||||
|
||||
local abm_timer = 0
|
||||
local background = "form_bg.png"
|
||||
|
||||
minetest.register_node("minegistics:Workshop", {
|
||||
description = "Workshop: Converts resources into products.\n" ..
|
||||
|
@ -28,11 +29,12 @@ minetest.register_node("minegistics:Workshop", {
|
|||
local formspec = {
|
||||
"size[8,9]",
|
||||
"list[context;main;0,0;8,4;]",
|
||||
"list[current_player;main;0,5;8,4;]",
|
||||
"list[current_player;main;0,5.25;8,4;]",
|
||||
"image[0,1;9,4.75;"..background.."]",
|
||||
"scroll_container[1,2;12,4;recipe_scroll;vertical;0.05]",
|
||||
"label[0,0;" .. recipe_list .. "]",
|
||||
"scroll_container_end[]",
|
||||
"scrollbar[7,1;0.25,4;vertical;recipe_scroll;0]",
|
||||
"scrollbar[6.75,1.2;0.25,3.75;vertical;recipe_scroll;0]",
|
||||
"button[3.5,10;4,2;Back;Back]"
|
||||
}
|
||||
meta:set_string("formspec", table.concat(formspec, ""))
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Loading…
Reference in New Issue