diff --git a/init.lua b/init.lua index 29bc891..5bd505f 100755 --- a/init.lua +++ b/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 + GamePrint("Starting with the Eat Your Vegetables perk") - local x_center = 789 - local y_bottom = -96 + -- Spawn the actual perk + local perk_entity = perk_spawn( 771, -96, "FOOD_CLOCK" ) - 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" ) + -- Give the perk to the player + perk_pickup( perk_entity, player_entity, EntityGetName( perk_entity ), false, false ) end diff --git a/mod.xml b/mod.xml index 3522ba9..396f075 100755 --- a/mod.xml +++ b/mod.xml @@ -1,6 +1,6 @@ diff --git a/mod_id.txt b/mod_id.txt index 6bc9205..041d9e2 100644 --- a/mod_id.txt +++ b/mod_id.txt @@ -1 +1 @@ -starting_perk \ No newline at end of file +veggies \ No newline at end of file diff --git a/workshop.xml b/workshop.xml index 482fd4d..479dbbb 100644 --- a/workshop.xml +++ b/workshop.xml @@ -1,6 +1,6 @@