I haven't read the whole API for LUA, that's why I thought it only accepted intergers, thanks for the feedback

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-- Leveling up System by Miguelink 64.
-- First make a leveling up item on your items folder, I used a +2 to max hp for every level up.
-- heart_container
local item = ...
local game = item:get_game()
function item:on_obtaining()
game:add_max_life(2)
game:set_life(game:get_max_life())
end
-- Add to your dialogs a _treasure dialog for the item, mine says "Level up!".
-- You must copy this script to your enemies you want to give you exp.
local exp = 1 -- Change this to the wanted experience given by killing the enemy.
function enemy:on_dead()
if game:get_value("level") ~= game:get_value("max_level") then
game:set_value("experience",game:get_value("experience") + exp)
if game:get_value("experience") >= game:get_value("max_experience") then -- Checks if you can level up
hero:start_treasure("heart_container") -- You can change this for your leveling up item.
game:set_value("max_experience",game:get_value("max_experience") * 2) -- Doubles the amount needed to level up next time.
game:set_value("experience",0) -- Resets experience
game:set_value("level",game:get_value("level") + 1) -- Level up
end
end
end
-- You must copy this script to your initial game script under
-- function initial_game:initialize_new_game(game)
game:set_value("max_experience",50) -- Max experience needed to level up from level 1 to level 2
game:set_value("experience",0) -- Creates experience
game:set_value("max_level",20) -- Max level achievable
game:set_value("level",1) -- Start at level 1
Quote from: Max on March 02, 2019, 12:39:05 AM
Ah, I misunderstood "hard version of ALTTP". Good choice, I think, and a great way to learn. If you didn't already hear, there's a discord many people are active on if you can't find any answers in the forums : )
Quote from: Max on March 01, 2019, 04:33:48 PM
Nice, looks like a great start! You've already got a lot of things working, looks like you're coming along!
A little feedback I have is that a remake of the entirety of ALTTP is quite a lot for a first project. Smaller projects, in my experience, are more likely to get finished.
-- Event called when the game pauses
function game:on_paused()
game:start_dialog("pause.menu.question",function(answer) -- Opens the "menu"
if answer == 1 then -- Items
if game:has_item("boomerang") == true then -- Checks if you have an item
game:start_dialog("pause.menu.items.1",function(answer) -- Shows item
if answer == 1 then
game:set_item_assigned(1,game:get_item("boomerang")) -- Assigns selected item to Slot 1
sol.audio.play_sound("danger")
game:set_paused(false)
end
end)
else -- If you don't have items at all
game:start_dialog("pause.menu.items.no_items")
game:set_paused(false)
end
end
if answer == 2 then -- Save and continue
game:save()
sol.audio.play_sound("danger")
game:set_paused(false)
end
if answer == 3 then -- Save and Quit (Closes the game)
sol.audio.play_sound("danger")
game:save()
sol.main.exit()
end
if answer == 4 then -- Continue
sol.audio.play_sound("danger")
game:set_paused(false)
end
end)
end
-- Event called when the game pauses
function game:on_paused()
game:start_dialog("pause.menu.question",function(answer) -- Opens the "menu"
if answer == 1 then -- Items
if game:has_item("boomerang") == true then -- Checks if you have an item
game:start_dialog("pause.menu.items.1",function(answer) -- Shows item
if answer == 1 then
game:set_item_assigned(1,game:get_item("boomerang")) -- Assigns selected item to Slot 1
sol.audio.play_sound("danger")
game:set_paused(false)
end
end)
else -- If you don't have items at all
game:start_dialog("pause.menu.items.no_items")
game:set_paused(false)
end
end
if answer == 2 then -- Save and continue
game:save()
sol.audio.play_sound("danger")
game:set_paused(false)
end
if answer == 3 then -- Save and Quit (Closes the game)
sol.audio.play_sound("danger")
game:save()
sol.main.exit()
end
if answer == 4 then -- Continue
sol.audio.play_sound("danger")
game:set_paused(false)
end
end)
end