Skip to content
Snippets Groups Projects
Commit b51c33ae authored by dg's avatar dg
Browse files

Mouse wheel works in the hotkey panel

git-svn-id: http://svn.net-core.org/repos/t-engine4@2630 51575b47-30f0-44d4-a5cc-537603b46e54
parent 772e73c1
No related branches found
No related tags found
No related merge requests found
......@@ -140,6 +140,15 @@ end
-- This is optional, only if you need mouse support
function _M:onMouse(button, mx, my, click, on_over)
local a = self.actor
if button == "wheelup" and click then
a:prevHotkeyPage()
return
elseif button == "wheeldown" and click then
a:nextHotkeyPage()
return
end
mx, my = mx - self.display_x, my - self.display_y
for i, zone in pairs(self.clics) do
if mx >= zone[1] and mx < zone[1] + zone[3] and my >= zone[2] and my < zone[2] + zone[4] then
......
......@@ -26,6 +26,7 @@ function _M:init(zone, map, level, spots)
Random.init(self, zone, map, level, spots)
local data = level.data.generator.actor
self.on_spot_chance = data.on_spot_chance or 70
self.spot_radius = data.spot_radius or 5
self.spot_filters = data.spot_filters or {}
-- Pick a number of spots
......@@ -41,7 +42,7 @@ function _M:getSpawnSpot(m)
if rng.percent(self.on_spot_chance) then
local spot = rng.table(self.spots)
if not spot then return end
local _, _, gs = util.findFreeGrid(spot.x, spot.y, 5, "block_move", {[Map.ACTOR]=true})
local _, _, gs = util.findFreeGrid(spot.x, spot.y, self.spot_radius, "block_move", {[Map.ACTOR]=true})
local tries = 0
local g = rng.table(gs)
local x, y = g[1], g[2]
......
......@@ -34,6 +34,7 @@ function _M:init(zone, map, level, data)
self.hurst = data.hurst or nil
self.lacunarity = data.lacunarity or nil
self.octave = data.octave or 4
self.nb_spots = data.nb_spots or 10
self.do_ponds = data.do_ponds
if self.do_ponds then
self.do_ponds.zoom = self.do_ponds.zoom or 5
......@@ -138,6 +139,7 @@ function _M:generate(lev, old_lev)
end end
-- make the noise
local possible_spots = {}
local noise = core.noise.new(2, self.hurst, self.lacunarity)
for i = 1, self.map.w do
for j = 1, self.map.h do
......@@ -146,6 +148,7 @@ function _M:generate(lev, old_lev)
self.map(i-1, j-1, Map.TERRAIN, self:resolve("wall"))
else
self.map(i-1, j-1, Map.TERRAIN, self:resolve("floor"))
if v >= self.sqrt_percent then possible_spots[#possible_spots+1] = {x=i-1, y=j-1, type="clearing", subtype="clearing"} end
end
end
end
......@@ -153,6 +156,12 @@ function _M:generate(lev, old_lev)
local spots = {}
self.spots = spots
-- Add some spots
for i = 1, self.nb_spots do
local s = rng.tableRemove(possible_spots)
if s then self.spots[#self.spots+1] = s end
end
if self.do_ponds then
for i = 1, rng.range(self.do_ponds.nb[1], self.do_ponds.nb[2]) do
self:addPond(rng.range(self.do_ponds.size.w, self.map.w - self.do_ponds.size.w), rng.range(self.do_ponds.size.h, self.map.h - self.do_ponds.size.h), spots)
......
......@@ -17,24 +17,6 @@
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
newEntity{
define_as = "GENERAL_STORE",
name = "general store",
display = '1', color=colors.LIGHT_UMBER,
store = {
purse = 10,
restock_after = 1000,
empty_before_restock = true,
min_fill = 40,
max_fill = 60,
filters = {
-- {type="scroll", id=true},
},
-- fixed = {
-- },
},
}
newEntity{
define_as = "ARMOR",
name = "armour smith",
......
......@@ -46,12 +46,12 @@ return {
class = "engine.generator.actor.OnSpots",
nb_npc = {20, 30},
filters = { {max_ood=2}, },
nb_spots = 2, on_spot_chance = 50,
nb_spots = 2, on_spot_chance = 35,
},
object = {
class = "engine.generator.object.OnSpots",
nb_object = {6, 9},
nb_spots = 2, on_spot_chance = 70,
nb_spots = 2, on_spot_chance = 80,
},
trap = {
class = "engine.generator.trap.Random",
......
......@@ -52,14 +52,16 @@ return {
lite_room_chance = 100,
},
actor = {
class = "engine.generator.actor.Random",
class = "engine.generator.actor.OnSpots",
nb_npc = {20, 30},
filters = { {max_ood=2}, },
nb_spots = 2, on_spot_chance = 35,
guardian = "TROLL_BILL",
},
object = {
class = "engine.generator.object.Random",
class = "engine.generator.object.OnSpots",
nb_object = {6, 9},
nb_spots = 2, on_spot_chance = 80,
},
trap = {
class = "engine.generator.trap.Random",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment