Forgot about this for a while, coming back to it now. I'm using Diarandor's current dialog box as a point of reference, but I kinda need a push in the right direction, I'm not too sure where to begin with this atm
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
local entity = ...
local map = entity:get_map()
function entity:on_created()
self:set_size(16, 16)
self:set_traversable_by("hero", false)
self:create_sprite("entities/bush_vine")
if entity:get_type() == "fire" then
sol.audio.play_sound("jump")
self:remove()
end
end
function entity:on_removed()
self:get_sprite():set_animation("destroy")
end
-- DIABLO STYLE HEALTH ORB
local life_bar = {}
function life_bar:new(game)
local object = {}
setmetatable(object, self)
self.__index = self
object:initialize(game)
return object
end
function life_bar:initialize(game)
self.game = game
self.surface = sol.surface.create(48, 48)
self.life_bar_img = sol.surface.create("hud/health_orb.png")
self.container_img = sol.surface.create("hud/health_orb.png")
self.life_displayed = game:get_life()
self.max_life_displayed = 0
self:check()
self:rebuild_surface()
end
-- Checks whether the view displays the correct info
-- and updates it if necessary.
function life_bar:check()
local need_rebuild = false
local max_life = self.game:get_max_life()
local life = self.game:get_life()
-- Maximum health
if max_life ~= self.max_life_displayed then
need_rebuild = true
if self.life_displayed > max_life then
self.life_displayed = max_life
end
self.max_life_displayed = max_life
end
-- Current health
if life ~= self.life_displayed then
need_rebuild = true
local increment
if life < self.life_displayed then
increment = -1
elseif life > self.life_displayed then
increment = 1
end
if increment ~= 0 then
self.life_displayed = self.life_displayed + increment
if (life - self.life_displayed) % 10 == 1 then
--sol.audio.play_sound("magic_bar")
end
end
end
-- Redraw the surface only if something has changed.
if need_rebuild then
self:rebuild_surface()
end
-- Schedule the next check.
sol.timer.start(self.game, 20, function()
self:check()
end)
end
function life_bar:rebuild_surface()
self.surface:clear()
-- Max health
self.container_img:draw(self.surface)
-- Current health
self.life_bar_img:draw_region(0, 0, 2 + self.life_displayed, 8, self.surface)
end
function life_bar:set_dst_position(x, y)
self.dst_x = x
self.dst_y = y
end
function life_bar:on_draw(dst_surface)
if self.max_life_displayed > 0 then
local x, y = self.dst_x, self.dst_y
local width, height = dst_surface:get_size()
if x < 0 then
x = width + x
end
if y < 0 then
y = height + y
end
self.surface:draw(dst_surface, x, y)
end
end
return life_bar
local map = ...
local game = map:get_game()
local door_manager = require("maps/lib/door_manager")
door_manager:manage_map(map)
function map:on_started()
function map:on_started()
if not game:get_value("dun1keyy") then chest_key:set_enabled(false) end
end
map:set_doors_open("auto_door_f", true)
self.night_overlay = sol.surface.create() -- Create an empty surface of the size of the screen.
self.night_overlay:set_opacity(152) -- Make it semi-transparent (0: transparent, 255: opaque).
self.night_overlay:fill_color({195, 24, 24}) -- Fill it with dark blue to obtain a night effect.
end
function map:on_draw(destination_surface)
self.night_overlay:draw(destination_surface)
end
function bridge_switch:on_activated()
sol.audio.play_sound("secret")
map:set_entities_enabled("bridge_tile", true)
end
function close_auto_door_f_sensor_1:on_activated()
if auto_door_f:is_open()
and map:has_entities("auto_enemy_auto_door_f") then
map:close_doors("auto_door_f")
end
end
for enemies in map:get_entities("auto_enemy_auto_door_f") do
enemies.on_dead = function()
if not map:has_entities("auto_enemy_auto_door_f") and not game:get_value("dun1keyy") then
chest_key:set_enabled(true)
sol.audio.play_sound("chest_appears")
end
end
end