Je peux parler fr ce sera plus simple ?
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.
#32
Development / Re: Small Key HUD ?
April 05, 2017, 02:36:04 PM
It's not possible to have a simple script for the keys ? I don't want to have different key counters in each dungeon... I can't just have a really simple key counter like rupee but for the key ?
#33
Development / Re: Small Key HUD ?
April 05, 2017, 02:13:38 PM
I have used the code you gived to me ("small_key" and "equipment") but now, when I take a key I got an error:
Error: In on_obtaining: [string "items/small_key.lua"]:12: attempt to call method 'add_small_key' (a nil value)
Why ?... What sort of things I need to do to make it work well ?!
Error: In on_obtaining: [string "items/small_key.lua"]:12: attempt to call method 'add_small_key' (a nil value)
Why ?... What sort of things I need to do to make it work well ?!
#34
Development / Re: Small Key HUD ?
April 05, 2017, 06:51:25 AM
I don't really know what I modify... I'm trying with chance. For now I got two counter, one for rupee with rupee's icon and an other rupee's counter with key's icon but I would like it display the number of keys... I have a big problem with variable and the save in solarus... (Where is the variable "money"..., how to use a variable from an item...)
#35
Development / Re: Small Key HUD ?
April 04, 2017, 09:31:48 PM
Thank for your answers but I'm really begining in the world of programmation... For now, I'm trying to modifiying the christopho's script for the HUD called rupee but I don't know how it work... I have already check those scripts but it's to complicate (I'm talking about mercuris chess)...
The ruppee code in the tutorial:
The ruppee code in the tutorial:
Code Select
-- The money counter shown in the game screen.
local rupees_builder = {}
local rupee_icon_img = sol.surface.create("hud/small_key_icon.png")
function rupees_builder:new(game, config)
local rupees = {}
local digits_text = sol.text_surface.create({
font = "white_digits",
horizontal_alignment = "left",
vertical_alignment = "top",
})
local money_displayed = game:get_money()
local dst_x, dst_y = config.x, config.y
function rupees:on_draw(dst_surface)
local x, y = dst_x, dst_y
local width, height = dst_surface:get_size()
if x < 0 then
x = width + x
end
if y < 0 then
y = height + y
end
rupee_icon_img:draw(dst_surface, x + 8, y)
digits_text:draw(dst_surface, x, y + 10)
end
-- Checks whether the view displays correct information
-- and updates it if necessary.
local function check()
local need_rebuild = false
local money = game:get_money()
local max_money = game:get_max_money()
-- Current money.
if money ~= money_displayed then
need_rebuild = true
if money_displayed < money then
money_displayed = money_displayed + 1
else
money_displayed = money_displayed - 1
end
if money_displayed == money -- The final value was just reached.
or money_displayed % 3 == 0 then -- Otherwise, play sound "rupee_counter_end" every 3 values.
sol.audio.play_sound("rupee_counter_end")
end
end
if digits_text:get_text() == "" then
need_rebuild = true
end
-- Update the text if something has changed.
if need_rebuild then
digits_text:set_text(string.format("%03d", money_displayed))
-- Show in green if the maximum is reached.
if money_displayed == max_money then
digits_text:set_font("green_digits")
else
digits_text:set_font("white_digits")
end
end
return true -- Repeat the timer.
end
-- Periodically check.
check()
sol.timer.start(game, 40, check)
return rupees
end
return rupees_builder
#36
Development / Small Key HUD ?
April 04, 2017, 09:05:39 PM
Hello, I followed Christopho's tuto and I don't understand how to display a small key counter...
The small_key item:
Thank you for helping me !
The small_key item:
Code Select
local item = ...
local game = item:get_game()
--small_key option
function item:on_created()
self:set_shadow("small")
self:set_can_disappear(false)
self:set_brandish_when_picked(true)
self:set_sound_when_picked("picked_small_key")
item:set_amount_savegame_variable("small_keys_save")
end
--small_key save
function item:on_obtaining()
item:add_amount(1)
end
Thank you for helping me !
#37
Development / Re: I have not understand the save of items (small_key)
August 03, 2016, 02:28:12 AM
Realy thanks ! I can sleeping well now ! Bye ! Maybe later... to help me pass the beginner steps !
#38
Development / Re: I have not understand the save of items (small_key)
August 03, 2016, 02:17:22 AM
But there is an eroor in the consol with that : Error: In on_obtaining: [string "items/small_key.lua"]:16: bad argument #1 to add_amount (integer expected, got nil))
#39
Development / Re: I have not understand the save of items (small_key)
August 03, 2016, 02:10:10 AM
Oh thank !!! It works !!! It's the first time than I do something which works with solarus ! Thank you !
#40
Development / Re: I have not understand the save of items (small_key)
August 03, 2016, 02:01:47 AM
With this code, if I take two keys, I just can open one door after...
How can I and where I need to inizialize a other variable for the amouts ?
I really sorry because I am a real beginners ...
How can I and where I need to inizialize a other variable for the amouts ?
I really sorry because I am a real beginners ...
#41
Development / Re: I have not understand the save of items (small_key)
August 03, 2016, 01:38:46 AM
It does not work...
Where I need to add this ligne ?
Where I need to add this ligne ?
Code Select
local item = ...
function item:on_created()
item:set_savegame_variable("small_key_save")
self:set_amount_savegame_variable("small_key_save")
item:set_shadow("small")
item:set_can_disappear(false)
item:set_brandish_when_picked(true)
item:set_sound_when_picked("picked_small_key")
end
#42
Development / Re: I have not understand the save of items (small_key)
August 03, 2016, 01:22:30 AM
It is possible to increment this variable when we take a other key ?
#43
Development / Re: I have not understand the save of items (small_key)
August 03, 2016, 01:12:49 AM
Ok, thanks a lot !!!
#44
Development / Re: I have not understand the save of items (small_key)
August 03, 2016, 12:46:43 AM
I have made juste one map with a door !
I give you my project...
http://www.mediafire.com/download/e4i1ad61k3enfio/The+legend+of+zelda+and+the+solitary+hero.zip
I give you my project...
http://www.mediafire.com/download/e4i1ad61k3enfio/The+legend+of+zelda+and+the+solitary+hero.zip
#45
Development / Re: I have not understand the save of items (small_key)
August 03, 2016, 12:31:32 AM
This is my map script :
Code Select
-- Lua script of map Outdoor_hero_house.
-- This script is executed every time the hero enters this map.
-- Feel free to modify the code below.
-- You can add more events and remove the ones you don't need.
-- See the Solarus Lua API documentation:
-- http://www.solarus-games.org/doc/latest
local map = ...
local game = map:get_game()
-- Event called at initialization time, as soon as this map becomes is loaded.
function map:on_started()
-- You can initialize the movement and sprites of various
-- map entities here.
end
-- Event called after the opening transition effect of the map,
-- that is, when the player takes control of the hero.
function map:on_opening_transition_finished()
end