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.

Messages - MetalZelda

Pages: [1] 2 3 ... 35
Development / Re: Randomnize table ?
« 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:
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
  7.       game:start_dialog("minigame.chest.need_pay", function()
  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]
  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"
  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

Development / Randomnize table ?
« on: December 10, 2017, 02:31:53 pm »

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 ?

Your scripts / Re: Archery Minigame / Mini-jeu de tir à l'arc
« 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

Your scripts / Re: New rain script
« on: November 18, 2017, 01:14:59 pm »
It is much better now, this is awesome, thanks for this awesome script !

Your scripts / Re: New rain script
« on: November 14, 2017, 04:26:24 pm »
Yes, snow should not be harder than this. But better to make it in a different script because the rain script is already very complex due to the smooth transition between different rain modes (the rain drop number and their properties, and the darkness value, vary very smoothly). If you can wait for Christmas holidays, I will probably make the snow script for then.

Snow can be easy to make, just by editing the rain script, it tooks me around 5 minutes to make sprites and edit stuffs and the result is ok (if you take out the green terrain which don't fit the snow weather)
The snow effect is better with the drop deviation variable

Great thing is, it is really easy to include the weather script with my day / night cycle, I don't see any problem so far

Your scripts / Re: New rain script
« on: November 12, 2017, 07:10:34 pm »
Oh wow, definately gonna use it for my project, this is gonna serve environment purpose I've tough some time ago
Wonder if other effects can be achieved just by modifying your script (snow)

Gonna look around if this script can fit in my Day / Night script

Development / Re: Variable music.
« on: November 01, 2017, 11:55:42 pm »
I should go like this

In your music directory, name your music like so 'music_name_0, music_name_1', etc, etc

In your code

Code: Lua
  1. local music = math.random(0, x) -- Where X = number of music with as name "music_name_"
  2. local function play_music()
  3."music_name_" .. music, function()
  4.     -- Re-random the music
  5.     -- Get the old number
  6.     local old = music
  8.     -- Set a new random value
  9.     music = math.random(0, x)  -- Where X = number of music with as name "music_name_"
  11.     -- Avoid repetition
  12.     if music == old then
  13.       -- Re-random the music number
  14.       music = math.random(0, x)  -- Where X = number of music with as name "music_name_"
  15.     end
  17.     -- Call the function to play another music
  18.     -- Remark, if you use "LOOPSTART" in the music metadata, the callback (this code essentially) will never be called.
  19.     play_music()
  20.   end)
  21. end
  23. -- Start the music. The only way to cancel the phase is to use
  24. play_music()

That's basic stuff but that's the way to go essentially.

If you want to play specific tracks rather than random one, you can do the same thing, just replace music = math.random(0, x) by music = (music + 1) % x (replace x by the number you want, this is the number of tracks you wanna play)

Development / Removing a sprite created through sol.sprite.create ?
« on: October 08, 2017, 05:18:54 pm »

I'm having troubble with cutscenes and sprites management.
I am currently making sage cutscenes with as inspiration ALTTP, but, after a while, the crystal around the sage needs to be removed

The sprite creation is a bit different because the cutscene starts immediately after the boss died, a surface fades to accomplish the black background, a menu handles the whole cutscene (mostly to overwrite and avoid pausing / moving, doing actions during cutscene)

Sprites are created in this order

black surface
Link sprite
Sage sprite
Crystal sprite

All created by sol.surface / sprite.create

But, calling

Code: [Select]
this happen

Code: [Select]
Error: In timer callback: [string "maps/cutscene_data/SageScene_0.lua"]:95: attempt to call method 'remove' (a nil value)
I can't use map entities because the menu is started above everything on the map, entities are not visible during the cutscene because of the background surface
Which confuse me a bit, we can't remove a sprite ?

Bugs & Feature requests / Re: Hero scaling
« on: September 24, 2017, 11:39:43 pm »
The thing is scale2x or hq2x actually does what you want, 2x bigger sprites.

The interesting thing would be manually configure the hero's hitbox width and height, I think the hitbox is a 16x16 and non-customizable at the moment

Your scripts / Re: Fractals !
« on: September 24, 2017, 11:36:16 pm »
Interesting concept, I've always been amazed by fractals

Your scripts / Re: Turtle Rock (Alttp) Pipe system
« on: September 07, 2017, 10:01:33 am »
Code: [Select]
Wait such thing is possible ?

Development / Re: Multiple ground sprites?
« on: September 01, 2017, 12:13:42 am »
Should be fairly possible with greyscaled sprite

This is the cheapest solution I have in mind

Development / Re: How to use: chest:on_opened() ?
« on: July 11, 2017, 06:40:12 pm »
Thank for the answere
With this code
Code: [Select]
function sword_chest:on_opened(sword, 1, "sword_chest_save")
  chest_open = chest_open + 1

I have another error
Error: Failed to load script 'maps/dungeons/tuto/place_holder': [string "maps/dungeons/tuto/place_holder.lua"]:5: <name> or '...' expected near '1'

I don't understand why...

Do like this
Don't know if this will work because I never use chest:on_opened() but that's the way to go

Code: Lua
  1. function sword_chest:on_opened(item, variant, savegame)
  3.   if item:get_name() == "sword" then
  5.   end
  6. end

Development / Re: How to use: chest:on_opened() ?
« on: July 11, 2017, 02:23:55 pm »

The first argument need to be an item, what you've done is that the first argument is a string

General discussion / Re: Le défi de Zeldo : La vengeance du bingo
« on: July 03, 2017, 01:51:22 am »
From what I've seen this is a big Zelda-1 like labyrinth
Looks like it has been made by ZeldoRetro

Reminds me of Darunia's Cavern from Parallel Worlds as well

Pages: [1] 2 3 ... 35