Menu

Show posts

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

Topics - MetalZelda

#21
I always thought about it, Solarus' default description is "An A-RPG Game Engine"
Despite this description, something comes in my mind "hmmm, is it only for a-rpg"

There is only a script that display a RPG styled HUD over here, this is the only thing I've seen here
There is also a platformer script that is still a Work in progress.

My though is, is a Fighting game possible ?
If we think intelligently, it is, a Street Fighter or a Super Smash Bros clone is definately possible in Solarus.

Super Smash Bros / Street Fighter is mostly a 2d game

Each fighter have their AI (Entities)
CPU can be made out of with Custom entities
Collisions might be custom entities
Menues are relatively easy to made, the only thing it has to memorize is the fighter we've choosen
The only thing is, these type of game tends to be multiplayer, and to do such we have to modify some specificities on the engine, or else, doing it through on_character_pressed
There are a lot of tutorial about 2d gravity
The only restriction here is the camera, which, at this moment, cannot be scaled in term of zooming

What do you all think ?
#22
Hi.

This is something I'm facing while creating enemies.
Destructibles are recognized as "thrown_item" if it has been defined in the enemy script, but build_in bombs are not recognized as "thrown_item", this is a bit weird, bombs can be thrown by the hero, just like a destructible
#23
Game art & music / [Tool] Palette Swapping tool
August 09, 2016, 12:08:49 AM
Author: MaximusMaxy
Taken From: Project Zelda Engine

Updated link

Grab this tool here.
https://www.mediafire.com/file/f7iz2t8e4iv21cx/tool.zip

This tool will ease your life, especially for those who re-use some material with another color (the hero for example), this will make your job.

What you need:
[/b][/i][/u]
  - Script editing software (Notepad ++ is largely enough)
      If you don't have any software grab Notepad++ here -> https://notepad-plus-plus.org/
  - Image editing software (for your sprites, mostly, and for the required files)
      Don't have any ? Grab GIMP, it's free and it does the job ->https://www.gimp.org/


I am gonna do this tutorial with my sprites.


How this work :


Step 1: The Basic
1 - Dowload the archive
2 - Extract it somewhere
3 - Go to Data/scripts and open this script in your favorite script editing program

Step 2: It starts.
4 - Select the sprites you want to convert and place them in Graphics/characters
 


5 - Open your image editing software and grab a sample of your sprite. Create a new image with as parameter
  Width = the number of pixel you want to convert
  Height = 1 (You can set any value you want)
 

6 - Grab the colors you want to modify like so, in my example, I want to recolor Link's Tunic to red


Save this as png in Graphics/Characters, and name it StartColor.png, this file will be used by the script to memorize the color to change.

7 - Set your target colors, like so


Save this file as png in Graphics/Characters, and name it TargetColor.png, this file will be used by the script to replace the memorized color by StartColor.

8 - Go to the script editor, and go to the previously opened script, and go at line 43, you will see something like this


Replace all the things in '' by the sprite you want to convert, without it's extention like so
'your_file',

9 - Save the file

10 - Open the programm


11 - The process is completely automated, the speed of the conversion may vary from your CPU, hard drive speed, etc


12 - When finished, the programm warns you, and close automatically


13 - Go to the 'Palette Swap' folder.


Ta-da

This script is kinda useful, you don't need to swap color manually from a image editing software, so it save a lot of time.
Have fun
#24
Hello !

I'm facing a strange anomaly while making some item interaction stuffs.
I do have worked all items and they work perfectly, now, i'm making some kind of interaction with NPC's (trading)

Problem is

Code (lua) Select
function trade_npc:on_interaction_item(item)
  print("Interacting, no item has been choosen yet")
  if item == "green_chuchu_counter" then
    print("Green Chuchu (Counter) is being shown to this NPC")
  end

end


on_interaction_item is called, problem is, I'm using the item green_chuchu_counter item, but

print("Green Chuchu (Counter) is being shown to this NPC")

is not called, I tested without the "" on the condition, doesn't work eigher.

Trying to get the item through print(item) prints a userdata, so it doesn't help a lot

Any help would be welcome
#25
Greets !

So, I was about to implement a light effect (used by wrightmat in his project) and started to make the thing.
Problem is, the old lighting system use a very basic bitmap



Wrightmat's one use this one in addition to his lighting effect



Is there's a way to "revert" the picture, so I get the same effect
I don't know what and how blending picture are computed, and I greatly suck at image editing so any help would be welcome
I'm using GIMP if you're asking.

Thanks
#26
Hi.

So I was trying to make a system that place the camera depending on where the hero is to better see the map, problem is with the camera movement. (Target movement)

This is in my map script

Code (lua) Select
local function to_area(entity, callback)
  local movement = sol.movement.create("target")
  movement:set_target(camera:get_position_to_track(entity))
  movement:set_speed(50)
  movement:start(camera, function() if callback ~= nil then callback() end end)

  print(movement:get_speed())
end

function camera_to_area:on_activated()
  to_area(camera_spot) -- This should do it as it is aldo triggered when the minigame is about to start
end

function camera_to_hero:on_activated()
  local dir = hero:get_direction()
  if dir == 3 then
    to_area(hero, function() camera:start_tracking(hero) end)
  end
end


When I step on camera_to_area, the movement speed is the one I want, 50, but, if I step on camera_to_hero, the movement speed is 96, while I set the speed at 50, the function and the callback works, but speed looks kinda buggy.
I don't know if this is the right way to do but even with this configuration it should print 50, not 96
#27
Bugs & Feature requests / [Question] Audio Features
July 31, 2016, 10:37:51 PM
Hi

So in my project (and maybe in some other), I use audio that change depending on the action of the hero, this is normal, but, to accomplish this, I need to split the audio in many parts. But, trouble are, loading and playing an audio does freeze for some time the game, even if the file's under 1mb

So I suggested an idea of extending the audio script, just like you did Chris by adding audio looping with LOOPSTART

You can see the whole idea here

https://github.com/MetalES/Project-Zelda/issues/17

What do you think ?
#28
Hello !

So I was finalizing my Ocarina item and thought of something.

For my Water Temple (and other places) in my project, there are a lot of entities that need the ocarina to do some actions.
In the ocarina script, things goes like this

Code (lua) Select

-- these are example, h = hero
--ocarina_zelda_x = event id on the map

    -- for e in m:get_entities("ocarina_zelda") do
  -- if h:overlaps(e) then
    -- e:on_zelda_lullaby_interaction()
  -- else
    -- self:return_no_effect()
  -- end
-- end
-- end


If I playtest and play Zelda Lullaby (as shown above), it execute every entities with the name 'ocarina_zelda' present in the map, so it call both e:on_zelda_lullaby_interaction() because I am overlapping one of these entity, and it also execute return_no_effect(),  while the thing I want is execute the only entity Link is overlapping

Any clues ?
#29
General discussion / Solarus on a RPi ?
May 28, 2016, 12:30:06 PM
Hi.

I do have seen some april fool in the french board (http://forums.zelda-solarus.com/index.php/topic,23111.0.html) and it is kinda awesome, even for a fake.
So I was thinking, I am about to start a project that imply a Raspberry Pi Zero and some crap to do a small, portable linux console, and the RPI Zero is one of a kind (only 5€/$).
Yet, no one has tested to run Solarus nor one of it's made project on these little hardware, and I am here to ask if anyone has tested Solarus on these hardware and some feedbacks about it.

Hardware (most important)
512Mb Ram
1Ghz CPU

#30
Development / [Solved] Ignoring a chunk of text ?
April 05, 2016, 12:20:15 AM
Hi.

So earlier I was imaginating a mail system and how it should work. It works properly (https://github.com/MetalES/Project-Zelda/issues/4), but I am in need of help.

The mail's text content is stored in another file (see bellow), this is to ensure that translators will not be lost and also to keep string.dat clean (Only mail names are part of string.dat)

Everything works fine, except that I need to ignore a chunk of line in order to display the right page.

This is how a mail file looks like (of course, this is a test)
$ = Tell the engine to go to another line
  • [/0] = Tell the engine that this page start and ends there (Is there a way to do it like so ?)


    [reward]heart_piece

    [0]
    Line0$
    Line1$
    Line2$
    Line3$
    Line4$
    Line5$
    Line6$
    [/0]

    [1]
    Line0$
    Line1$
    Line2$
    Line3$
    Line4$
    Line5$
    Line6$
    [/1]

    [2]
    Line0$
    Line1$
    Line2$
    Line3$
    Line4$
    Line5$
    Line6$
    [/2]


    This is the code
    Code (lua) Select

    local submenu = require("scripts/menus/pause_submenu")
    local mail_submenu = submenu:new()

    function mail_submenu:on_started()
      submenu.on_started(self)
     
      self.game:set_custom_command_effect("attack", "return")
      self.game:set_custom_command_effect("action", "open")
     
      self.cursor_sprite = sol.sprite.create("menus/pause_cursor")
      self.cursor_sprite:set_animation("letter")
     
      self.displaying_mail = false

      local font, font_size = sol.language.get_menu_font()
      local width, height = sol.video.get_quest_size()

      self.mail_name_surface = sol.surface.create(320,800)
     
      -- Todo, this is a test, rezise this to fit the page bitmap
      self.text_display_surface = sol.surface.create(320, 240)
     
      self.mail_highest_visible = 1
      self.mail_visible_y = 0
      self.mail_names = {}
     
      -- This handle the whole mail page
      self.mail_content = sol.text_surface.create{
        horizontal_alignment = "left",
        vertical_alignment = "top",
        font = "lttp",
        font_size = 14,
        text = text_lines,
      }
     
      --Todo
      self.page_number = sol.text_surface.create({
        horizontal_alignment = "left",
        vertical_alignment = "top",
        font = "lttp",
        font_size = 14,
        text = "0 /" .. self.game:get_value("total_mail") / 5,
      })
      --
     
      for i = 1, 100 do
        if self.game:get_value("mail_" .. i .. "_obtained") then
          self.mail_names[i] = sol.text_surface.create{
            horizontal_alignment = "left",
            vertical_alignment = "top",
            font = "lttp",
            font_size = 14,
            text_key = "quest_status_mail.mail." .. self.game:get_value("mail_" .. i .. "_name"),
          }
    end
      end

      self.up_arrow_sprite = sol.sprite.create("menus/arrow")
      self.up_arrow_sprite:set_direction(1)
      self.up_arrow_sprite:set_xy(58, 48)
      self.down_arrow_sprite = sol.sprite.create("menus/arrow")
      self.down_arrow_sprite:set_direction(3)
      self.down_arrow_sprite:set_xy(58,212)

      self.cursor_position = nil
      self:set_cursor_position(1)
     
      self:load_extra()
    end


    function mail_submenu:load_extra()
      self.mail_name_surface:clear()
     
      local misc_img = sol.surface.create("menus/quest_status_mail_system.png")

      -- misc_img:draw_region(0, 37, 182, 172, self.mail_surface, 129, 55)
       
      for i = 1, 100 do
        local y = 7 + (i - 1) * 32
    local x = 18

    if self.game:get_value("mail_" .. i .. "_obtained") then
      misc_img:draw_region(0, 22, 310, 32, self.mail_name_surface, 5, 0 + (33 * (i - 1)) - (i - 1))
      self.mail_names[i]:draw(self.mail_name_surface, 47, y + 2)
     
      if self.game:get_value("mail_" .. i .. "_opened") then
        misc_img:draw_region(0, 0, 27, 19, self.mail_name_surface, x, y - 1)
      elseif self.game:get_value("mail_" .. i .. "_highlighted") then
        misc_img:draw_region(26, 1, 27, 18, self.mail_name_surface, x, y)
      else
        misc_img:draw_region(52, 1, 27, 18, self.mail_name_surface, x, y)
      end
    end
      end
    end


    function mail_submenu:set_cursor_position(position)

      if position ~= self.cursor_position then

        local width, height = sol.video.get_quest_size()

        self.cursor_position = position
        while position <= self.mail_highest_visible do
          self.mail_highest_visible = self.mail_highest_visible - 1
          self.mail_visible_y = self.mail_visible_y - 32
        end

        while position > self.mail_highest_visible + 5 do
          self.mail_highest_visible = self.mail_highest_visible + 1
          self.mail_visible_y = self.mail_visible_y + 32
        end

        self.cursor_sprite.x = 10
        self.cursor_sprite.y = 40 + 32 * (position - self.mail_highest_visible)
      end
    end

    function mail_submenu:on_draw(dst_surface)
      -- Text.
      self.mail_name_surface:draw_region(0, self.mail_visible_y + 32, 320, 160, dst_surface, 0, 53) -- (0, self.mail_visible_y + 27, 320, 169, dst_surface, 17, 49

      -- Arrows.
      if self.game:get_value("total_mail") > 5 then
        if self.mail_visible_y > 0 then
          self.up_arrow_sprite:draw(dst_surface)
        end

        if self.mail_visible_y < 60 then
          self.down_arrow_sprite:draw(dst_surface)
        end
      end
     
      self.text_display_surface:draw(dst_surface, 0, 0)
        -- Cursor.
      self.cursor_sprite:draw(dst_surface, self.cursor_sprite.x, self.cursor_sprite.y)
      self:draw_save_dialog_if_any(dst_surface)
    end


    function mail_submenu:on_command_pressed(command)
      local handled = submenu.on_command_pressed(self, command)

      if not handled then
        if command == "left" then -- maybe use this for page ?
          handled = true
     
        elseif command == "right" then
          handled = true
     
        elseif command == "up" then
      if self.game:get_value("unread_mail_amount") > 1 then
        sol.audio.play_sound("menu/cursor")
    if self.cursor_position == 1 then
      self:set_cursor_position(self.game:get_value("unread_mail_amount"))
    else
      self:set_cursor_position(self.cursor_position - 1)
    end
      end
          handled = true
     
        elseif command == "down" then
      if self.game:get_value("unread_mail_amount") > 1 then
    sol.audio.play_sound("menu/cursor")
    if self.cursor_position >= self.game:get_value("unread_mail_amount") then
      self:set_cursor_position(1)
    else
      self:set_cursor_position(self.cursor_position + 1)
    end
      end
          handled = true
     
    elseif command == "pause" then
      submenu.avoid_can_save_from_qsmenu = false
      self.display_mail = false
      sol.menu.stop(self)
     
        elseif command == "action" then
      --todo

      if self.is_reading then
        self:display_mail(nil)
    self.is_reading = false
      else
        self:display_mail(self.cursor_position)
        self.is_reading = true
    if not self.game:get_value("mail_" .. self.cursor_position .. "_opened") then
      self.game:set_value("mail_" .. self.cursor_position .. "_opened", true)
    end
      end
     
          sol.audio.play_sound("danger")
      handled = true
     
        elseif command == "attack" then
      if not self.displaying_mail then
        self.game:set_custom_command_effect("action", "open")
            self.game:set_custom_command_effect("attack", "save")
        submenu.secondary_menu_started = false
            sol.timer.start(1, function()
          submenu.avoid_can_save_from_qsmenu = false
        end)
        sol.menu.stop(self)
      else
        -- if it is displaying a letter, just clear the message, it is very simple.
        self.displaying_mail = false -- that's it.
      end
          handled = true
        end
      end
     
      if not self.game:get_value("mail_" .. self.cursor_position .. "_highlighted") then
        self.game:set_value("mail_" .. self.cursor_position .. "_highlighted", true)
      end
     
      self:load_extra()
      return handled
    end

    function mail_submenu:display_mail(index)
      local mail_text
      self.current_page = 0

      if index ~= nil then
        -- Load the target file, only in read mode, the file name is the name of the letter, given by it's savegame variable.
    -- These files are part of dialogs, so they need to be part of the language system. So mails can be translated with ease.
    -- Luckily, savegame variable for this is ("mail_" next_mail_pointer_non_allowed "_" name), so you just have to get the cursor position in order to get that file
        mail_text = sol.file.open("languages/".. sol.language.get_language() .. "/text/mail/" .. self.game:get_value("mail_".. self.cursor_position .. "_name") .. ".dat", "r")
    -- Read the file, and store all of it's content in self.text.
        self.text = mail_text:read("*all")
    -- We get all of the file's text stored in self.text, the host file isn't interesting anymore, unload it.
    mail_text:close()
    -- Parse the text.
    self:parse_text()
    -- We are reading the mail, on_command_pressed need an alternate command mapping
    self.reading_mail = true
      else
        -- We are on the mail, and player pressed "close", he closed the mail, clear everything that regards this mail.
        self.text_display_surface:clear()
    -- The surface handling the text has been cleared, but not the text
    self.mail_content:set_text("")

        mail_text = nil
        self.text = nil
      end
    end

    function mail_submenu:parse_text()
      local line = 0
     
      -- Start some wizzard stuffs here

      -- $ = pass line, works
      for text in string.gmatch(self.text, "[^$]+") do
        line = line + 1
    self.mail_content:set_text(text)
        self.mail_content:draw(self.text_display_surface, 0, 0 + (line * 15))
      end
    end

    return mail_submenu


    The problem is, when opening a mail, I want to ignore all things that doesn't regard the current page , and I am not really good when it comes to string modification, I don't know how to do it, I mostly want the engine to analyse and draw texts that are between [page] and [/page].

    Any help would be welcome
#31
Hi.

So I was using MoS map system for the pause menu.
The problem is, I am making a dungeon that have more then 8 floors, the maps are done, but if I put in dungeons.lua

Code (lua) Select
  [7] = {
    floor_width = 2256,
    floor_height = 2256,
    lowest_floor = -4, -- can't go lower
    highest_floor = 3, -- can't go higher
    maps = { final_path .. "Dungeon/ETemple/Floor-7" }, -- final_path = value to check HMode, reversed map wise.
    boss = {
      floor = -4,
      x = 1035, -- todo
      y = 560, -- todo
      savegame_variable = "b1046",
    },
  },


If lowest is inferior to -4 and highest is superior to 3, the map won't display, I got an error in highest_floor_display.
Tested with Mystery of Solarus, same result, the floor image allows 33 floors (34 if you include the "unknown" stairs)
#32
Hello.

Edit:
For other users asking : Diarandor explain how to do it bellow.

This is the final script

Code (lua) Select
  local max_charging_time = 900 -- approximative time of the animation 'casting the fishing rod'
  local charging_time = max_charging_time - self.dowsed_distance -- Value is calculated is self:dowse()
  local distance = self.dowsed_distance -- same
  local max_distance = 230  -- Maximum distance of the movement.
  local duration = distance -- relative speed of the rod when casting it.
  local max_height = math.floor(-self.dowsed_distance / 5)
 
  local function f(t)
    return math.floor(4 * max_height * (t / duration - (t / duration) ^ 2))
  end
 
  local t = 0
  sol.timer.start(self, 10, function()
    fishing_rod:get_sprite():set_xy(0, -f(t))
    t = t + 10
    if t > duration then return false
      else return true
    end
  end)
#33
Hi.

I was making an event with a circle movement.
However, this movement need to start at a precise angle, so at first I tried math.pi / 2 in set_initial_angle() but it always start at the right
I also tried something based on http://math.rice.edu/~pcmi/sphere/drg_txt.html but nothing seems to happen, it always start at the right

This is the movement code

Code (lua) Select


  local s = sol.movement.create("straight")
  s:set_angle(math.pi / 2)
  s:set_speed(60)
  s:set_max_distance(16)
  s:start(entity_sprite, function()
    local c = sol.movement.create("circle")
c:set_initial_angle(math.pi / 2) -- start the movement from above the hero's head -- looks like it is faulty ?
c:set_center(self, 0, -8)
c:set_clockwise(false)
c:set_max_rotations(2)
c:set_radius(16)
c:set_radius_speed(16)
c:set_duration(1250)
    c:start(entity_sprite)
  end)


Is this a bug or am I doing it wrong ?
#34
If you put another sprite to the hero through set_tunic_sprite_id() or changing it's tunic ability and then call hero:get_sprite():get_animation_set(), the returned result is the tunic id that was created at game initialisation, it is updated only if the game has been reset and if the game has been saved.
#35
Hello.
I need some informations.

I am currently working on the Title Screen of my project, but instead of taking place on a menu, it takes place on a game map.
The Title screen's startup is created when the engine has read main.lua in another file (to avoid bothering the "real" savegames on the File Selection menu)
But, as I access the File Selection screen, the map is still loaded (should be normal because the menu is displayed above the map)

My question is, is the map (and it's objects) that got loaded by the title screen file still loaded when the other savegame got started or are they destroyed and immediately replaced by the new game (for example : the surface) ?

Objects are attached to the map itself
Code (lua) Select
-- Title Screen Map, Work in Progress
-- Todo : Movement
-- Display : It works better then I though
local map = ...
local savegame_menu = require("scripts/menus/savegames")

local draw_title_name = false

local surface = sol.surface.create(320, 240)
surface:fill_color({0, 0, 0})
surface:fade_out(80, function() sol.audio.play_music("menu_title_screen") end)

map.title_screen_logo_img = sol.surface.create("menus/title_screen/title_logo.png")

map.website_img = sol.text_surface.create{
  font = "lttp",
  font_size = 14,
  text_key = "title_screen.website",
  horizontal_alignment = "center"
}

map.press_space_img = sol.text_surface.create{
  font = "lttp",
  font_size = 14,
  text_key = "title_screen.press_space",
  horizontal_alignment = "center"
}

local function switch_press_space()
  map.press_space_img:fade_in(40, function()
    map.press_space_img:fade_out(40, function()
      switch_press_space()
    end)
  end)
end

function map:on_key_pressed(key)
  if key == "space" or key == "enter" then
    if not draw_title_name then
     switch_press_space()
     draw_title_name = true
    else
     surface:fade_in(40, function()
       sol.menu.start(sol.main, savegame_menu)
     end)
    end
    --
  end
return true
end

function map:on_draw(dst_surface)
  if draw_title_name then
    self.website_img:draw(dst_surface, 160, 220)
    self.title_screen_logo_img:draw(dst_surface, 88, 30)
    self.press_space_img:draw(dst_surface, 160, 200)
  end
  surface:draw(dst_surface, 0, 0)
end


File Generated when the engine starts

Code (lua) Select
if not sol.game.exists("solarus_boot.dat") then
  local savegame = sol.game.load("solarus_boot.dat")
  savegame:set_starting_location("cutscene/scene_TitleScreen/0", "default")
  savegame:save()
end


And how it is started in main.lua

  -- Then the Title Screen (after "blabla presents").
  title_screen.on_finished = function()
    if sol.game.exists("solarus_boot.dat") then
      self.game = sol.game.load("solarus_boot.dat")
      sol.menu.stop_all(self)
      self:start_savegame(self.game)
    end
  end


This is how it looks actually


Any help will be appreciated
Thanks
#36
Hi

I was working on some enemies and I am facing a little problem.
I want a sprite of this enemy to react to a thrown bomb, but "thrown_item" in as attack_consequence doesn't seems to work, tried with "explosion'' and it worked, but that's not the wanted effect.

Then, I was playing with set attak consequence and the console show me something that isn't documented in the API
http://www.solarus-games.org/doc/latest/lua_api_enemy.html#lua_api_enemy_set_attack_consequence_sprite

"Invalid name'attack', valid name are" blabla ""script""


Loading it in game does nothing, the enemy still move.

this is the current script, I want a thrown bomb to interract with this particular sprite, but it is not working, as said above, "explosion" work.
There is nothing much, the local variable is set to true when it is needed for the collision.

Code (lua) Select
-- Part in on_created
self:set_attack_consequence_sprite(head_sprite, "thrown_item", "custom")
self:set_attack_consequence_sprite(head_sprite, "explosion", "custom")


Code (lua) Select

  function enemy:on_custom_attack_received(attack, sprite)
  if attack == "sword" and sprite == sprite then
if can_attack then
sol.audio.play_sound("ennemies/_boss/king_dodongo/hit")
self:get_sprite():set_direction(1)
self:remove_life(enemy:get_game():get_ability('sword'))
sol.timer.start(250, function()
self:get_sprite():set_direction(0)
end)
else
sol.audio.play_sound("sword_tapping")
end
  end
 
  if attack == "thrown_item" and sprite == head_sprite then
     if can_damage then
      print("damaged")
end
  end

  if self:get_life() <= 5 then
start_dying_cutscene()
  end 
end
end
#37
Hi

So I was testing around the hero mode that I implemented in my project.
Now I need to define how much damage a enemy (or anything else)deal to the hero.
But, accessing hero:on_taking_damage(damage) through metatable to overwrite the default function seems not to work
I don't know what have I done wrong, there is no hero:on_taking_damage elsewhere, hero_mode is set to true in the savegame file, so that's not a savegame issue. The code is based on ROTH.

Code (lua) Select
-- On taking damage : Called when the hero takes damage. Increase this if we are in hero mode
  function hero_meta:on_taking_damage(damage) -- Not working
    local game = self:get_game()
local hero_mode = game:get_value("hero_mode")
if hero_mode then
  damage = damage * 2
else
  damage = damage
end 
game:remove_life(damage)
  end
#38
Development / Getting the tile id bellow the hero ?
January 23, 2016, 04:03:12 PM
Hi.

I know that it already exist but it only return the built-in ground that the hero is walking on.

My idea about it is to create custom interaction behaviors for certain tile, and the Tileset Editor manage all the tiles by id, it should be cool if this should be accessible in the API
#39
Development / Pause an entity movement ?
January 15, 2016, 08:02:12 PM
Hi.

Is there any way to pause every entities on the map that have movement ?

For example, if I interact with a custom entity, all entities in the map still moves while I want them to be suspended.
It could be useful if there is a entity:set_paused() function, or is there any way to do it ?
#40
Hi.

So, today I was working on the Time System that is heavily based on Majora's Mask.
But, I am facing a problem, I want the tone between hours / minutes to have a smooth transition, fill_color just set the new color immediatly on the surface.

The script bellow is the Time system's Tone manager, everything you'll see is already declared in other script, the tone work perfectly, but I don't know how I could make tone value to increase smoothly and though, make the tone progress smooth

Code (lua) Select
local game = ...
local tone_manager = {}
local tone_timer

-- Day/Night system - Tone.

function game:start_tone_system()
  sol.menu.start(self:get_map(), tone_manager, false)
end

function tone_manager:on_started()
  self.game = game
 
  self.tone_surface = sol.surface.create(320,240)
  self.surface_opacity = 0
  self.target_opacity = 0
  self.color_r, self.color_g, self.color_b, self.color_alpha = 0, 0, 0, 0

  self:check()
end

function tone_manager:set_new_tone(r,g,b,a,o)
  if r ~= nil then
   self.color_r = r
  else
   self.color_r = 0
  end

  if g ~= nil then
   self.color_g = g
  else
   self.color_g = 0
  end
 
  if b ~= nil then
   self.color_b = b
  else
   self.color_b = 0
  end
 
  if a ~= nil then
   self.color_alpha = a
  else
   self.color_a = 0
  end
 
  if o ~= nil then
   self.target_opacity = o
  else
   self.target_opacity = 0
  end
print(self.color_r, self.color_g, self.color_b, self.color_alpha)
end

function tone_manager:get_target_tone()
return self.color_r, self.color_g, self.color_b, self.color_alpha
end

function tone_manager:get_target_opacity()
return self.target_opacity
end

-- Checks if the tone need to be updated
-- and updates it if necessary.
function tone_manager:check()
local minute = self.game:get_value("current_minute")
local hour = self.game:get_value("current_hour")
local world = self.game:get_map():get_world() or nil

  if world ~= "outside" then
    self.time_system = false
  else
    self.time_system = true
print("outside")
  end
 
   if (hour == 24 or hour == 0) and minute >= 0 and minute <= 30 then -- test, from midnight to 0:30
    self:set_new_tone(0, 0, 64,0, 150)
  else
self.tone_surface:set_opacity(0)
    self.tone_surface:fill_color{0,0,64}
  end
 
  -- Schedule the next check.
  sol.timer.start(self, self.game:get_value("time_flow") / 4, function()
    self:check()
  if self.time_system and self.game.is_new_map then
    self:rebuild_tone()
    self.game.is_new_map = false
  end
  end)
end

function tone_manager:rebuild_tone()
tone_timer = sol.timer.start(self.game:get_map(), self.game:get_value("time_flow") / 30, function()
self.tone_surface:set_opacity(self.target_opacity)
        self.tone_surface:fill_color{self.color_r, self.color_g, self.color_b, self.color_a}
return true
end)
end

function tone_manager:on_finished()
  sol.timer.stop_all(self)
  tone_timer:stop()
end

function tone_manager:on_draw(dst_surface)
  self.tone_surface:draw(dst_surface,0,0)
end

return tone_manager




This is the current result, the transition and clock work, but the color change is immediate ...


Any help would be welcome