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

Messages - froggy77

#106
Development / Re: Possible to create a level up system?
January 10, 2016, 03:04:16 PM
Thank you for answering. If I understand you, I should not use my enemy metatable for this, but only enemy scripts.

I also used the metatable for the hero: I created "hero:get_xp()" and "hero:set_xp(xp, boolean)" functions .(Maybe I will also create "hero:add_xp(xp)" ). It works fine, but I had then added a value in the backup file, otherwise I lost the xp value when I backed up and left the game. It would be easier without metatables for backups and to avoid having a value that is outdated.
I have another question:
Is it better to often read a value inside a metatable or a value from a backup file?


I put this code in the quest_manager.lua, maybe it is not the best file.

Code (Lua) Select

-- Initializes some behavior of our hero.
local function initialize_hero()

  local hero_meta = sol.main.get_metatable("hero")
  -- ZL --  Functions for experience points of our hero
  hero_meta.t_xp = {k_xp = nil}
  function hero_meta:set_xp(v_xp, bool)
local game = self:get_game()
v_xp = v_xp or nil
bool = bool or false -- false means "do not save" with a set_value.
if type(v_xp) == "number" and type(bool) == "boolean" or bool == nil then
hero_meta.t_xp.k_xp = v_xp
if bool == true then
game:set_value("xp", v_xp)
end
else
print("error in set_xp(v_xp, bool)")
end
  end
  function hero_meta:get_xp()
local game = self:get_game()
local xp = game:get_value("xp")
if hero_meta.t_xp.k_xp == nil then
local hero = self:get_map():get_hero()
-- print("xp from file = ", xp)
hero:set_xp(xp) -- xp value is now in the metatable
return xp
else
-- print("xp from metatable = ", hero_meta.t_xp.k_xp)
return hero_meta.t_xp.k_xp
end
  end

end


function quest_manager:initialize_quest()

  -- blablabla
  initialize_hero()
  -- blablabla

end


EDIT: I said "backup file" (for save1.dat, save2.dat or save3.dat), but I should have said "buffer";  e.g "xp = 100" is first read in a "backup file" and then the value is in the buffer of the engine. But with my method, I have xp value in the buffer (with other values found in the saveX.dat) + in the metatable which also used memory: I think my method is stupid, and I should avoid to insert data in the metatable.
#107
Development / Re: Possible to create a level up system?
January 10, 2016, 12:01:44 PM
Very interesting subject , at least for me, because I started a little scripting experience points .
Quote from: Renkineko on January 05, 2016, 07:50:13 AM
(...)
If you want to give xp to each kill of enemy, you can modify the enemy metatable to add the xp value of enemy to the xp counter of your hero (it can be a formula if easy enemy give you less and less xp to avoid the "easy farm" ^^).
(...)
I modified the enemy metatable to add the xp value, but the problem is that the value is common to every enemy. It could be ok for a bonus. I have probably misunderstood.
#108
Thank you for your test.
I also tested with Mystery of Solarus (engine v1.4.2) and the problem is the same. It is not really a bug, but I would be happy to find a solution, even if it is just a workaround.
#109
I use a destructible entity, not a custom entity.
Not so cool for me. 8)
#110
Hello,

I would like an object that can regenerate.
But, my problem is that when I tick the option to regenerate, there are two animations of destruction:
First, there is an animation of destruction (with the sound) when the hero begins to lift an object
and then, there is the same animation and the same sound when the hero is destroying this objet (after having throwing it).
The first animation is OK for a "flower bomb", not too ugly for a bush, but strange for a rock or something in wood.

Is there a way to have two animations and sounds or even delete the first animation of destruction and its sound?
I tried with metables, but I did not succeed.

Thanks in advance.
#111
Quote from: 20degree on October 28, 2015, 12:35:14 AM
I have put some rectangles that have some " ? " into it. I have called it as "exit_sensor", then i have copy it and past it, and ive notice that it is writen "exit_sensor_2", etc, etc.
This is normal. Different sensors with the same name (e;g: "exit_sensor",  "exit_sensor_2",  "exit_sensor_3") can activate the same  object (They can open a same door if the object is a door).

