Recent Posts

Pages: [1] 2 3 ... 10
1
Development / Re: Randomnize table ?
« Last post by Diarandor on December 10, 2017, 05:46:42 pm »
Remember to initialize a random seed once, and only once (the recommended way is to use the time as seed). This could be done in your main script.
2
Development / Re: Randomnize table ?
« Last post by MetalZelda on December 10, 2017, 05:33:28 pm »
That depends on what you want to do.

1) If you want to show only the treasure of the chest you opened and not the others, then you only need a random number between 1 and #minigame_prizes (remember to rename your list "minigame_prices" to "minigame_priZes", because it's not the same thing). You can use:
Code: [Select]
local index = math.random(1, #minigame_prizes)
local prize = minigame_prizes[index]

2) If you want to show where all prizes are after you open the chest, then you need to code a random permutation. I would use the "Knuth shuffles" permutation algorithm (it is very simple and the code is short); you can adapt the code from here:
https://en.wikipedia.org/wiki/Random_permutation
You can either permute the prizes list directly, or permute a list with numbers from 1 to #minigame_prizes and then use the permuted indices list to associate the prizes to the corresponding chests.

We all enjoy games with chests. Does that mean we are all perverts?  :o

Yes, that's the way I wanna go
I did found some workaround by setting a random treasure at chest opening sequence

Code: Lua
  1. -- Define what happen when the player tries to open a chest
  2. -- Since chests are empty (no treasure), that makes things easier
  3. for chests in map:get_entities_by_type("chest") do
  4.   chests.on_opened = function()
  5.     if minigame_state == "end" then
  6.       sol.audio.play_sound("error")
  7.       game:start_dialog("minigame.chest.need_pay", function()
  8.         sol.audio.play_sound("objects/minecart/landing")
  9.         chests:set_open(false)
  10.         hero:unfreeze()
  11.       end)
  12.     else
  13.       local rng = math.random(1, #minigame_prizes)
  14.       rng = minigame_prizes[rng]
  15.  
  16.       local treasure, variant, savegame = rng[1], rng[2], rng[3]
  17.       hero:start_treasure(treasure, variant + 1, savegame, function()
  18.         game:start_dialog("minigame.chest.finished")
  19.       end)
  20.       minigame_state = "end"
  21.      
  22.     end
  23.   end
  24. end

I don't know if there's a better way to do so, since rng only applies when the choosen chest has been opened
Oh well, it does what I wanted

Y'all love chests chest is love chest is life :o
3
Development / Re: Randomnize table ?
« Last post by Diarandor on December 10, 2017, 05:13:24 pm »
That depends on what you want to do.

1) If you want to show only the treasure of the chest you opened and not the others, then you only need a random number between 1 and #minigame_prizes (remember to rename your list "minigame_prices" to "minigame_priZes", because it's not the same thing). You can use:
Code: [Select]
local index = math.random(1, #minigame_prizes)
local prize = minigame_prizes[index]

2) If you want to show where all prizes are after you open the chest, then you need to code a random permutation. I would use the "Knuth shuffles" permutation algorithm (it is very simple and the code is short); you can adapt the code from here:
https://en.wikipedia.org/wiki/Random_permutation
You can either permute the prizes list directly, or permute a list with numbers from 1 to #minigame_prizes and then use the permuted indices list to associate the prizes to the corresponding chests.

We all enjoy games with chests. Does that mean we are all perverts?  :o
4
Development / Randomnize table ?
« Last post by MetalZelda on December 10, 2017, 02:31:53 pm »
Hello

Today I am mostly programming minigames, one of which is based on ALTTP.
But, I have taken another view of how the minigame would work.
Winnable items are shown before the game starts like so



Then a movement starts on winnable item's entity and the minigame starts.

This leads me to this question to make the minigame more dependant of an RNG (Random Number Generator) to make the minigame a bit more difficult
Winnable items are stored in a table

Code: Lua
  1. local minigame_prices = {
  2.   {"rupee", 0},
  3.   {"amber_counter", 0},
  4.   {"green_chuchu_counter", 0},
  5.   {"heart_piece", 0},
  6.   {"arrow", 0},
  7.   {"rupee", 3},
  8.   {"heart", 0},
  9.   {"rupee", 5},
  10.   {"rupee", 2},
  11. }

Basically, it is

[chest 1] treasure = rupee, variant = 0

All I want is

[chest (random 1 - 9)] treasure = rupee, variant = 0

Any idea of how to make it happen ?
5
Your scripts / Re: Archery Minigame / Mini-jeu de tir à l'arc
« Last post by MetalZelda on December 10, 2017, 12:55:59 pm »
I like how it's done, it reminds me of a shooting game in Anciant Stone Tablets
6
Development / Re: [SOLVED]Change map graphics during play
« Last post by Diarandor on December 08, 2017, 05:05:49 pm »
I am not sure, but maybe shaders are already functional in the development version of the engine. Chris can tell you that. I don't know if that is included in the last snapshots.

In my opinion, duplicating all tilesets and sprites is too crazy and bad. Don't do it in that way. Wait 2-3 months until shaders are finished and do it with clean code.
7
Development / Re: Change map graphics during play
« Last post by Satoh on December 08, 2017, 06:20:05 am »
I actually missed it while I was reading, but if I make a duplicate of each tileset, with the specific graphical alterations I need, there IS a function to swap tilesets while the map is loaded.

map:set_tileset(tileset_id)

It'll mean duplicating all my tilesets, but it'll work in lieu of waiting around for shaders...which I may not even figure out how to use.
8
Development / Re: Besoin d'aide pour le dialogue de début
« Last post by Delltus on December 08, 2017, 12:39:12 am »
problème résolue merci à vous !
9
Development / Re: Besoin d'aide pour le dialogue de début
« Last post by Diarandor on December 07, 2017, 08:48:10 pm »
It can be done in some of your initialization scripts, like the scripts main.lua or game_manager.lua, or other similar script.
Check the API to know how to do it: http://www.solarus-games.org/doc/1.5/lua_api_language.html
In your case, this line should be enough for now:
Code: Lua
  1. sol.language.set_language("fr")
10
Development / Re: Besoin d'aide pour le dialogue de début
« Last post by Delltus on December 07, 2017, 08:39:40 pm »
Oui c'est surement ça vue qu'ils y avais aucune langue j'ai juste copier coller le dossier, la langue ce configure ou ?
Pages: [1] 2 3 ... 10