Initial code
parent
c68ec65af7
commit
551866c7f0
|
@ -0,0 +1,165 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
24
README.md
24
README.md
|
@ -1 +1,23 @@
|
|||
cidades
|
||||
# Cidades
|
||||
[![download](https://img.shields.io/github/tag/BrunoMine/fine_mobs.svg?style=flat-square&label=release)](https://github.com/BrunoMine/cidades/archive/master.zip)
|
||||
[![git](https://img.shields.io/badge/git-project-green.svg?style=flat-square)](https://github.com/BrunoMine/cidades)
|
||||
[![forum](https://img.shields.io/badge/minetest-mod-green.svg?style=flat-square)](https://forum.minetest.net)
|
||||
[![bower](https://img.shields.io/badge/bower-mod-green.svg?style=flat-square)](https://minetest-bower.herokuapp.com/mods/cidades)
|
||||
|
||||
## Description
|
||||
Create cities
|
||||
|
||||
## Requirements
|
||||
* Minetest 0.5.1 or higher
|
||||
* default mod
|
||||
|
||||
## License
|
||||
See LICENSE.txt for more info about LGPL 3.0 license
|
||||
|
||||
### Authors of the source code
|
||||
Originally by BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (LGPL 3.0)
|
||||
|
||||
### Authors of media (textures, models and sonds)
|
||||
All that are not described here are authored by
|
||||
BrunoMine, Bruno Borges <borgesdossantosbruno@gmail.com> (CC BY-SA 3.0)
|
||||
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
--[[
|
||||
Mod Cidades for Minetest
|
||||
Copyright (C) 2020 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||
|
||||
City Builder
|
||||
]]
|
||||
|
||||
|
||||
minetest.register_node("cidades:area_mark", {
|
||||
description = "Area Mark",
|
||||
tiles = {"cidades_area_mark.png"},
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2},
|
||||
drop = "",
|
||||
})
|
||||
|
||||
-- Mark area
|
||||
local mark_area = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local radius = meta:get_float("radius")
|
||||
local height = meta:get_float("height")
|
||||
local depth = meta:get_float("depth")
|
||||
|
||||
local minp = {
|
||||
x = pos.x - radius - 1,
|
||||
y = pos.y - depth - 1,
|
||||
z = pos.z - radius - 1,
|
||||
}
|
||||
local maxp = {
|
||||
x = pos.x + radius + 1,
|
||||
y = pos.y + height + 1,
|
||||
z = pos.z + radius + 1,
|
||||
}
|
||||
|
||||
for y = minp.y, maxp.y do
|
||||
minetest.set_node({x=maxp.x, y=y, z=maxp.z}, {name="cidades:area_mark"})
|
||||
minetest.set_node({x=maxp.x, y=y, z=minp.z}, {name="cidades:area_mark"})
|
||||
minetest.set_node({x=minp.x, y=y, z=maxp.z}, {name="cidades:area_mark"})
|
||||
minetest.set_node({x=minp.x, y=y, z=minp.z}, {name="cidades:area_mark"})
|
||||
end
|
||||
|
||||
for x = minp.x, maxp.x do
|
||||
minetest.set_node({x=x, y=maxp.y, z=maxp.z}, {name="cidades:area_mark"})
|
||||
minetest.set_node({x=x, y=maxp.y, z=minp.z}, {name="cidades:area_mark"})
|
||||
end
|
||||
for z = minp.z, maxp.z do
|
||||
minetest.set_node({x=maxp.x, y=maxp.y, z=z}, {name="cidades:area_mark"})
|
||||
minetest.set_node({x=minp.x, y=maxp.y, z=z}, {name="cidades:area_mark"})
|
||||
end
|
||||
end
|
||||
|
||||
-- Create Schematic
|
||||
local export_city = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local radius = meta:get_float("radius")
|
||||
local height = meta:get_float("height")
|
||||
local depth = meta:get_float("depth")
|
||||
|
||||
local minp = {
|
||||
x = pos.x - radius,
|
||||
y = pos.y - depth,
|
||||
z = pos.z - radius,
|
||||
}
|
||||
local maxp = {
|
||||
x = pos.x + radius,
|
||||
y = pos.y + height,
|
||||
z = pos.z + radius,
|
||||
}
|
||||
|
||||
local filename = meta:get_string("city_id")..".mts"
|
||||
|
||||
minetest.mkdir(minetest.get_worldpath().."/cities in work")
|
||||
|
||||
if minetest.create_schematic(minp, maxp, {}, minetest.get_worldpath().."/cities in work/"..filename) ~= true then
|
||||
return minetest.chat_send_all("Export failed.")
|
||||
end
|
||||
|
||||
minetest.chat_send_all("Schematic successfully exported. Restart the world to import it. "..filename.." file is in the world directory ('cities in work' folder).")
|
||||
end
|
||||
|
||||
-- Load Schematic
|
||||
local import_city = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local radius = meta:get_float("radius")
|
||||
local height = meta:get_float("height")
|
||||
local depth = meta:get_float("depth")
|
||||
|
||||
local minp = {
|
||||
x = pos.x - radius,
|
||||
y = pos.y - depth,
|
||||
z = pos.z - radius,
|
||||
}
|
||||
|
||||
local filename = meta:get_string("city_id")..".mts"
|
||||
|
||||
if minetest.place_schematic(minp, minetest.get_worldpath().."/cities in work/"..filename) ~= true then
|
||||
return minetest.chat_send_all("Import failed.")
|
||||
end
|
||||
|
||||
minetest.chat_send_all("Schematic successfully imported.")
|
||||
end
|
||||
|
||||
|
||||
-- Update formspec
|
||||
local update_formspec = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
meta:set_string("formspec", "size[8,8]"
|
||||
.."field[1,1;6,1;city_id;City ID (eg. wood_ville);"..meta:get_string("city_id").."]"
|
||||
.."field[1,4;2,1;radius;Radius;"..meta:get_float("radius").."]"
|
||||
.."field[3,4;2,1;height;Height;"..meta:get_float("height").."]"
|
||||
.."field[5,4;2,1;depth;Depth;"..meta:get_float("depth").."]"
|
||||
|
||||
.."label[0.5,5;This node is the reference for central position]"
|
||||
.."label[0.5,5.5;Spawn position for this city is 6 blocks above this block.]"
|
||||
|
||||
.."button_exit[1,7;2,1;export;Export]"
|
||||
.."button_exit[3,7;2,1;import;Import]"
|
||||
.."button_exit[5,7;2,1;mark;Mark]")
|
||||
end
|
||||
|
||||
|
||||
-- City Builder node
|
||||
minetest.register_node("cidades:city_builder", {
|
||||
description = "City Builder",
|
||||
paramtype2 = "facedir",
|
||||
place_param2 = 0,
|
||||
tiles = {"default_wood.png^default_apple.png"},
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2},
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "City Builder")
|
||||
|
||||
meta:set_string("city_id", "")
|
||||
meta:set_int("radius", 80)
|
||||
meta:set_int("height", 50)
|
||||
meta:set_int("depth", 15)
|
||||
|
||||
update_formspec(pos)
|
||||
end,
|
||||
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
|
||||
-- Check privs
|
||||
if minetest.check_player_privs(sender:get_player_name(), {server = true}) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
-- Save settings
|
||||
if fields.export or fields.import or fields.mark then
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("city_id", fields.city_id)
|
||||
meta:set_float("radius", tonumber(fields.radius))
|
||||
meta:set_float("height", tonumber(fields.height))
|
||||
meta:set_float("depth", tonumber(fields.depth))
|
||||
update_formspec(pos)
|
||||
end
|
||||
|
||||
-- Mark area
|
||||
if fields.mark then
|
||||
mark_area(pos)
|
||||
end
|
||||
|
||||
-- Import city
|
||||
if fields.import then
|
||||
import_city(pos)
|
||||
end
|
||||
|
||||
-- Export city
|
||||
if fields.export then
|
||||
export_city(pos)
|
||||
end
|
||||
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,50 @@
|
|||
--[[
|
||||
Mod Cidades for Minetest
|
||||
Copyright (C) 2020 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||
|
||||
Data Base
|
||||
]]
|
||||
|
||||
local mod_storage = minetest.get_mod_storage()
|
||||
|
||||
cidades.db = {}
|
||||
|
||||
|
||||
-- Set City def
|
||||
cidades.db.set_city = function(city_name, def)
|
||||
mod_storage:set_string("city_"..city_name, minetest.serialize(def))
|
||||
end
|
||||
|
||||
-- Get City def
|
||||
cidades.db.get_city = function(city_name)
|
||||
return minetest.deserialize(mod_storage:get_string("city_"..city_name))
|
||||
end
|
||||
|
||||
|
||||
-- Set Property def
|
||||
cidades.db.set_property = function(owner, def)
|
||||
mod_storage:set_string("property_"..owner, minetest.serialize(def))
|
||||
end
|
||||
|
||||
-- Get Property def
|
||||
cidades.db.get_property = function(owner)
|
||||
return minetest.deserialize(mod_storage:get_string("property_"..owner))
|
||||
end
|
||||
|
||||
-- Check Property
|
||||
cidades.db.check_property = function(owner)
|
||||
if mod_storage:get_string("property_"..owner) ~= "" then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
-- Active cities
|
||||
cidades.update_active_cities = function(city_name, status)
|
||||
cidades.active_cities[city_name] = status
|
||||
mod_storage:set_string("active_cities", minetest.serialize(cidades.active_cities))
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1 @@
|
|||
Cities for Multiplayer
|
|
@ -0,0 +1,31 @@
|
|||
--[[
|
||||
Mod Cidades for Minetest
|
||||
Copyright (C) 2020 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||
|
||||
]]
|
||||
|
||||
cidades = {}
|
||||
|
||||
cidades.money_item = (minetest.settings:get("cidades_money_item") or "default:apple")
|
||||
|
||||
local modpath = minetest.get_modpath("cidades")
|
||||
|
||||
dofile(modpath.."/data_base.lua")
|
||||
|
||||
dofile(modpath.."/number_nodes.lua")
|
||||
|
||||
--dofile(modpath.."/city.lua")
|
||||
dofile(modpath.."/city_builder.lua")
|
||||
--dofile(modpath.."/city_stone.lua")
|
||||
|
||||
dofile(modpath.."/property.lua")
|
||||
dofile(modpath.."/property_builder.lua")
|
||||
dofile(modpath.."/property_stone.lua")
|
||||
|
||||
--dofile(modpath.."/teleporter.lua")
|
||||
|
||||
dofile(modpath.."/seller_node.lua")
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
--[[
|
||||
Mod Cidades for Minetest
|
||||
Copyright (C) 2020 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||
|
||||
-- Number nodes
|
||||
]]
|
||||
|
||||
cidades.number_node = {}
|
||||
|
||||
for i=0, 9 do
|
||||
cidades.number_node["cidades:stone_"..i] = i
|
||||
minetest.register_node("cidades:stone_"..i, {
|
||||
description = "Stone",
|
||||
paramtype2 = "facedir",
|
||||
place_param2 = 0,
|
||||
tiles = {"default_stone.png"},
|
||||
is_ground_content = false,
|
||||
groups = {cracky = 3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
--[[
|
||||
Mod Cidades for Minetest
|
||||
Copyright (C) 2020 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||
|
||||
Property
|
||||
]]
|
||||
|
||||
|
||||
cidades.property = {}
|
||||
|
||||
|
||||
-- Radius
|
||||
cidades.property.radius = {
|
||||
["0"] = 3,
|
||||
["1"] = 4,
|
||||
["2"] = 5,
|
||||
["3"] = 6,
|
||||
["4"] = 7,
|
||||
["5"] = 8,
|
||||
["6"] = 9,
|
||||
["7"] = 10,
|
||||
["8"] = 11,
|
||||
["9"] = 12,
|
||||
}
|
||||
cidades.property.radius_i = {
|
||||
["3"] = 0,
|
||||
["4"] = 1,
|
||||
["5"] = 2,
|
||||
["6"] = 3,
|
||||
["7"] = 4,
|
||||
["8"] = 5,
|
||||
["9"] = 6,
|
||||
["10"] = 7,
|
||||
["11"] = 8,
|
||||
["12"] = 9,
|
||||
}
|
||||
|
||||
-- Height
|
||||
cidades.property.height = {
|
||||
["0"] = 3,
|
||||
["1"] = 5,
|
||||
["2"] = 8,
|
||||
["3"] = 10,
|
||||
["4"] = 12,
|
||||
["5"] = 14,
|
||||
["6"] = 16,
|
||||
["7"] = 18,
|
||||
["8"] = 20,
|
||||
["9"] = 25,
|
||||
}
|
||||
cidades.property.height_i = {
|
||||
["3"] = 0,
|
||||
["5"] = 1,
|
||||
["8"] = 2,
|
||||
["10"] = 3,
|
||||
["12"] = 4,
|
||||
["14"] = 5,
|
||||
["16"] = 6,
|
||||
["18"] = 7,
|
||||
["20"] = 8,
|
||||
["25"] = 9,
|
||||
}
|
||||
|
||||
-- Get data node
|
||||
cidades.property.get_data_pos = function(pos, data_type, def)
|
||||
def = def or 0
|
||||
|
||||
if data_type == "core" then
|
||||
return {
|
||||
x = pos.x,
|
||||
y = pos.y - def,
|
||||
z = pos.z
|
||||
}
|
||||
elseif data_type == "cost10x" then
|
||||
return {
|
||||
x = pos.x - 1,
|
||||
y = pos.y - def,
|
||||
z = pos.z - 1
|
||||
}
|
||||
elseif data_type == "cost100x" then
|
||||
return {
|
||||
x = pos.x - 1,
|
||||
y = pos.y - def,
|
||||
z = pos.z
|
||||
}
|
||||
elseif data_type == "cost1000x" then
|
||||
return {
|
||||
x = pos.x - 1,
|
||||
y = pos.y - def,
|
||||
z = pos.z + 1
|
||||
}
|
||||
elseif data_type == "height" then
|
||||
return {
|
||||
x = pos.x,
|
||||
y = pos.y - def,
|
||||
z = pos.z + 1
|
||||
}
|
||||
elseif data_type == "radius" then
|
||||
return {
|
||||
x = pos.x,
|
||||
y = pos.y - def,
|
||||
z = pos.z - 1
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- Get property data
|
||||
cidades.property.get_data = function(pos)
|
||||
local height = cidades.property.height[tostring(cidades.number_node[minetest.get_node(cidades.property.get_data_pos(pos, "height")).name])]
|
||||
local radius = cidades.property.radius[tostring(cidades.number_node[minetest.get_node(cidades.property.get_data_pos(pos, "radius")).name])]
|
||||
local cost10x = tostring(cidades.number_node[minetest.get_node(cidades.property.get_data_pos(pos, "cost10x")).name])
|
||||
local cost100x = tostring(cidades.number_node[minetest.get_node(cidades.property.get_data_pos(pos, "cost100x")).name])
|
||||
local cost1000x = tostring(cidades.number_node[minetest.get_node(cidades.property.get_data_pos(pos, "cost1000x")).name])
|
||||
local cost = tonumber(cost1000x..cost100x..cost10x.."0")
|
||||
|
||||
return {
|
||||
radius = radius,
|
||||
height = height,
|
||||
cost = cost,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
--[[
|
||||
Mod Cidades for Minetest
|
||||
Copyright (C) 2020 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||
|
||||
Property Builder
|
||||
]]
|
||||
|
||||
|
||||
|
||||
-- Create property
|
||||
local create_property = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local radius = meta:get_float("radius")
|
||||
local height = meta:get_float("height")
|
||||
local cost = meta:get_float("cost")
|
||||
-- Adjust cost
|
||||
do
|
||||
local i = ""
|
||||
if cost < 1000 then i = "0" end
|
||||
if cost < 100 then i = "00" end
|
||||
cost = i..tonumber(cost)
|
||||
end
|
||||
|
||||
local cost10x = string.sub(cost, 3, 3)
|
||||
local cost100x = string.sub(cost, 2, 2)
|
||||
local cost1000x = string.sub(cost, 1, 1)
|
||||
|
||||
-- Set data nodes
|
||||
minetest.set_node(cidades.property.get_data_pos(pos, "radius", 2), {name = "cidades:stone_"..cidades.property.radius_i[tostring(radius)]})
|
||||
minetest.set_node(cidades.property.get_data_pos(pos, "height", 2), {name = "cidades:stone_"..cidades.property.height_i[tostring(height)]})
|
||||
minetest.set_node(cidades.property.get_data_pos(pos, "cost10x", 2), {name = "cidades:stone_"..cost10x})
|
||||
minetest.set_node(cidades.property.get_data_pos(pos, "cost100x", 2), {name = "cidades:stone_"..cost100x})
|
||||
minetest.set_node(cidades.property.get_data_pos(pos, "cost1000x", 2), {name = "cidades:stone_"..cost1000x})
|
||||
minetest.set_node(cidades.property.get_data_pos(pos, "core", 2), {name = "cidades:property_stone_for_sale"})
|
||||
|
||||
-- Set seller
|
||||
minetest.set_node({x=pos.x, y=pos.y+1, z=pos.z}, {name = "cidades:seller"})
|
||||
|
||||
-- Remove property builder
|
||||
--minetest.remove_node(pos)
|
||||
|
||||
minetest.chat_send_all("Property created")
|
||||
end
|
||||
|
||||
|
||||
-- Update formspec
|
||||
local update_formspec = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
meta:set_string("formspec", "size[8,8]"
|
||||
.."field[1,3;6.5,1;radius;Radius (3 - 12);"..meta:get_float("radius").."]"
|
||||
.."field[1,4.5;6.5,1;height;Height (3, 5, 8, 10, 12, 14, 16, 18, 20 or 25);"..meta:get_float("height").."]"
|
||||
.."field[1,6;6.5,1;cost;Cost (10 - 9990);"..meta:get_float("cost").."]"
|
||||
.."button_exit[1,7;6,1;create;Create]")
|
||||
end
|
||||
|
||||
|
||||
-- Property Builder node
|
||||
minetest.register_node("cidades:property_builder", {
|
||||
description = "Property Builder",
|
||||
paramtype2 = "facedir",
|
||||
place_param2 = 0,
|
||||
tiles = {"default_wood.png^default_paper.png"},
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2},
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "Property Builder")
|
||||
|
||||
meta:set_int("radius", 4)
|
||||
meta:set_int("height", 5)
|
||||
meta:set_string("cost", "100")
|
||||
|
||||
update_formspec(pos)
|
||||
end,
|
||||
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
|
||||
-- Check privs
|
||||
if minetest.check_player_privs(sender:get_player_name(), {server = true}) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
-- Save settings
|
||||
if fields.create then
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
if cidades.property.radius_i[fields.radius] then
|
||||
meta:set_float("radius", tonumber(fields.radius))
|
||||
else
|
||||
return minetest.chat_send_all("Invalid radius")
|
||||
end
|
||||
|
||||
if cidades.property.height_i[fields.height] then
|
||||
meta:set_float("height", tonumber(fields.height))
|
||||
else
|
||||
return minetest.chat_send_all("Invalid height")
|
||||
end
|
||||
|
||||
if tonumber(fields.cost) <= 9990 and tonumber(fields.cost) >= 10 then
|
||||
meta:set_float("cost", tonumber(fields.cost))
|
||||
else
|
||||
return minetest.chat_send_all("Invalid cost")
|
||||
end
|
||||
|
||||
update_formspec(pos)
|
||||
end
|
||||
|
||||
-- Mark area
|
||||
if fields.create then
|
||||
create_property(pos)
|
||||
end
|
||||
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,33 @@
|
|||
--[[
|
||||
Mod Cidades for Minetest
|
||||
Copyright (C) 2020 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||
|
||||
Property Stone
|
||||
]]
|
||||
|
||||
|
||||
-- Property Stone for Sale
|
||||
minetest.register_node("cidades:property_stone_for_sale", {
|
||||
description = "Property Stone",
|
||||
paramtype2 = "facedir",
|
||||
place_param2 = 0,
|
||||
tiles = {"default_stone.png"},
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, stone = 1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
|
||||
-- Property Stone Purchased
|
||||
minetest.register_node("cidades:property_stone_purchased", {
|
||||
description = "Property Stone Purchased",
|
||||
paramtype2 = "facedir",
|
||||
place_param2 = 0,
|
||||
tiles = {"default_stone.png"},
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, stone = 1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
|
@ -0,0 +1,55 @@
|
|||
--[[
|
||||
Mod Cidades for Minetest
|
||||
Copyright (C) 2020 BrunoMine (https://github.com/BrunoMine)
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>5.
|
||||
|
||||
Seller node
|
||||
]]
|
||||
|
||||
|
||||
-- Access
|
||||
local seller_access = function(player, pos)
|
||||
-- Set pos
|
||||
player:set_attribute("cidades:seller_pos", minetest.serialize(pos))
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
local data = cidades.property.get_data({x=pos.x, y=pos.y-3, z=pos.z})
|
||||
local width = (data.radius * 2) + 1
|
||||
|
||||
-- Button status
|
||||
local status = "button[0,2.35;5,1;buy;Buy]"
|
||||
if cidades.db.check_property(name) ~= true then
|
||||
status = "label[0,2.35;"..minetest.colorize("#ff0707", "You already own land.")
|
||||
.."\n"..minetest.colorize("#ff0707", "Sell it to buy that one.").."]"
|
||||
end
|
||||
|
||||
minetest.show_formspec(name, "cidades:seller",
|
||||
"size[5,3]"
|
||||
.."label[0,-0.15;Land for sale"
|
||||
.."\nHeight: "..data.height
|
||||
.."\nWidth: "..width
|
||||
.."\nTotal buildable area: "..(width*width*(data.height)).." blocks"
|
||||
.."\nCost: "..data.cost.."]"
|
||||
..status
|
||||
)
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Seller node
|
||||
minetest.register_node("cidades:seller", {
|
||||
description = "Seller",
|
||||
paramtype2 = "facedir",
|
||||
place_param2 = 0,
|
||||
tiles = {"default_wood.png^default_coal_lump.png"},
|
||||
is_ground_content = false,
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2},
|
||||
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
seller_access(clicker, pos)
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,6 @@
|
|||
# Configurações aplicaveis para o menu gráfico
|
||||
# Settings applicable from Minetest GUI
|
||||
|
||||
# Cow Spawn
|
||||
# Higher values increase the population of spawned cow around the world
|
||||
cow_spawn_chance (Cow Spawn) int 2
|
Binary file not shown.
After Width: | Height: | Size: 120 B |
Loading…
Reference in New Issue