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:
parent
a287e0b025
commit
2dea221deb
6 changed files with 11 additions and 64 deletions
68
init.lua
68
init.lua
|
@ -6,70 +6,18 @@ dofile("data/scripts/lib/mod_settings.lua")
|
|||
function OnPlayerSpawned( player_entity )
|
||||
|
||||
-- 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
|
||||
return
|
||||
end
|
||||
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
|
||||
if only_one then
|
||||
GamePrint("Starting with a choice between " .. to_string(perks_amount) .. " perks")
|
||||
else
|
||||
GamePrint("Starting with " .. to_string(perks_amount) .. " free perks")
|
||||
end
|
||||
|
||||
local x_center = 789
|
||||
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" )
|
||||
GamePrint("Starting with the Eat Your Vegetables perk")
|
||||
|
||||
-- Spawn the actual perk
|
||||
local perk_entity = perk_spawn( 771, -96, "FOOD_CLOCK" )
|
||||
|
||||
-- Give the perk to the player
|
||||
perk_pickup( perk_entity, player_entity, EntityGetName( perk_entity ), false, false )
|
||||
end
|
||||
|
|
4
mod.xml
4
mod.xml
|
@ -1,6 +1,6 @@
|
|||
<Mod
|
||||
name="Starting perk"
|
||||
description="Start every run with a perk from the Holy Mountain pool."
|
||||
name="Eat your vegetables"
|
||||
description="Start every run with the Eat Your Vegetables perk."
|
||||
request_no_api_restrictions="0"
|
||||
>
|
||||
</Mod>
|
||||
|
|
|
@ -1 +1 @@
|
|||
starting_perk
|
||||
veggies
|
|
@ -1,6 +1,6 @@
|
|||
<Mod
|
||||
name="starting_perk"
|
||||
description="Start every run with a random perk from the Holy Mountain pool."
|
||||
name="eat_your_veggies"
|
||||
description="Start every run with the Eat Your Vegetables perk."
|
||||
tags="gameplay,perks,loadouts"
|
||||
dont_upload_folders=""
|
||||
dont_upload_files=""
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
2572658701
|
Binary file not shown.
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 89 KiB |
Loading…
Reference in a new issue