Compare commits

...

5 Commits

Author SHA1 Message Date
root ce0811c0c3 downgrade to minetest 5.4 2021-12-08 19:10:44 +01:00
root 0e8c42ccc7 spawned merchants 2021-08-21 10:44:35 +02:00
root 34c13aa8f0 spawned merchants 2021-08-21 10:33:56 +02:00
root c10dc54519 spawned merchants 2021-08-21 01:57:18 +02:00
root 3edf4e3411 spawned merchants 2021-08-21 01:42:24 +02:00
10 changed files with 127 additions and 14 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
## Generic ignorable patterns and files
user.conf

View File

@ -29,7 +29,7 @@ Hold the special key (aux) and rightclick the merchantz. It requires the server
## Spawn
By default some merchants spawn in the world.
By default some merchants spawn in the world and after a time are leaving.
See the 'eraz.conf' file to enable/disable and config.
## Licenses

View File

@ -10,6 +10,10 @@ local function is_srt_empty(s)
return s == nil or s == ''
end
local function round(x)
return x>=0 and math.floor(x+0.5) or math.ceil(x-0.5)
end
local function boolean_to_string(var)
if var or var == 1 or var == "true" then
return "true"
@ -377,7 +381,7 @@ local function compose_formspec(self, player, msg)
scroll_container[0.5,1.25;3,3;scroll_buy;vertical;]
]]..items_loot..[[
scroll_container_end[]
scrollbaroptions[min=0;max=]]..tostring(math.round(items_count))
scrollbaroptions[min=0;max=]]..tostring(round(items_count))
..[[;smallstep=]]..items_count_str..[[;largestep=]]..items_count_str..[[]
style_type[scroll_buy;bgcolor=#446699]
scrollbar[3.5,1.25;0.5,3;vertical;scroll_buy;0]
@ -385,7 +389,7 @@ local function compose_formspec(self, player, msg)
scroll_container[4.25,1.25;3,3;scroll_basket;vertical;]
]]..items_basket..[[
scroll_container_end[]
scrollbaroptions[min=0;max=]]..tostring(math.round(items_count))
scrollbaroptions[min=0;max=]]..tostring(round(items_count))
..[[;smallstep=]]..items_count_str..[[;largestep=]]..items_count_str..[[]
scrollbar[7.25,1.25;0.5,3;vertical;scroll_basket;0]
button_exit[5.125,5;1,1;btn_buy;]]..S("Buy")..[[]

View File

@ -2,11 +2,11 @@
## Enable/disable spawn
spawn = true
## Time in second
spawn_interval = 300
spawn_interval = 1200
## Chance to spawn [0.0-1.0]
spawn_chance = 0.5
## A message announcing the merchant to all the players
spawn_announce = true
## Lifetime for the merchant
## dissapearing after it
lifetime = 300
lifetime = 1200

View File

@ -20,5 +20,5 @@ if eraz.settings.spawn then
end
local user_file = modpath .. "/user.lua"
if eraz.file_exists(user_file) then
assert(loadfile(user_file))()
assert(loadfile(user_file))(S)
end

View File

@ -26,3 +26,4 @@ A new merchant has just arrived at=Un nuevo comerciante acaba de llegar a
bringing=trayendo
unknown stuff=cosas desconocidas
basic food=comida básica

View File

@ -16,3 +16,4 @@ eraz.register_loot("basic_food", {
},
},
})

View File

@ -1,11 +1,11 @@
local modpath = ...
eraz.settings = {}
local settings = Settings(modpath .. "/eraz.conf")
eraz.settings.spawn = settings:get_bool("spawn") or true
eraz.settings.spawn_interval = tonumber(settings:get("spawn_interval"))
eraz.settings.spawn_chance = tonumber(settings:get("spawn_chance"))
eraz.settings.spawn_announce = settings:get_bool("spawn_announce") or true
eraz.settings.lifetime = tonumber(settings:get("lifetime"))
eraz.settings = {
spawn = settings:get_bool("spawn") or true,
spawn_interval = tonumber(settings:get("spawn_interval")),
spawn_chance = tonumber(settings:get("spawn_chance")),
spawn_announce = settings:get_bool("spawn_announce") or true,
lifetime = tonumber(settings:get("lifetime")),
}

View File

@ -1,5 +1,9 @@
local S = ...
local function round(x)
return x>=0 and math.floor(x+0.5) or math.ceil(x-0.5)
end
--SPAWN
eraz.spawn = function(spawn_pos, limit_max_mobs, abr, liquidflag)
@ -14,7 +18,7 @@ eraz.spawn = function(spawn_pos, limit_max_mobs, abr, liquidflag)
local loot_description = eraz.loots[ent_ref.loot].description or S("unknown stuff")
if eraz.settings.spawn_announce then
minetest.chat_send_all(S("A new merchant has just arrived at")
.." ("..tostring(math.round(spawn_pos.x))..", "..tostring(math.round(spawn_pos.z))
.." ("..tostring(round(spawn_pos.x))..", "..tostring(round(spawn_pos.z))
.."),".." "..S("bringing").." "..loot_description
)
end

101
user.lua Normal file
View File

@ -0,0 +1,101 @@
local S = ...
eraz.register_loot("minerals", {
description = S("some minerals"),
type = "fixed",
items = {
iron = {
name = "default:iron_lump",
price = 10,
amount = 25,
},
copper = {
name = "default:copper_lump",
price = 5,
amount = 25,
},
bauxite = {
name = "aloz:bauxite_lump",
price = 7,
amount = 25,
},
},
})
eraz.register_loot("fruits", {
description = S("some fruits"),
type = "fixed",
items = {
apple = {
name = "default:apple",
price = 3,
amount = 6,
},
cherries = {
name = "cherrytree:cherries",
price = 5,
amount = 10,
},
lemon = {
name = "lemontree:lemon",
price = 2,
amount = 12,
},
clementine = {
name = "clementinetree:clementine",
price = 4,
amount = 8,
},
blueberries = {
name = "default:blueberries",
price = 5,
amount = 15,
},
pineapple = {
name = "pineapple:pineapple",
price = 6,
amount = 4,
},
pomegranate = {
name = "pomegranate:pomegranate",
price = 3,
amount = 7,
},
plum= {
name = "plumtree:plum",
price = 2,
amount = 8,
},
cacao_beans = {
name = "cacaotree:cacao_beans",
price = 10,
amount = 30,
},
barberries = {
name = "swaz:barberries",
price = 1,
amount = 20,
},
redcurrants = {
name = "redw:redcurrants",
price = 1,
amount = 15,
},
acorn = {
name = "oak:acorn",
price = 2,
amount = 25,
},
chestnut = {
name = "chestnuttree:fruit",
price = 3,
amount = 25,
},
persimmon = {
name = "ebony:persimmon",
price = 5,
amount = 7,
},
},
})