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 - Diarandor

#931
Development / Re: Carrying custom entities
September 19, 2015, 01:25:41 AM
The custom_interactions.lua is used to detect the entity and notify the hud that the hero can lift the entity (we may need to add something to the hud script). It works adding a collision test created with collision_test_manager.lua (this script allows to add/remove only one collision test, which is useful to remove the lifting-detection collision test after the entity has been lifted and add it again when the entity has fallen to the ground).

We will deal later with the save_between_maps.lua (not so important for now), which will allow to save position in a map for what I call independent entities. Forget about this script for now.
#932
Development / Re: Carrying custom entities
September 19, 2015, 01:19:10 AM
I have added you as a collaborator in my repository (I think I did it correctly but not sure), its here:
https://github.com/Diarandor/portable_entities

First, add these scripts to your data scripts folder:
1) collision_test_manager.lua
2) custom_interactions.lua
3) save_between_maps.lua
and the following to the (custom) entities scripts folder:
4) generic_portable.lua

The script (4) is the main one. As first step, create a custom entity in the map editor with this script in some map (and put some 16x16 sprite on it). It is necessary to create an animation set for the hero to make him carry the entity.

We need to add some things to your game_manager script (see the notes in my game_manager script in the repository to know where to add these parts of code). Add these lines:

-- First

sol.main.load_file("scripts/custom_interactions.lua")(game)
sol.main.load_file("scripts/collision_test_manager.lua")(game)

-- Second

    -- Modify metatable of hero to make carried entities follow him with hero:on_position_changed().
    local hero_metatable = sol.main.get_metatable("hero")
    function hero_metatable:on_position_changed()
      if self.custom_carry then
        local x, y, layer = self:get_position()
        self.custom_carry:set_position(x, y+2, layer)
      end
    end
    local hero_tunic_sprites_id = {[1] = "tunic1", [2] = "tunic_carrying1"} -- Tunic names.
    function hero_metatable:set_carrying(boolean)
      local i = 0; if boolean then i = 1 end
      hero:set_tunic_sprite_id(hero_tunic_sprites_id[i])
    end

--Third (this will be harder). In the event "function game:on_command_pressed(command)", add the two parts of code I say in the code:

        local action_effect = game:get_custom_command_effect("action")
        -- Custom action effects.
        if action_effect and game:get_interaction_entity() then
         game:get_hero().custom_interaction:on_custom_interaction(); return true
        end

and

      if attack_effect == "custom_carry" then
      -- THIS IS NEEDED FOR THE GENERIC_PORTABLE.LUA SCRIPT!!!!
        game:get_hero().custom_carry:throw(); return true
      end


