1
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.
I still don't see the aim of this. You can play Solarus on any OS and use controllers and gamepads, or am I wrong?
Here is an example of how the custscene builder should be used (example from Zelda OLB SE):Code: (lua) [Select]cutscene.builder(game, map, hero)
.dialog("out.e4.pit_hello")
.exec(function()
hero:freeze()
end)
.movement({
type = "straight",
entity = pit,
properties = {
angle = 0,
speed = 64,
max_distance = 176,
ignore_obstacles = true,
},
})
.exec(function()
pit:remove()
hero:unfreeze()
end)
.start()
cutscene.builder(game, map, hero)
cutscene.wait(500)
cutscene.exec(function() print("test") end)
cutscene.start()
Yes, you can use the event hero.on_state_changed. But i'd personally do it in a different way, with a timer each millisecond to check the ground below the hero during the dash movement. But both approac
hes are ok.
-- local variable that detect if we are dashing (mostly used in on_key_pressed())
local dashing = false
hero:register_event("on_position_changed", function()
if dashing then
local x, y, layer = hero:get_position()
-- Check ground bellow code
end
end
if key == game:get_value("_keyboard_action")
Zelda's Adventure, released for the Phillips CD-i
sol.audio.set_music_channel_volume() only works for .IT musics.
texture = {
src = "source_file_name",
opacity = opacity,
}
map:dim_room_surface(i, bool)
Nice work!If you forget one of them, your computer might explode and then stuff in red will appear, Diarandor might send you cats, you've been warned.I'll be preparing my cats, just in case.
local map_metatable = sol.main.get_metatable("map")
require(path_of_the_script)(map_metatable)
--[[
Fadable rooms
Made by MetalZelda
Inspired by: Project Zelda Engine
Feb.2018 - Rev Mar.2018
Version 1.6
REQUIRED:
- [Multi Events] by Christopho
(http://forum.solarus-games.org/index.php/topic,784.0.html)
Simulate multiple rooms by hiding one using a table
{
texture = {
src = "texture_path",
opacity = 0 - 255,
}
x = x position of the roof
y = y position of the roof
width = horizontal lenght of the roof
height = vertical lenght of the roof
color = {r, g, b} (color of the roof)
}
color can be omnitted if using a texture
texture can be omnitted if using a color preset
You can combine both by using a semi-transparent texture and apply a color, the color will be drawn bellow
Trigger zone is defined by the script bellow
Usually: rooms.under = (x >= rooms.x - 9 and x <= rooms.x + rooms.width + 9) and (y >= rooms.y - 6 and y <= rooms.y + rooms.height + 23)
]]
return function(map)
-- This is the incrementation value, 8 is faster enough
local opacity_increment = 8
map:register_event("on_started", function(map)
-- If nothing exists on the rooms table means that there are nothing to display, the scripts stops here.
if map.fade_rooms == nil then
return
end
-- Store additionnal data on the roof table such as surface, color and opacity (default = 255) that can be automatically set by the script
for num, rooms in ipairs(map.fade_rooms) do
rooms.surface = sol.surface.create(rooms.width, rooms.height)
if rooms.color then
rooms.surface:fill_color(rooms.color)
end
if rooms.texture then
local texture_surface = sol.surface.create("roof_texture/" .. rooms.texture.src .. ".png")
local texture_width, texture_height = texture_surface:get_size()
if rooms.texture.opacity then
texture_surface:set_opacity(rooms.texture.opacity)
end
-- Get the total pixels to cover
local total = ((rooms.width * rooms.height) / (texture_width * texture_height))
local x = 0
local y = 0
for i = 1, total do
-- Draw the texture on the right place
texture_surface:draw(rooms.surface, x, y)
-- Increment next value
x = x + texture_width
if x >= rooms.width then
x = 0
y = y + texture_height
end
end
end
rooms.opacity = 255
end
end)
map:register_event("on_draw", function(map, dst_surface)
-- To avoid errors, if there is nothing to draw, abort.
if map.fade_rooms == nil then
return
end
for _, rooms in ipairs(map.fade_rooms) do
local cam_x, cam_y = map:get_camera():get_position()
rooms.surface:draw(dst_surface, rooms.x - cam_x, rooms.y - cam_y)
local opacity = rooms.opacity
-- Get player position, current layer is not a necessary parameter.
local x, y = map:get_hero():get_position()
-- Define the rule of being under a roof for any roof.
rooms.under = (x >= rooms.x - 9 and x <= rooms.x + rooms.width + 9) and (y >= rooms.y - 6 and y <= rooms.y + rooms.height + 23)
-- Define opacity variation for roof
if rooms.under or rooms.force_under then
rooms.opacity = rooms.opacity > (opacity_increment - 1) and rooms.opacity - opacity_increment or 0
else
rooms.opacity = rooms.opacity < (255 - opacity_increment) and rooms.opacity + opacity_increment or 255
end
-- Don't need to update any opacity if the game is paused.
if map:get_game():is_paused() then
rooms.opacity = opacity
end
rooms.surface:set_opacity(rooms.opacity)
end
end)
function map:dim_room_surface(i, bool)
if bool == nil then
bool = self.fade_rooms[i].force_under == nil and true or (not self.fade_rooms[i].force_under)
end
self.fade_rooms[i].force_under = bool
end
end
rooms.under = (x >= rooms.x - 9 and x <= rooms.x + rooms.width + 9) and (y >= rooms.y - 6 and y <= rooms.y + rooms.height + 23)
local map = ...
local fade_roofs = {
{
texture = {
src = "forest_roof_txt0",
opacity = 120
},
x = 80,
y = 256,
width = 272,
height = 200,
color = {56, 40, 40}
},
{
x = 80,
y = 16,
width = 272,
height = 200,
color = {56, 40, 40}
},
}
map.fade_rooms = fade_rooms
{
texture = {src = src of the image, opacity = opacity (0 - 255}
x = x position of the roof
y = y position of the roof
width = horizontal lenght of the roof
height = vertical lenght of the roof
color = {r, g, b} (color of the roof)
}