Quote from: 20degree on October 28, 2015, 12:35:14 AM
The next thing i wonder, is that the software "Tree" on the left. There is the folder called "script". I wonder if it is there i add the script that i could call as example: "town_exit_sensor.lua"?
No, it is easier in the map script as explained in tutorials (see below). In the tree, "solarus" > "maps" > Right click on the map > and "Open map script"

- Part 13: Lost Woods (youtube)
- Chapitre 13 : Les Bois Perdus (youtube)
- Chapitre 13 : Les Bois Perdus (Adaptation écrite)

#112
You forgot an "end" in your function.

Otherwise, I would test with something like that:
if game:get_value("_item_slot_1") == "bow" or game:get_value("_item_slot_2") == "bow" then
#113
Development / Re: Help? :/
October 18, 2015, 12:35:09 PM
I use repl.it to test and understand basic commands of Lua (There are different languages).


#114
Your projects / Re: Solarus - ZL project
October 18, 2015, 04:12:55 AM
Thank you, polyglot762  :)
I tried to follow the board members of another forum: new clouds, smaller sun and softer color frame at the horizon.
The island is slightly adapted to the new pixel art .



New pixel art with 11 colors again, most of which are taken from the first pixel art:


EDIT:
Just a mockup of a dragon of fire. Hope it will not too difficult to script. ;)


EDIT2:
A memory with Solarus!!! Solarus is so 8).  I want to improve my scripting skills before beginning to animate for example a boss with all its attacks.
The Memory will be a mini game, but I think it will be include it in my main project.
In-game:
#115
Your projects / Re: Solarus - ZL project
October 11, 2015, 01:28:04 AM
I drew this background image which will be probably used for the credits . There are 11 colors.

Are the colors of the image correct? Clouds not too ugly ?
Things that are not corrects?

#116
Development / Re: Scrolling credits
October 10, 2015, 05:57:55 PM
I share my script if you like. I think it's pretty simple to customize.
#117
Development / Problem with fade_in and fade_out methods
October 04, 2015, 06:53:51 PM
Hello,

I don't know if there is a bug with the following methods:
drawable:fade_in([delay], [callback])
and
drawable:fade_out([delay], [callback])

I make maybe some mistakes in the use of these methods. :-[
These methods work, but at the end, the chosen colors are not exactly the same.
When I picked the color in an image editor (e.g. Gimp), I can see it's darker.
It is as if the surface kept a little transparency at the end of my fade_in() . Even when I used surface:clear()

So instead of writing this,
self.bg_surface:fade_in()

I write this:
self.bg_surface:fade_in(20, function () self.bg_surface:set_opacity(255) end)

This workaround may not work with text_surface, because there is no text_surface:set_opacity(opacity)
Is there a solution?
#118
Development / Re: Problems with dialog and HUD
September 09, 2015, 12:19:28 AM
In game_manager.lua, I would replace

Code ( lua) Select
  -- Function called when the player goes to another map.
   game.on_map_changed = function(game, map)
     
  -- Notify the HUD (some HUD elements need to know that).
hud:on_map_changed(map)
   end


by this:

Code ( lua) Select
  -- Function called when the player goes to another map.
   function game:on_map_changed(map)
     
  -- Notify the HUD (some HUD elements need to know that).
hud:on_map_changed(map)
   end
#119
Quote
If I were you , I would start with the basic menu of Zelda Mystery of Solarus DX, then I would adapt it to my needs. In fact, this is how I proceed. ;)

Just minor changes for the moment :-[
- A new hud for the hearts (link).
- Added an icon next to the caption text when the item is selected.
- Changed the size of icons in the dialog box. 16 pixels wide , it was too small for face sprites.
- The title of sub-menus is a text surface and not a picture. I also found a way to get a gradation of colors playing with several text surfaces.
#120
OK so I fetch in this sense.
Thank you!