You will get some errors at first. I will help you to solve them and make it work. (Note that I had some parts of the code mixed with other scripts so we may have some problems at present.) Let me know what you get in the error.txt.
#933
Development / Re: Carrying custom entities
September 18, 2015, 01:19:10 AM
Cool. I will notify you when I have it ready, in a few days (it's almost ready but I need to make a few more changes in my code).
#934
Development / Re: Carrying custom entities
September 17, 2015, 03:25:22 PM
Hi! I want to make this script usable for other people, so I'm gonna simplify my script (which has unnecessary features for other people). I'd like to put it in the libsolarus-mudora repository when it is ready, so other quest makers can use it for their games.

@wrightmat :
Are you interested in these scripts to carry custom entities? If so and you have some free time, I ask for your help, mainly as a tester, but also to improve the explanation comments of the scripts (which may be a bit unclear at present) and give some suggestions to improve the code. If you agree, I will send you a simplified version of it as soon as I can (a simplified version of the one of my repository), maybe this week. I will explain to you what needs to be done to make it work. We can talk by email if you prefer.
#935
I have never used LibreOffice and never heard about it before, so I don't know how it is. LaTeX is something like a text editor and a programming language at the same time, and has hundreds or thousands of libraries to do whatever you want (although for your purposes you do not need that). All serious science  researchers of physics, maths, and other sciences use it to make their articles, although it can be used to write a book or whatever.

Of course, LaTeX is very very active, but normal people without programming knowledge are afraid of these things and use programs like Word and convert it with PDFCreator or other tools (much easier but not professional and bad quality).

LaTeX is not hard to to learn (at least compared to Lua, and Lua is a very very easy programming language, so don't be scared of it). I use the Miktex distribution (you can find it with google) but there are others. You also need an editor to use LaTeX, and there are lots of choices (the one I use is TeXnicCenter, which is free and multiplatform if I am not wrong, but there are other good and better editors too that you can find using google). (I use it to write my math articles, and currently to write my PhD thesis. So I would gladly help you if you choose to use Tex.)

Anyway, this was just my opinion. You are free to use the program you want, and it will be a huge work in any case. Good luck with this work!!! ;D
#936
I still think it would be much better to use LaTeX, as someone said before. LaTeX is very professional (it's usually the one used to write scientific articles) and you would not have that problem with the links to reference other pages when the pages change. If you change your mind I might help you using Tex when I have some free time.
#937
If you plan to use Latex and need some help, maybe I could help you, I have some experience with it.
#938
Development / Re: Problems with dialog and HUD
September 07, 2015, 07:21:53 AM
As the error says, you are trying to load the settings.dat file, but this file (or the path you give to load it) do not exist.

On the other hand, I think you do not have the image that you store on the variable zs_presents_img in the correct path for it to be opened, or you are not opening it correctly, which would explain why your zs_presents_img variable is nil.
#939
Development / Re: Scrolling credits
September 06, 2015, 06:18:15 PM
I think you forgot to draw the lines (stored in your line list) in the map:on_draw event. That should solve the main problem.
#940
Development / Re: Problems with dialog and HUD
September 05, 2015, 07:17:52 PM
In the hud script, there are global menu variables that you could define as local. Also, you wrote self.hud instead of hud.elements, could that be related to the error?
#941
Development / Re: Problems with dialog and HUD
September 05, 2015, 04:10:15 AM
I could not find the problem, sorry.
Maybe Christopho or other programmers can help you to find what is wrong.
#942
Development / Re: Problems with dialog and HUD
September 05, 2015, 03:44:45 AM
The first error is strange. As you already know, it means that the hud variable is nil.
Maybe something is not working in the line "hud = hud_manager:create(game)"
(this could be because your hud_manager:create(game) is not returning a hud for some reason, or something like that). So, maybe the problem is in the hud script, could you post it?
#943
Development / Re: Problems with dialog and HUD
September 05, 2015, 03:30:50 AM
The second error is due to that the function get_dialog_font is not defined by the engine (you can check it does not appear in the Lua API). In some scripts I have seen, it appears defined in the main script (the game manager would be another option to define that). Try to put in the main.lua the following code (but change the font names to the ones you are using):

-- Returns the font and font size to be used for dialogs
-- depending on the specified language (the current one by default).
function sol.language.get_dialog_font(language)
  -- For now the same font is used by all languages.
  return "fixed8", 11
end

-- Returns the font and font size to be used to display text in menus
-- depending on the specified language (the current one by default).
function sol.language.get_menu_font(language)
  -- For now the same font is used by all languages.
  return "Viner Hand Itc", 8
end
#944
Development / Re: Scrolling credits
September 05, 2015, 02:56:26 AM
Hi! There are lots of ways to do this. I would do the following:

I would put the code of the credits in the script of a map like you have done.

In that script, I would define a function called "function map:start_line(text_line)". This function would create a text surface with the given text (text_line), set the initial coordinates x,y of the text surface, create/start the movement, and define an event movement:on_position_changed() so that when the text surface has reached the end we can use the fade_out() function or something like that. (You can also put this code inside the map:on_started() function and not define the function, as you have done, but it's not important.)

In the event "function map:on_started(destination)", I would use a timer which calls the function map:start_line(text_line) on each iteration to create a new line. (You can increase a variable n -> n+1 at each iteration and set text_line = credits[n], or something like that.) You need to set a suitable amount of time for the timer, so that the lines are created with the desired separation, and obviuosly destroy the timer when you reach the end of your "credits" list.

With small changes of your code you can do it. (I think that you forgot to set as local the variable line_text.)

#945
Development / Re: Question about dynamic tiles
September 04, 2015, 10:47:11 PM
You are right Christopho, it should be possible.

So, as you say, there won't be any problem with the grid alignment since we can check the ground on the four corners of the 16x16 square. And the idea of parsing the map is great, I didn't think of that possibility.

There are two possible behaviours for the shovel in the following particular case: if the ground can be dug in some of the corners of the 16x16 tile (aligned to the 16x16 grid) but not in all of them, then we can either
1) make the shovel to clash with the ground, or
2) make the shovel to dig only in the 8x8 parts (of the 16x16 square) that can be dug (to do this, we create 8x8 tiles in the correct positions).
Although this is not very important, I think the first option is much better and simpler in this particular case.

To check the collision with a custom entity "digging hole", I think that the best/fastest option could be to call once the function map:get_entities_in_rectangle(x, y, width, height) (when Solarus 1.5 is released, with this function), and then check if there is some hole entity overlapping the corresponding 16x16 square.

(Since I'm not having much free time lately, I will wait for someone to write this script, or I will try to do it by myself when I have some free time.)