1
Fork 0
mirror of https://github.com/Steffo99/noita-starting-perk.git synced 2024-11-23 14:14:20 +00:00

Convert the mod to a different one

This commit is contained in:
Steffo 2023-03-24 22:52:20 +01:00
parent a287e0b025
commit 2dea221deb
Signed by: steffo
GPG key ID: 2A24051445686895
6 changed files with 11 additions and 64 deletions

View file

@ -6,70 +6,18 @@ dofile("data/scripts/lib/mod_settings.lua")
function OnPlayerSpawned( player_entity ) function OnPlayerSpawned( player_entity )
-- Run this only once per game -- Run this only once per game
local init_check_flag = "starting_perk_init_done" local init_check_flag = "veggies_init_done"
if GameHasFlagRun( init_check_flag ) then if GameHasFlagRun( init_check_flag ) then
return return
end end
GameAddFlagRun( init_check_flag ) GameAddFlagRun( init_check_flag )
-- Load mod settings
local perks_amount = math.ceil(ModSettingGet("starting_perk.perks_spawned"))
local only_one = ModSettingGet("starting_perk.only_one")
-- Print mod settings to the player -- Print mod settings to the player
if only_one then GamePrint("Starting with the Eat Your Vegetables perk")
GamePrint("Starting with a choice between " .. to_string(perks_amount) .. " perks")
else -- Spawn the actual perk
GamePrint("Starting with " .. to_string(perks_amount) .. " free perks") local perk_entity = perk_spawn( 771, -96, "FOOD_CLOCK" )
end
-- Give the perk to the player
local x_center = 789 perk_pickup( perk_entity, player_entity, EntityGetName( perk_entity ), false, false )
local y_bottom = -96
local gap = 6
local size = 14
local offset = gap + size
-- Find the number of rows
-- Ceil makes it wider instead of taller
local rows = math.ceil(math.sqrt(perks_amount))
-- Draw perk rows
for current_row = 1, rows, 1 do
-- Find the number of columns
local cols
if perks_amount < rows then
-- Spawn only the leftover amount
cols = perks_amount
else
-- Spawn the full amount
cols = rows
end
-- If there is something to spawn
if cols ~= 0 then
-- Find the total row width
local width = (offset * cols) + size
-- Find the X position to start spawning perks at
local x_left = x_center - (width / 2)
-- Draw perk columns
for current_col=1, cols, 1 do
-- Find the position to spawn each perk at
local x = x_left + (current_col - 1) * offset
local y = y_bottom - (current_row - 1) * offset
-- Spawn the perk
perk_spawn_random(x, y, not only_one)
perks_amount = perks_amount - 1
end
end
end
-- Used to take the screenshot
-- perk_spawn( 771, -96, "GENOME_MORE_LOVE" )
end end

View file

@ -1,6 +1,6 @@
<Mod <Mod
name="Starting perk" name="Eat your vegetables"
description="Start every run with a perk from the Holy Mountain pool." description="Start every run with the Eat Your Vegetables perk."
request_no_api_restrictions="0" request_no_api_restrictions="0"
> >
</Mod> </Mod>

View file

@ -1 +1 @@
starting_perk veggies

View file

@ -1,6 +1,6 @@
<Mod <Mod
name="starting_perk" name="eat_your_veggies"
description="Start every run with a random perk from the Holy Mountain pool." description="Start every run with the Eat Your Vegetables perk."
tags="gameplay,perks,loadouts" tags="gameplay,perks,loadouts"
dont_upload_folders="" dont_upload_folders=""
dont_upload_files="" dont_upload_files=""

View file

@ -1 +0,0 @@
2572658701

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 KiB

After

Width:  |  Height:  |  Size: 89 KiB