diff --git a/engine/assets/langs/en.txt b/engine/assets/langs/en.txt index ed0ec41..e604e94 100644 --- a/engine/assets/langs/en.txt +++ b/engine/assets/langs/en.txt @@ -40,6 +40,7 @@ BATTLE_FLEE_REWARD= * Ran away with {} EXP\n and {} GOLD. BATTLE_WIN_REWARD=* YOU WON!\n* You earned {} EXP and {} gold. BATTLE_WIN_LEVEL_UP=* Your LOVE increased. BATTLE_ITEM_HEAL=* You recovered {} HP! +BATTLE_ITEM_HURT=* You lost {} HP! BATTLE_ITEM_HEAL_MAX=* Your HP was maxed out. BATTLE_ITEM_FOOD_USE=* You eat the {}. BATTLE_ITEM_DRINK_USE=* You drink the {}. @@ -103,6 +104,229 @@ ITEM_STICK_SHORTNAME=Stick ITEM_STICK_DESCRIPTION=* "Stick" - Weapon AT 0\n* Its bark is worse than\n its bite. ITEM_STICK_USE=* You threw the stick away.[wait:5]\n* Then picked it back up. +ITEM_MONSTER_CANDY_NAME=Monster Candy +ITEM_MONSTER_CANDY_SHORTNAME=MnstrCndy +ITEM_MONSTER_CANDY_DESCRIPTION=* "Monster Candy" - Heals 10 HP\n* Has a distinct,[wait:5] \n non-licorice flavor. +ITEM_MONSTER_CANDY_DESCRIPTION_SHOP=Heals 10 HP\n(Licorice-\nfree\nguaranteed.) +ITEM_MONSTER_CANDY_USE=\n* Very un-licorice-like. +ITEM_MONSTER_CANDY_USE_2=\n* ... tastes like licorice. + +ITEM_SPIDER_DONUT_NAME=Spider Donut +ITEM_SPIDER_DONUT_SHORTNAME=SpidrDont +ITEM_SPIDER_DONUT_SHORTNAME2=SpdrDonut +ITEM_SPIDER_DONUT_DESCRIPTION=* "Spider Donut" - Heals 12 HP\n* A donut made with Spider\n Cider in the batter. +ITEM_SPIDER_DONUT_DESCRIPTION_SHOP=undefined +ITEM_SPIDER_DONUT_USE=* Don't worry,[wait:5] Spider didn't. + +ITEM_SPIDER_CIDER_NAME=Spider Cider +ITEM_SPIDER_CIDER_SHORTNAME=SpidrCidr +ITEM_SPIDER_CIDER_SHORTNAME2=SpdrCider +ITEM_SPIDER_CIDER_DESCRIPTION=* "Spider Cider" - Heals 24 HP\n* Made with whole spiders,[wait:5]\n not just the juice. +ITEM_SPIDER_CIDER_DESCRIPTION_SHOP=undefined + +ITEM_BUTTERSCOTCH_PIE_NAME=Butterscotch Pie +ITEM_BUTTERSCOTCH_PIE_SHORTNAME=ButtsPie +ITEM_BUTTERSCOTCH_PIE_SHORTNAME2=Pie +ITEM_BUTTERSCOTCH_PIE_DESCRIPTION=* "Butterscotch Pie" - All HP\n* Butterscotch-cinnamon\n pie,[wait:5] one slice. +ITEM_BUTTERSCOTCH_PIE_DESCRIPTION_SHOP=undefined + +ITEM_SNOWMAN_PIECE_NAME=Snowman Piece +ITEM_SNOWMAN_PIECE_SHORTNAME=SnowPiece +ITEM_SNOWMAN_PIECE_SHORTNAME2=SnowPiece +ITEM_SNOWMAN_PIECE_DESCRIPTION=* "Snowman Piece" - Heals 45 HP\n* Please take this to the\n ends of the earth. +ITEM_SNOWMAN_PIECE_DESCRIPTION_SHOP=undefined + +ITEM_NICE_CREAM_NAME=Nice Cream +ITEM_NICE_CREAM_SHORTNAME=NiceCream +ITEM_NICE_CREAM_SHORTNAME2=NiceCream +ITEM_NICE_CREAM_DESCRIPTION=* "Nice Cream" - Heals 15 HP\n* Instead of a joke,[wait:5] the\n wrapper says something nice. +ITEM_NICE_CREAM_DESCRIPTION_SHOP=undefined +ITEM_NICE_CREAM_USE=* You're just great! +ITEM_NICE_CREAM_USE_2=* You look nice today! +ITEM_NICE_CREAM_USE_3=* Are those claws natural? +ITEM_NICE_CREAM_USE_4=* You're super spiffy! +ITEM_NICE_CREAM_USE_5=* Have a wonderful day! +ITEM_NICE_CREAM_USE_6=* Is this as sweet as you? +ITEM_NICE_CREAM_USE_7=* (An illustration of a hug.) +ITEM_NICE_CREAM_USE_8=* Love yourself! I love you! + +ITEM_BISICLE_NAME=Bisicle +ITEM_BISICLE_SHORTNAME=Bisicle +ITEM_BISICLE_SHORTNAME2=Bisicle +ITEM_BISICLE_DESCRIPTION=* "Bisicle" - Heals 11 HP\n* It's a two-pronged popsicle,[wait:5]\n so you can eat it twice. +ITEM_BISICLE_DESCRIPTION_SHOP=Heals 11HP x 2\nEat it twice! +ITEM_BISICLE_USE=* You eat one half of\n the Bisicle. + +ITEM_UNISICLE_NAME=Unisicle +ITEM_UNISICLE_SHORTNAME=Unisicle +ITEM_UNISICLE_SHORTNAME2=Popsicle +ITEM_UNISICLE_DESCRIPTION=* "Unisicle" - Heals 11 HP\n* It's a SINGLE-pronged popsicle.[wait:5]\n* Wait,[wait:5] that's just normal... +ITEM_UNISICLE_DESCRIPTION_SHOP=undefined + +ITEM_CINNAMON_BUNNY_NAME=Cinnamon Bunny +ITEM_CINNAMON_BUNNY_SHORTNAME=CinnaBun +ITEM_CINNAMON_BUNNY_SHORTNAME2=C. Bun +ITEM_CINNAMON_BUNNY_DESCRIPTION=* "Cinnamon Bunny" - Heals 22 HP\n* A cinnamon roll in the shape\n of a bunny. +ITEM_CINNAMON_BUNNY_DESCRIPTION_SHOP=Heals 22HP\nIt's my own\nrecipe. + +ITEM_TEMMIE_FLAKES_NAME=Temmie Flakes +ITEM_TEMMIE_FLAKES_SHORTNAME=TemFlakes +ITEM_TEMMIE_FLAKES_SHORTNAME2=TemFlakes +ITEM_TEMMIE_FLAKES_DESCRIPTION=* "Temmie Flakes" - Heals 2 HP\n* It's just torn up pieces\n of colored construction paper. +ITEM_TEMMIE_FLAKES_DESCRIPTION_SHOP=Heals 2HP\nfood of\ntem + +ITEM_ABANDONED_QUICHE_NAME=Abandoned Quiche +ITEM_ABANDONED_QUICHE_SHORTNAME=Ab Quiche +ITEM_ABANDONED_QUICHE_SHORTNAME2=Quiche +ITEM_ABANDONED_QUICHE_DESCRIPTION=* "Abandoned Quiche" Heals 34 HP\n* A psychologically damaged\n spinach egg pie. +ITEM_ABANDONED_QUICHE_DESCRIPTION_SHOP=undefined +ITEM_ABANDONED_QUICHE_DROP=* You leave the Quiche on the\n ground and tell it you'll\n be right back. +ITEM_ABANDONED_QUICHE_USE=* You eat the quiche. + +ITEM_DOG_RESIDUE_NAME=Dog Residue +ITEM_DOG_RESIDUE_SHORTNAME=DogResidu +ITEM_DOG_RESIDUE_SHORTNAME2=D.Residue +ITEM_DOG_RESIDUE_DESCRIPTION=* "Dog Residue" - Dog Item\n* Shiny trail left\n behind by a dog. +ITEM_DOG_RESIDUE_DESCRIPTION_2=* "Dog Residue" - Dog Item\n* Dog-shaped husk shed\n from a dog's carapace. +ITEM_DOG_RESIDUE_DESCRIPTION_3=* "Dog Residue" - Dog Item\n* Dirty dishes left\n unwashed by a dog. +ITEM_DOG_RESIDUE_DESCRIPTION_4=* "Dog Residue" - Dog Item\n* Glowing crystals secreted\n by a dog. +ITEM_DOG_RESIDUE_DESCRIPTION_5=* "Dog Residue" - Dog Item\n* Jigsaw puzzle left\n unfinished by a dog. +ITEM_DOG_RESIDUE_DESCRIPTION_6=* "Dog Residue" - Dog Item\n* Web spun by a dog\n to ensnare prey. +ITEM_DOG_RESIDUE_DESCRIPTION_SHOP=undefined +ITEM_DOG_RESIDUE_USE=* You used the Dog Residue. +ITEM_DOG_RESIDUE_USE_SUCCESS=* The rest of your inventory\n filled up with Dog Residue. +ITEM_DOG_RESIDUE_USE_FAIL=* ... +ITEM_DOG_RESIDUE_USE_FAIL_2=* You finished using it. +ITEM_DOG_RESIDUE_USE_FAIL_3=* An uneasy atmosphere fills\n the room. + +ITEM_DOG_SALAD_NAME=Dog Salad +ITEM_DOG_SALAD_SHORTNAME=Dog Salad +ITEM_DOG_SALAD_SHORTNAME2=Dog Salad +ITEM_DOG_SALAD_DESCRIPTION=* "Dog Salad" - Heals ?? HP\n* Recovers HP.\n* (Hit Poodles.) +ITEM_DOG_SALAD_DESCRIPTION_SHOP=undefined +ITEM_DOG_SALAD_USE=* Oh.[wait:5] Tastes yappy... +ITEM_DOG_SALAD_USE_2=* Oh.[wait:5] Fried tennis ball... +ITEM_DOG_SALAD_USE_3=* Oh.[wait:5] There are bones... +ITEM_DOG_SALAD_USE_4=* It's literally garbage??? + +ITEM_ASTRONAUT_FOOD_NAME=Astronaut Food +ITEM_ASTRONAUT_FOOD_SHORTNAME=AstroFood +ITEM_ASTRONAUT_FOOD_SHORTNAME2=Astr.Food +ITEM_ASTRONAUT_FOOD_DESCRIPTION=* "Astronaut Food" Heals 21 HP\n* For feeding a pet\n astronaut. +ITEM_ASTRONAUT_FOOD_DESCRIPTION_SHOP=undefined + +ITEM_INSTANT_NOODLES_NAME=Instant Noodles +ITEM_INSTANT_NOODLES_SHORTNAME=InstaNood +ITEM_INSTANT_NOODLES_SHORTNAME2=I.Noodles +ITEM_INSTANT_NOODLES_DESCRIPTION=* "Instant Noodles" Heals HP\n* Comes with everything you\n need for a quick meal! +ITEM_INSTANT_NOODLES_DESCRIPTION_SHOP=undefined +ITEM_INSTANT_NOODLES_USE=* You remove the Instant\n Noodles from their\n packaging. +ITEM_INSTANT_NOODLES_USE_1=[noskip]* You put some water in\n the pot and place it on\n the heat. +ITEM_INSTANT_NOODLES_USE_2=[noskip]* You wait for the water\n to boil... +ITEM_INSTANT_NOODLES_USE_3=[noskip]* ...[wait:20]\n* ...[wait:20]\n* ... +ITEM_INSTANT_NOODLES_USE_4=[noskip]* It's[wait:10] boiling. +ITEM_INSTANT_NOODLES_USE_5=[noskip]* You place the noodles[wait:5]\n into the pot. +ITEM_INSTANT_NOODLES_USE_6=[noskip]* 4[wait:15] minutes left[wait:15] until\n the noodles[wait:10] are finished. +ITEM_INSTANT_NOODLES_USE_7=[noskip]* 3[wait:15] minutes left[wait:15] until\n the noodles[wait:10] are finished. +ITEM_INSTANT_NOODLES_USE_8=[noskip]* 2[wait:15] minutes left[wait:15] until\n the noodles[wait:10] are finished. +ITEM_INSTANT_NOODLES_USE_9=[noskip]* 1[wait:15] minute left[wait:15] until\n the noodles[wait:10] are finished. +ITEM_INSTANT_NOODLES_USE_10=[noskip]* The noodles[wait:15] are finished. +ITEM_INSTANT_NOODLES_USE_11=[noskip]* ... they don't taste very\n good. +ITEM_INSTANT_NOODLES_USE_12=[noskip]* You add the flavor packet. +ITEM_INSTANT_NOODLES_USE_13=[noskip]* That's better. +ITEM_INSTANT_NOODLES_USE_14=[noskip]* Not great,[wait:5] but better. + +ITEM_CRAB_APPLE_NAME=Crab Apple +ITEM_CRAB_APPLE_SHORTNAME=CrabApple +ITEM_CRAB_APPLE_SHORTNAME2=CrabApple +ITEM_CRAB_APPLE_DESCRIPTION=* "Crab Apple" Heals 18 HP\n* An aquatic fruit that\n resembles a crustacean. +ITEM_CRAB_APPLE_DESCRIPTION_SHOP=Heals 18HP\n(Looks\nlike a\ncrab.) + +ITEM_HOT_DOG_NAME=Hot Dog...? +ITEM_HOT_DOG_SHORTNAME=Hot Dog +ITEM_HOT_DOG_SHORTNAME2=Hot Dog +ITEM_HOT_DOG_DESCRIPTION=* "Hot Dog...?" Heals 20 HP\n* The "meat" is made of something\n called a "water sausage." +ITEM_HOT_DOG_DESCRIPTION_SHOP=undefined + +ITEM_HOT_CAT_NAME=Hot Cat +ITEM_HOT_CAT_SHORTNAME=Hot Cat +ITEM_HOT_CAT_SHORTNAME2=Hot Cat +ITEM_HOT_CAT_DESCRIPTION=* "Hot Cat" Heals 21 HP\n* Like a hot dog,[wait:5] but with\n little cat ears on the end. +ITEM_HOT_CAT_DESCRIPTION_SHOP=undefined + +ITEM_GLAMBURGER_NAME=Glamburger +ITEM_GLAMBURGER_SHORTNAME=GlamBurg +ITEM_GLAMBURGER_SHORTNAME2=G.Burger +ITEM_GLAMBURGER_DESCRIPTION=* "Glamburger" Heals 27 HP\n* A hamburger made of edible\n glitter and sequins. +ITEM_GLAMBURGER_DESCRIPTION_SHOP=Heals 27HP\nVery popular\nfood. + +ITEM_STARFAIT_NAME=Starfait +ITEM_STARFAIT_SHORTNAME=Starfait +ITEM_STARFAIT_SHORTNAME2=Starfait +ITEM_STARFAIT_DESCRIPTION=* "Starfait" Heals 14 HP\n* A sweet treat made of\n sparkling stars. +ITEM_STARFAIT_DESCRIPTION_SHOP=Heals 14HP\nVery popular\nfood. + +ITEM_SEATEA_NAME=Sea Tea +ITEM_SEATEA_SHORTNAME=Sea Tea +ITEM_SEATEA_SHORTNAME2=Sea Tea +ITEM_SEATEA_DESCRIPTION=* "Sea Tea" Heals 10 HP\n* Made from glowing marshwater.\n* Increases SPEED for one battle. +ITEM_SEATEA_DESCRIPTION_SHOP=Heals 10HP\nSPEED\nup in\nbattle. +ITEM_SEATEA_USE=* Your SPEED boosts! + +ITEM_LEGENDARY_HERO_NAME=Legendary Hero +ITEM_LEGENDARY_HERO_SHORTNAME=Leg.Hero +ITEM_LEGENDARY_HERO_SHORTNAME2=L. Hero +ITEM_LEGENDARY_HERO_DESCRIPTION=* "Legendary Hero" Heals 40 HP\n* Sandwich shaped like a sword.\n* Increases ATTACK when eaten. +ITEM_LEGENDARY_HERO_DESCRIPTION_SHOP=Heals 40HP\nHero Sandwich.\nATTACK UP\nin battle. +ITEM_LEGENDARY_HERO_USE=* ATTACK increased by 4! + +ITEM_FACE_STEAK_NAME=Steak in the Shape of Mettaton's Face +ITEM_FACE_STEAK_SHORTNAME=FaceSteak +ITEM_FACE_STEAK_SHORTNAME2=Steak +ITEM_FACE_STEAK_DESCRIPTION=* "Face Steak" Heals 60 HP\n* Huge steak in the shape\n of Mettaton's face. +ITEM_FACE_STEAK_DESCRIPTION_SHOP=Heals 60HP\nDon't ask.\nPlease. +ITEM_FACE_STEAK_USE=* You eat the Face Steak. + +ITEM_POPATO_CHISPS_NAME=Popato Chisps +ITEM_POPATO_CHISPS_SHORTNAME=PT Chisps +ITEM_POPATO_CHISPS_SHORTNAME2=Chips +ITEM_POPATO_CHISPS_DESCRIPTION=* "Popato Chisps" Heals 13 HP\n* Regular old popato chisps. +ITEM_POPATO_CHISPS_DESCRIPTION_SHOP=undefined + +ITEM_BAD_MEMORY_NAME=Bad Memory +ITEM_BAD_MEMORY_SHORTNAME=BadMemory +ITEM_BAD_MEMORY_SHORTNAME2=BadMemory +ITEM_BAD_MEMORY_DESCRIPTION=* "Bad Memory" Hurts 1 HP\n* ????? +ITEM_BAD_MEMORY_DESCRIPTION_SHOP=undefined +ITEM_BAD_MEMORY_USE=* You consume the Bad Memory.[wait:5] + +ITEM_JUNK_FOOD_NAME=Junk Food +ITEM_JUNK_FOOD_SHORTNAME=Junk Food +ITEM_JUNK_FOOD_SHORTNAME2=Junk Food +ITEM_JUNK_FOOD_DESCRIPTION=* "Junk Food" Heals 17 HP\n* Food that was probably\n once thrown away. +ITEM_JUNK_FOOD_DESCRIPTION_SHOP=Heals 17HP\nHas a big\nbite out of\nit. + +ITEM_HUSH_PUPPY_NAME=Hush Puppy +ITEM_HUSH_PUPPY_SHORTNAME=HushPupe +ITEM_HUSH_PUPPY_SHORTNAME2=HushPuppy +ITEM_HUSH_PUPPY_DESCRIPTION=* "Hush Puppy" Heals 65 HP\n* This wonderful spell will stop\n a dog from casting magic. +ITEM_HUSH_PUPPY_DESCRIPTION_SHOP=undefined +ITEM_HUSH_PUPPY_USE=\n* Dog-magic is neutralized. + +ITEM_SNAIL_PIE_NAME=Snail Pie +ITEM_SNAIL_PIE_SHORTNAME=Snail Pie +ITEM_SNAIL_PIE_SHORTNAME2=Snail Pie +ITEM_SNAIL_PIE_DESCRIPTION=* "Snail Pie" - Heals Some HP\n* An acquired taste. +ITEM_SNAIL_PIE_DESCRIPTION_SHOP=undefined +ITEM_SNAIL_PIE_HEAL=* Your HP was maxed out. + +ITEM_LAST_DREAM_NAME=Last Dream +ITEM_LAST_DREAM_SHORTNAME="Dream" +ITEM_LAST_DREAM_SHORTNAME2="Dream" +ITEM_LAST_DREAM_DESCRIPTION=* "Dream" Heals 12 HP\n* The goal of "Determination." +ITEM_LAST_DREAM_DESCRIPTION_SHOP=undefined +ITEM_LAST_DREAM_USE=* Through DETERMINATION,[wait:5] the\n dream became true. + # World shop WORLD_SHOP_ACTION_BUY=Buy WORLD_SHOP_ACTION_SELL=Sell diff --git a/engine/assets/sounds/catsalad.wav b/engine/assets/sounds/catsalad.wav new file mode 100644 index 0000000..33f0666 Binary files /dev/null and b/engine/assets/sounds/catsalad.wav differ diff --git a/engine/assets/sounds/dogresidue.wav b/engine/assets/sounds/dogresidue.wav new file mode 100644 index 0000000..055029b Binary files /dev/null and b/engine/assets/sounds/dogresidue.wav differ diff --git a/engine/assets/sounds/dogsalad.wav b/engine/assets/sounds/dogsalad.wav new file mode 100644 index 0000000..8580176 Binary files /dev/null and b/engine/assets/sounds/dogsalad.wav differ diff --git a/engine/item/consumable.lua b/engine/item/consumable.lua index 534b08d..5085494 100644 --- a/engine/item/consumable.lua +++ b/engine/item/consumable.lua @@ -28,16 +28,24 @@ function ItemConsumable:setType(type) self.type = type end ---- Uses the consumable item -function ItemConsumable:use() - if type(self.onBeforeUse) == "function" then - self:onBeforeUse() - end - +--- Gets the item's heal text +--- @return Dummy.Text.Text +function ItemConsumable:getHealText() local heal_text = Lang.translate("BATTLE_ITEM_HEAL", self:getHeal()) if self:getHeal() + Player.getHP() >= Player.getMaxHP() then heal_text = Lang.translate("BATTLE_ITEM_HEAL_MAX") end + -- Hurt the player for some reason + if self:getHeal() < 0 then + heal_text = Lang.translate("BATTLE_ITEM_HURT", math.abs(self:getHeal())) + end + return heal_text +end + +--- (Override) Gets the item's final dialogue text +--- @return Dummy.Text.Text[] +function ItemConsumable:getDialogueTexts() + local heal_text = self:getHealText() local dialogue_text = heal_text local use_texts = self:getUseTexts() @@ -46,6 +54,16 @@ function ItemConsumable:use() end local texts = { dialogue_text, table.unpack(use_texts, 2) } + return texts +end + +--- Uses the consumable item +function ItemConsumable:use() + if type(self.onBeforeUse) == "function" then + self:onBeforeUse() + end + + local texts = self:getDialogueTexts() if World.isInBattle() then Battle.playDialogueText(table.unpack(texts)) else diff --git a/engine/item/equipment.lua b/engine/item/equipment.lua index 4480b61..3f51511 100644 --- a/engine/item/equipment.lua +++ b/engine/item/equipment.lua @@ -28,16 +28,22 @@ function ItemEquipment:setType(type) self.type = type end +--- (Override) Gets the item's final dialogue text when used +--- @return Dummy.Text.Text[] +function ItemEquipment:getDialogueTexts() + local texts = self:getUseTexts() + if #texts <= 0 then + texts = { { "BATTLE_ITEM_EQUIPMENT_USE", Lang.translate(self:getName()) } } + end + return texts +end --- Uses the equipment item function ItemEquipment:use() if type(self.onBeforeUse) == "function" then self:onBeforeUse() end - local texts = self:getUseTexts() - if #texts <= 0 then - texts = { { "BATTLE_ITEM_EQUIPMENT_USE", Lang.translate(self:getName()) } } - end + local texts = self:getDialogueTexts() if World.isInBattle() then Battle.playDialogueText(table.unpack(texts)) else diff --git a/engine/item/item.lua b/engine/item/item.lua index 789888b..7a0d050 100644 --- a/engine/item/item.lua +++ b/engine/item/item.lua @@ -91,6 +91,12 @@ function Item:setDropText(text, ...) self.drop_texts = { text, ... } end +--- (Override) Gets the item's final dialogue text when used +--- @return Dummy.Text.Text[] +function Item:getDialogueTexts() + return self:getUseTexts() +end + --- Gets the item's buy price --- @return integer function Item:getBuyPrice() @@ -121,14 +127,15 @@ function Item:use() if type(self.onBeforeUse) == "function" then can_use = self:onBeforeUse() end + if not can_use then return end - local use_texts = self:getUseTexts() - if #use_texts > 0 then + local dialogue_texts = self:getDialogueTexts() + if #dialogue_texts > 0 then if World.isInBattle() then - Battle.playDialogueText(table.unpack(use_texts)) + Battle.playDialogueText(table.unpack(dialogue_texts)) else - World.playDialogue(use_texts) + World.playDialogue(dialogue_texts) end end diff --git a/engine/items/abandoned_quiche.lua b/engine/items/abandoned_quiche.lua new file mode 100644 index 0000000..9816231 --- /dev/null +++ b/engine/items/abandoned_quiche.lua @@ -0,0 +1,30 @@ +--- @class Item.AbandonedQuiche : Dummy.Item.Consumable +local AbandonedQuicheItem = Class(ItemConsumable, "Item.AbandonedQuiche") + +--- Creates an abandoned quiche +--- @return Item.AbandonedQuiche +function AbandonedQuicheItem:new() + self = Class:new(AbandonedQuicheItem, { + "abandoned_quiche", -- item identifier + "ITEM_ABANDONED_QUICHE_NAME", -- item name + "ITEM_ABANDONED_QUICHE_SHORTNAME", -- item short name + "ITEM_ABANDONED_QUICHE_DESCRIPTION", -- item description + 34, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(76) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_ABANDONED_QUICHE_DESCRIPTION_SHOP") + -- the text that will appear when the item is dropped on the ground + self:setDropText("ITEM_ABANDONED_QUICHE_DROP") + -- the text that will appear when the item is used + self:setUseText("ITEM_ABANDONED_QUICHE_USE") + + return self +end + +return AbandonedQuicheItem diff --git a/engine/items/astronaut_food.lua b/engine/items/astronaut_food.lua new file mode 100644 index 0000000..24731c2 --- /dev/null +++ b/engine/items/astronaut_food.lua @@ -0,0 +1,26 @@ +--- @class Item.AstronautFood : Dummy.Item.Consumable +local AstronautFoodItem = Class(ItemConsumable, "Item.AstronautFood") + +--- Creates a astronaut food +--- @return Item.AstronautFood +function AstronautFoodItem:new() + self = Class:new(AstronautFoodItem, { + "astronaut_food", -- item identifier + "ITEM_ASTRONAUT_FOOD_NAME", -- item name + "ITEM_ASTRONAUT_FOOD_SHORTNAME", -- item short name + "ITEM_ASTRONAUT_FOOD_DESCRIPTION", -- item description + 21, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(25) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_ASTRONAUT_FOOD_DESCRIPTION_SHOP") + + return self +end + +return AstronautFoodItem diff --git a/engine/items/bad_memory.lua b/engine/items/bad_memory.lua new file mode 100644 index 0000000..5af70dd --- /dev/null +++ b/engine/items/bad_memory.lua @@ -0,0 +1,37 @@ +--- @class Item.BadMemory : Dummy.Item.Consumable +local BadMemoryItem = Class(ItemConsumable, "Item.BadMemory") + +--- Creates a ??? +--- @return Item.BadMemory +function BadMemoryItem:new() + self = Class:new(BadMemoryItem, { + "bad_memory", -- item identifier + "ITEM_BAD_MEMORY_NAME", -- item name + "ITEM_BAD_MEMORY_SHORTNAME", -- item short name + "ITEM_BAD_MEMORY_DESCRIPTION", -- item description + -1, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(300) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_BAD_MEMORY_DESCRIPTION_SHOP") + -- the text that will appear when the item is used + self:setUseText("ITEM_BAD_MEMORY_USE") + + return self +end + +function BadMemoryItem:getHeal() + -- Heal the player fully if they're below 3 HP, hurt them otherwise. + if Player.getHP() <=2 then + return Player.getMaxHP() + else + return -1 + end +end + +return BadMemoryItem diff --git a/engine/items/bisicle.lua b/engine/items/bisicle.lua new file mode 100644 index 0000000..e0a7ab4 --- /dev/null +++ b/engine/items/bisicle.lua @@ -0,0 +1,36 @@ +--- @class Item.Bisicle : Dummy.Item.Consumable +local BisicleItem = Class(ItemConsumable, "Item.Bisicle") + +--- Creates a bisicle +--- @return Item.Bisicle +function BisicleItem:new() + self = Class:new(BisicleItem, { + "bisicle", -- item identifier + "ITEM_BISICLE_NAME", -- item name + "ITEM_BISICLE_SHORTNAME", -- item short name + "ITEM_BISICLE_DESCRIPTION", -- item description + 11, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(15) + -- the price at which the item will be sold in the shop + self:setSellPrice(5) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_BISICLE_DESCRIPTION_SHOP") + -- the main text that will appear when the item is used. + self.use_texts = { + "ITEM_BISICLE_USE" + } + + return self +end + +function BisicleItem:onUse() + -- Add a unisicle to the player's inventory when the bisicle is used. + local unisicle = require("items.unisicle"):new() + Player.addItem(unisicle) +end + +return BisicleItem diff --git a/engine/mods/world_example/scripts/items/blanket.lua b/engine/items/blanket.lua similarity index 79% rename from engine/mods/world_example/scripts/items/blanket.lua rename to engine/items/blanket.lua index 6e4003b..bdc7db3 100644 --- a/engine/mods/world_example/scripts/items/blanket.lua +++ b/engine/items/blanket.lua @@ -1,8 +1,8 @@ ---- @class WorldExample.Item.Blanket : Dummy.Item.Consumable -local BlanketItem = Class(ItemEquipment, "WorldExample.Item.Blanket") +--- @class Item.Blanket : Dummy.Item.Consumable +local BlanketItem = Class(ItemEquipment, "Item.Blanket") ---- Creates a monster candy ---- @return WorldExample.Item.Blanket +--- Creates a blanket +--- @return Item.Blanket function BlanketItem:new() self = Class:new(BlanketItem, { "blanket", -- item identifier diff --git a/engine/items/butterscotch_pie.lua b/engine/items/butterscotch_pie.lua new file mode 100644 index 0000000..f5264bb --- /dev/null +++ b/engine/items/butterscotch_pie.lua @@ -0,0 +1,26 @@ +--- @class Item.ButterScotchPie : Dummy.Item.Consumable +local ButterScotchPieItem = Class(ItemConsumable, "Item.ButterScotchPie") + +--- Creates a butterscotch pie +--- @return Item.ButterScotchPie +function ButterScotchPieItem:new() + self = Class:new(ButterScotchPieItem, { + "butterscotch_pie", -- item identifier + "ITEM_BUTTERSCOTCH_PIE_NAME", -- item name + "ITEM_BUTTERSCOTCH_PIE_SHORTNAME", -- item short name + "ITEM_BUTTERSCOTCH_PIE_DESCRIPTION", -- item description + Player.getMaxHP(), + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(180) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_BUTTERSCOTCH_PIE_DESCRIPTION_SHOP") + + return self +end + +return ButterScotchPieItem diff --git a/engine/items/cinnamon_bunny.lua b/engine/items/cinnamon_bunny.lua new file mode 100644 index 0000000..33aa7aa --- /dev/null +++ b/engine/items/cinnamon_bunny.lua @@ -0,0 +1,26 @@ +--- @class Item.CinnamonBunny : Dummy.Item.Consumable +local CinnamonBunnyItem = Class(ItemConsumable, "Item.CinnamonBunny") + +--- Creates a cinnamon bunny +--- @return Item.CinnamonBunny +function CinnamonBunnyItem:new() + self = Class:new(CinnamonBunnyItem, { + "cinnamon_bunny", -- item identifier + "ITEM_CINNAMON_BUNNY_NAME", -- item name + "ITEM_CINNAMON_BUNNY_SHORTNAME", -- item short name + "ITEM_CINNAMON_BUNNY_DESCRIPTION", -- item description + 22, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(25) + -- the price at which the item will be sold in the shop + self:setSellPrice(8) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_CINNAMON_BUNNY_DESCRIPTION_SHOP") + + return self +end + +return CinnamonBunnyItem diff --git a/engine/items/crab_apple.lua b/engine/items/crab_apple.lua new file mode 100644 index 0000000..00a59ed --- /dev/null +++ b/engine/items/crab_apple.lua @@ -0,0 +1,26 @@ +--- @class Item.CrabApple : Dummy.Item.Consumable +local CrabAppleItem = Class(ItemConsumable, "Item.CrabApple") + +--- Creates a crab apple +--- @return Item.CrabApple +function CrabAppleItem:new() + self = Class:new(CrabAppleItem, { + "crab_apple", -- item identifier + "ITEM_CRAB_APPLE_NAME", -- item name + "ITEM_CRAB_APPLE_SHORTNAME", -- item short name + "ITEM_CRAB_APPLE_DESCRIPTION", -- item description + 18, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(25) + -- the price at which the item will be sold in the shop + self:setSellPrice(5) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_CRAB_APPLE_DESCRIPTION_SHOP") + + return self +end + +return CrabAppleItem diff --git a/engine/items/dog_residue.lua b/engine/items/dog_residue.lua new file mode 100644 index 0000000..41c0e17 --- /dev/null +++ b/engine/items/dog_residue.lua @@ -0,0 +1,68 @@ +--- @class Item.DogResidue : Dummy.Item.Consumable +local DogResidueItem = Class(Item, "Item.DogResidue") + +--- Creates a dog residue +--- @return Item.DogResidue +function DogResidueItem:new() + self = Class:new(DogResidueItem, { + "dog_residue", -- item identifier + "ITEM_DOG_RESIDUE_NAME", -- item name + "ITEM_DOG_RESIDUE_SHORTNAME", -- item short name + "ITEM_DOG_RESIDUE_DESCRIPTION" -- item description + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(love.math.random(4)) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_DOG_RESIDUE_DESCRIPTION_SHOP") + -- the text that will appear when the item is used + self:setUseText("ITEM_DOG_RESIDUE_USE") + -- descriptions for each dog residue type + self.descriptions = { + "ITEM_DOG_RESIDUE_DESCRIPTION", + "ITEM_DOG_RESIDUE_DESCRIPTION_2", + "ITEM_DOG_RESIDUE_DESCRIPTION_3", + "ITEM_DOG_RESIDUE_DESCRIPTION_4", + "ITEM_DOG_RESIDUE_DESCRIPTION_5", + "ITEM_DOG_RESIDUE_DESCRIPTION_6" + } + -- Random description when a new version of the object is added (copies will retain the same description) + local rand = love.math.random(6) + self:setDescription(self.descriptions[rand]) + + return self +end + +function DogResidueItem:getDialogueTexts() + -- define dialogue_text as an empty table because it keeps adding to it if we don't. For some reason. + local dialogue_text = {} + table.insert(dialogue_text, self:getUseTexts()) + -- Show mini-cutscene depending on if the item can create clones + if #Player.getItems() == Player.getMaxItems() then + table.insert(dialogue_text, Lang.translate("ITEM_DOG_RESIDUE_USE_FAIL")) + table.insert(dialogue_text, Lang.translate("ITEM_DOG_RESIDUE_USE_FAIL_2")) + table.insert(dialogue_text, Lang.translate("ITEM_DOG_RESIDUE_USE_FAIL_3")) + else + table.insert(dialogue_text, Lang.translate("ITEM_DOG_RESIDUE_USE_SUCCESS")) + end + return dialogue_text +end + +function DogResidueItem:onUse() + -- Clone the item to all empty slots in the player's inventory + Assets.playSound("dogresidue") + for i = 1, Player.getMaxItems() - #Player.getItems() do + local rand = love.math.random(8) + local dog_salad = require("items.dog_salad"):new() + local dog_residue = require("items.dog_residue"):new() + if rand == 1 then + Player.addItem(dog_salad) + else + Player.addItem(dog_residue) + end + end +end + +return DogResidueItem diff --git a/engine/items/dog_salad.lua b/engine/items/dog_salad.lua new file mode 100644 index 0000000..bad0d98 --- /dev/null +++ b/engine/items/dog_salad.lua @@ -0,0 +1,64 @@ +--- @class Item.DogSalad : Dummy.Item.Consumable +local DogSaladItem = Class(ItemConsumable, "Item.DogSalad") + +--- Creates a dog salad +--- @return Item.DogSalad +function DogSaladItem:new() + self = Class:new(DogSaladItem, { + "dog_salad", -- item identifier + "ITEM_DOG_SALAD_NAME", -- item name + "ITEM_DOG_SALAD_SHORTNAME", -- item short name + "ITEM_DOG_SALAD_DESCRIPTION", -- item description + 15, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(15) + -- the price at which the item will be sold in the shop + self:setSellPrice(2) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_DOG_SALAD_DESCRIPTION_SHOP") + -- Random comments on use + self.use_comments = { + "ITEM_DOG_SALAD_USE", + "ITEM_DOG_SALAD_USE_2", + "ITEM_DOG_SALAD_USE_3", + "ITEM_DOG_SALAD_USE_4" + } + -- Random comments on use + self.rand = love.math.random(4) + + return self +end + +function DogSaladItem:getDialogueTexts() + -- Select a random comment when getting dialogue text + local dialogue_text = Lang.translate(self:getUseTexts()[1], Lang.translate(self:getName())) .. "\n" .. + Lang.translate(self.use_comments[self.rand]) .. "\n" .. self:getHealText() + + return {dialogue_text} +end + +function DogSaladItem:onUse() + Assets.playSound("dogresidue") +end + +function DogSaladItem:getHeal() + local val + if self.rand == 1 then + val = 2 + end + if self.rand == 2 then + val = 10 + end + if self.rand == 3 then + val = 30 + end + if self.rand == 4 then + val = Player.getMaxHP() + end + return val +end + +return DogSaladItem diff --git a/engine/items/face_steak.lua b/engine/items/face_steak.lua new file mode 100644 index 0000000..d269e65 --- /dev/null +++ b/engine/items/face_steak.lua @@ -0,0 +1,28 @@ +--- @class Item.FaceSteak : Dummy.Item.Consumable +local FaceSteakItem = Class(ItemConsumable, "Item.FaceSteak") + +--- Creates a face steak +--- @return Item.FaceSteak +function FaceSteakItem:new() + self = Class:new(FaceSteakItem, { + "face_steak", -- item identifier + "ITEM_FACE_STEAK_NAME", -- item name + "ITEM_FACE_STEAK_SHORTNAME", -- item short name + "ITEM_FACE_STEAK_DESCRIPTION", -- item description + 60, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(500) + -- the price at which the item will be sold in the shop + self:setSellPrice(14) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_FACE_STEAK_DESCRIPTION_SHOP") + -- the text that will appear when the item is used + self:setUseText("ITEM_FACE_STEAK_USE") + + return self +end + +return FaceSteakItem diff --git a/engine/items/glamburger.lua b/engine/items/glamburger.lua new file mode 100644 index 0000000..eda7c59 --- /dev/null +++ b/engine/items/glamburger.lua @@ -0,0 +1,26 @@ +--- @class Item.GlamBurger : Dummy.Item.Consumable +local GlamBurgerItem = Class(ItemConsumable, "Item.GlamBurger") + +--- Creates a glamburger +--- @return Item.GlamBurger +function GlamBurgerItem:new() + self = Class:new(GlamBurgerItem, { + "glamburger", -- item identifier + "ITEM_GLAMBURGER_NAME", -- item name + "ITEM_GLAMBURGER_SHORTNAME", -- item short name + "ITEM_GLAMBURGER_DESCRIPTION", -- item description + 27, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(120) + -- the price at which the item will be sold in the shop + self:setSellPrice(15) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_GLAMBURGER_DESCRIPTION_SHOP") + + return self +end + +return GlamBurgerItem diff --git a/engine/items/hot_cat.lua b/engine/items/hot_cat.lua new file mode 100644 index 0000000..43fe801 --- /dev/null +++ b/engine/items/hot_cat.lua @@ -0,0 +1,30 @@ +--- @class Item.HotCat : Dummy.Item.Consumable +local HotCatItem = Class(ItemConsumable, "Item.HotCat") + +--- Creates a hot cat +--- @return Item.HotCat +function HotCatItem:new() + self = Class:new(HotCatItem, { + "hot_cat", -- item identifier + "ITEM_HOT_CAT_NAME", -- item name + "ITEM_HOT_CAT_SHORTNAME", -- item short name + "ITEM_HOT_CAT_DESCRIPTION", -- item description + 21, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(30) + -- the price at which the item will be sold in the shop + self:setSellPrice(11) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_HOT_CAT_DESCRIPTION_SHOP") + + return self +end + +function HotCatItem:onUse() + Assets.playSound("catsalad") +end + +return HotCatItem diff --git a/engine/items/hot_dog.lua b/engine/items/hot_dog.lua new file mode 100644 index 0000000..aeb5492 --- /dev/null +++ b/engine/items/hot_dog.lua @@ -0,0 +1,30 @@ +--- @class Item.HotDog : Dummy.Item.Consumable +local HotDogItem = Class(ItemConsumable, "Item.HotDog") + +--- Creates a hot dog...? Maybe. +--- @return Item.HotDog +function HotDogItem:new() + self = Class:new(HotDogItem, { + "hot_dog", -- item identifier + "ITEM_HOT_DOG_NAME", -- item name + "ITEM_HOT_DOG_SHORTNAME", -- item short name + "ITEM_HOT_DOG_DESCRIPTION", -- item description + 20, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(30) + -- the price at which the item will be sold in the shop + self:setSellPrice(10) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_HOT_DOG_DESCRIPTION_SHOP") + + return self +end + +function HotDogItem:onUse() + Assets.playSound("dogsalad") +end + +return HotDogItem diff --git a/engine/items/hush_puppy.lua b/engine/items/hush_puppy.lua new file mode 100644 index 0000000..5387118 --- /dev/null +++ b/engine/items/hush_puppy.lua @@ -0,0 +1,31 @@ +--- @class Item.HushPuppy : Dummy.Item.Consumable +local HushPuppyItem = Class(ItemConsumable, "Item.HushPuppy") + +--- Creates hush puppy +--- @return Item.HushPuppy +function HushPuppyItem:new() + self = Class:new(HushPuppyItem, { + "butterscotch_pie", -- item identifier + "ITEM_HUSH_PUPPY_NAME", -- item name + "ITEM_HUSH_PUPPY_SHORTNAME", -- item short name + "ITEM_HUSH_PUPPY_DESCRIPTION", -- item description + 65, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(150) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_HUSH_PUPPY_DESCRIPTION_SHOP") + + return self +end + +function HushPuppyItem:getDialogueTexts() + return {Lang.translate(self:getUseTexts()[1], Lang.translate(self:getName())) .. + Lang.translate("ITEM_HUSH_PUPPY_USE") .. "\n" .. self:getHealText()} +end + +return HushPuppyItem diff --git a/engine/items/instant_noodles.lua b/engine/items/instant_noodles.lua new file mode 100644 index 0000000..42dfb75 --- /dev/null +++ b/engine/items/instant_noodles.lua @@ -0,0 +1,63 @@ +--- @class Item.InstantNoodles : Dummy.Item.Consumable +local InstantNoodlesItem = Class(ItemConsumable, "Item.InstantNoodles") + +--- Creates an instant noodles +--- @return Item.InstantNoodles +function InstantNoodlesItem:new() + self = Class:new(InstantNoodlesItem, { + "instant_noodles", -- item identifier + "ITEM_INSTANT_NOODLES_NAME", -- item name + "ITEM_INSTANT_NOODLES_SHORTNAME", -- item short name + "ITEM_INSTANT_NOODLES_DESCRIPTION", -- item description + 15, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(50) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_INSTANT_NOODLES_DESCRIPTION_SHOP") + --self:setUseText("ITEM_INSTANT_NOODLES_USE") + return self +end + +function InstantNoodlesItem:getHeal() + if World.isInBattle() then + --TODO: Serious Mode Check? + return 4 + else + return 15 + end +end + +function InstantNoodlesItem:getDialogueTexts() + -- TODO: Make this accurate. Stop music and delay use sounds. Override use function? + local usetext = { Lang.translate(self:getUseTexts()[1], Lang.translate(self:getName())) .. + "\n" .. self:getHealText() } + local dialogue_text = usetext + if World.isInBattle() then + dialogue_text = { + Lang.translate("ITEM_INSTANT_NOODLES_USE"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_2"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_3"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_4"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_5"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_6"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_7"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_8"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_9"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_10"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_11"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_12"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_13"), + Lang.translate("ITEM_INSTANT_NOODLES_USE_14"), + } + table.insert(dialogue_text, usetext) + end + return dialogue_text +end + + +return InstantNoodlesItem diff --git a/engine/items/junk_food.lua b/engine/items/junk_food.lua new file mode 100644 index 0000000..7600a48 --- /dev/null +++ b/engine/items/junk_food.lua @@ -0,0 +1,26 @@ +--- @class Item.JunkFood : Dummy.Item.Consumable +local JunkFoodItem = Class(ItemConsumable, "Item.JunkFood") + +--- Creates junk food +--- @return Item.JunkFood +function JunkFoodItem:new() + self = Class:new(JunkFoodItem, { + "butterscotch_pie", -- item identifier + "ITEM_JUNK_FOOD_NAME", -- item name + "ITEM_JUNK_FOOD_SHORTNAME", -- item short name + "ITEM_JUNK_FOOD_DESCRIPTION", -- item description + 17, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(25) + -- the price at which the item will be sold in the shop + self:setSellPrice(1) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_JUNK_FOOD_DESCRIPTION_SHOP") + + return self +end + +return JunkFoodItem diff --git a/engine/items/last_dream.lua b/engine/items/last_dream.lua new file mode 100644 index 0000000..5e3d645 --- /dev/null +++ b/engine/items/last_dream.lua @@ -0,0 +1,27 @@ +--- @class Item.LastDream : Dummy.Item.Consumable +local LastDreamItem = Class(ItemConsumable, "Item.LastDream") + +--- Creates a last dream +--- @return Item.LastDream +function LastDreamItem:new() + self = Class:new(LastDreamItem, { + "last_dream", -- item identifier + "ITEM_LAST_DREAM_NAME", -- item name + "ITEM_LAST_DREAM_SHORTNAME", -- item short name + "ITEM_LAST_DREAM_DESCRIPTION", -- item description + 17, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(250) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_LAST_DREAM_DESCRIPTION_SHOP") + self:setUseText("ITEM_LAST_DREAM_USE") + + return self +end + +return LastDreamItem diff --git a/engine/items/legendary_hero.lua b/engine/items/legendary_hero.lua new file mode 100644 index 0000000..df4b81a --- /dev/null +++ b/engine/items/legendary_hero.lua @@ -0,0 +1,42 @@ +--- @class Item.LegendaryHero : Dummy.Item.Consumable +local LegendaryHeroItem = Class(ItemConsumable, "Item.LegendaryHero") + +--- Creates a legendary hero +--- @return Item.LegendaryHero +function LegendaryHeroItem:new() + self = Class:new(LegendaryHeroItem, { + "legendary_hero", -- item identifier + "ITEM_LEGENDARY_HERO_NAME", -- item name + "ITEM_LEGENDARY_HERO_SHORTNAME", -- item short name + "ITEM_LEGENDARY_HERO_DESCRIPTION", -- item description + 40, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(300) + -- the price at which the item will be sold in the shop + self:setSellPrice(40) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_LEGENDARY_HERO_DESCRIPTION_SHOP") + + return self +end + +function LegendaryHeroItem:onUse() + if Player.getAT() < 150 then + Player.setAT(Player.getAT() + 4) + end +end + +function LegendaryHeroItem:getDialogueTexts() + local usecomment = "ITEM_LEGENDARY_HERO_USE" + if Player.getAT() < 150 then + return { Lang.translate(self:getUseTexts()[1], Lang.translate(self:getName())) .. "\n" .. + Lang.translate(usecomment) .. "\n" .. self:getHealText() } + else + return { Lang.translate(self:getUseTexts()[1], Lang.translate(self:getName())) .. "\n" .. self:getHealText() } + end +end + +return LegendaryHeroItem diff --git a/engine/items/monster_candy.lua b/engine/items/monster_candy.lua new file mode 100644 index 0000000..cf82aab --- /dev/null +++ b/engine/items/monster_candy.lua @@ -0,0 +1,52 @@ +--- @class Item.MonsterCandy : Dummy.Item.Consumable +local MonsterCandyItem = Class(ItemConsumable, "Item.MonsterCandy") + +--- Creates a monster candy +--- @return Item.MonsterCandy +function MonsterCandyItem:new() + self = Class:new(MonsterCandyItem, { + "monster_candy", -- item identifier + "ITEM_MONSTER_CANDY_NAME", -- item name + "ITEM_MONSTER_CANDY_SHORTNAME", -- item short name + "ITEM_MONSTER_CANDY_DESCRIPTION", -- item description + 10, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(15) + -- the price at which the item will be sold in the shop + self:setSellPrice(25) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_MONSTER_CANDY_DESCRIPTION_SHOP") + -- Random comments on use + self.use_comments = { + "ITEM_MONSTER_CANDY_USE", + "ITEM_MONSTER_CANDY_USE_2" + } + + return self +end + +function MonsterCandyItem:getDialogueTexts() + -- Generate a random number + local rand = love.math.random(0, 15) + -- Set the comment to initially be empty + local usecomment = "" + -- Set Default Dialogue Text + local dialogue_text = { Lang.translate(self:getUseTexts()[1], Lang.translate(self:getName())) .. + "\n" .. self:getHealText() } + -- Change use comment based on random number + if rand <= 2 then + usecomment = self.use_comments[1] + elseif rand == 15 then + usecomment = self.use_comments[2] + end + -- If the use comment is not empty, change the dialogue text to include the use comment + if usecomment ~= "" then + dialogue_text = { Lang.translate(self:getUseTexts()[1], Lang.translate(self:getName())) .. Lang.translate(usecomment) .. "\n" .. self:getHealText() } + end + return { dialogue_text } +end + +return MonsterCandyItem diff --git a/engine/items/nice_cream.lua b/engine/items/nice_cream.lua new file mode 100644 index 0000000..06b22d3 --- /dev/null +++ b/engine/items/nice_cream.lua @@ -0,0 +1,48 @@ +--- @class Item.NiceCream : Dummy.Item.Consumable +local NiceCreamItem = Class(ItemConsumable, "Item.NiceCream") + +--- Creates a nice cream +--- @return Item.NiceCream +function NiceCreamItem:new() + self = Class:new(NiceCreamItem, { + "nice_cream", -- item identifier + "ITEM_NICE_CREAM_NAME", -- item name + "ITEM_NICE_CREAM_SHORTNAME", -- item short name + "ITEM_NICE_CREAM_DESCRIPTION", -- item description + 15, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(15) + -- the price at which the item will be sold in the shop + self:setSellPrice(2) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_NICE_CREAM_DESCRIPTION_SHOP") + -- Random comments on use + self.use_comments = { + "ITEM_NICE_CREAM_USE", + "ITEM_NICE_CREAM_USE_2", + "ITEM_NICE_CREAM_USE_3", + "ITEM_NICE_CREAM_USE_4", + "ITEM_NICE_CREAM_USE_5", + "ITEM_NICE_CREAM_USE_6", + "ITEM_NICE_CREAM_USE_7", + "ITEM_NICE_CREAM_USE_8" + } + + return self +end + +function NiceCreamItem:getDialogueTexts() + -- Generate a random number + local rand = love.math.random(8) + -- Set Default Dialogue Text + local dialogue_text = Lang.translate(self:getUseTexts()[1], Lang.translate(self:getName())) .. + "\n" .. self:getHealText() + -- Override dialogue text with a random comment based on the random number + dialogue_text = Lang.translate(self.use_comments[rand]) + return { dialogue_text } +end + +return NiceCreamItem diff --git a/engine/items/popato_chisps.lua b/engine/items/popato_chisps.lua new file mode 100644 index 0000000..67520b3 --- /dev/null +++ b/engine/items/popato_chisps.lua @@ -0,0 +1,26 @@ +--- @class Item.PopatoChisps : Dummy.Item.Consumable +local PopatoChispsItem = Class(ItemConsumable, "Item.PopatoChisps") + +--- Creates a popato chisps +--- @return Item.PopatoChisps +function PopatoChispsItem:new() + self = Class:new(PopatoChispsItem, { + "popato_chisps", -- item identifier + "ITEM_POPATO_CHISPS_NAME", -- item name + "ITEM_POPATO_CHISPS_SHORTNAME", -- item short name + "ITEM_POPATO_CHISPS_DESCRIPTION", -- item description + 13, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(25) + -- the price at which the item will be sold in the shop + self:setSellPrice(35) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_POPATO_CHISPS_DESCRIPTION_SHOP") + + return self +end + +return PopatoChispsItem diff --git a/engine/items/sea_tea.lua b/engine/items/sea_tea.lua new file mode 100644 index 0000000..1fbfc6e --- /dev/null +++ b/engine/items/sea_tea.lua @@ -0,0 +1,43 @@ +--- @class Item.SeaTea : Dummy.Item.Consumable +local SeaTeaItem = Class(ItemConsumable, "Item.SeaTea") + +--- Creates a sea tea +--- @return Item.SeaTea +function SeaTeaItem:new() + self = Class:new(SeaTeaItem, { + "seatea", -- item identifier + "ITEM_SEATEA_NAME", -- item name + "ITEM_SEATEA_SHORTNAME", -- item short name + "ITEM_SEATEA_DESCRIPTION", -- item description + 10, + "drink" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(18) + -- the price at which the item will be sold in the shop + self:setSellPrice(5) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_SEATEA_DESCRIPTION_SHOP") + + return self +end + +function SeaTeaItem:onUse() + if Soul.getSpeed() < 2 then + Soul.setSpeed(Soul.getSpeed() + 0.25) + print(Soul.getSpeed()) + end +end + +function SeaTeaItem:getDialogueTexts() + local usecomment = "ITEM_SEATEA_USE" + if Soul.getSpeed() < 2 then + return { Lang.translate(self:getUseTexts()[1], Lang.translate(self:getName())) .. "\n" .. + Lang.translate(usecomment) .. "\n" .. self:getHealText() } + else + return { Lang.translate(self:getUseTexts()[1], Lang.translate(self:getName())) .. "\n" .. self:getHealText() } + end +end + +return SeaTeaItem diff --git a/engine/items/snail_pie.lua b/engine/items/snail_pie.lua new file mode 100644 index 0000000..f5853a6 --- /dev/null +++ b/engine/items/snail_pie.lua @@ -0,0 +1,38 @@ +--- @class Item.SnailPie : Dummy.Item.Consumable +local SnailPieItem = Class(ItemConsumable, "Item.SnailPie") + +--- Creates a snail pie +--- @return Item.SnailPie +function SnailPieItem:new() + self = Class:new(SnailPieItem, { + "snail_pie", -- item identifier + "ITEM_SNAIL_PIE_NAME", -- item name + "ITEM_SNAIL_PIE_SHORTNAME", -- item short name + "ITEM_SNAIL_PIE_DESCRIPTION", -- item description + math.pi, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(350) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_SNAIL_PIE_DESCRIPTION_SHOP") + + return self +end + +function SnailPieItem:getHeal() + if Player.getHP() < Player.getMaxHP() then + return (Player.getMaxHP() - Player.getHP()) - 1 + else + return 0 + end +end + +function SnailPieItem:getHealText() + return Lang.translate("ITEM_SNAIL_PIE_HEAL") +end + +return SnailPieItem diff --git a/engine/items/snowman_piece.lua b/engine/items/snowman_piece.lua new file mode 100644 index 0000000..1ff4749 --- /dev/null +++ b/engine/items/snowman_piece.lua @@ -0,0 +1,26 @@ +--- @class Item.SnowManPiece : Dummy.Item.Consumable +local SnowManPieceItem = Class(ItemConsumable, "Item.SnowManPiece") + +--- Creates a snowman piece +--- @return Item.SnowManPiece +function SnowManPieceItem:new() + self = Class:new(SnowManPieceItem, { + "snowman_piece", -- item identifier + "ITEM_SNOWMAN_PIECE_NAME", -- item name + "ITEM_SNOWMAN_PIECE_SHORTNAME", -- item short name + "ITEM_SNOWMAN_PIECE_DESCRIPTION", -- item description + 45, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(40) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_SNOWMAN_PIECE_DESCRIPTION_SHOP") + + return self +end + +return SnowManPieceItem diff --git a/engine/items/spider_cider.lua b/engine/items/spider_cider.lua new file mode 100644 index 0000000..9fe0b43 --- /dev/null +++ b/engine/items/spider_cider.lua @@ -0,0 +1,26 @@ +--- @class Item.SpiderCider : Dummy.Item.Consumable +local SpiderCiderItem = Class(ItemConsumable, "Item.SpiderCider") + +--- Creates a spider Cider +--- @return Item.SpiderCider +function SpiderCiderItem:new() + self = Class:new(SpiderCiderItem, { + "spider_cider", -- item identifier + "ITEM_SPIDER_CIDER_NAME", -- item name + "ITEM_SPIDER_CIDER_SHORTNAME", -- item short name + "ITEM_SPIDER_CIDER_DESCRIPTION", -- item description + 24, + "drink" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(18) + -- the price at which the item will be sold in the shop + self:setSellPrice(60) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_SPIDER_CIDER_DESCRIPTION_SHOP") + + return self +end + +return SpiderCiderItem diff --git a/engine/items/spider_donut.lua b/engine/items/spider_donut.lua new file mode 100644 index 0000000..751afc7 --- /dev/null +++ b/engine/items/spider_donut.lua @@ -0,0 +1,41 @@ +--- @class Item.SpiderDonut : Dummy.Item.Consumable +local SpiderDonutItem = Class(ItemConsumable, "Item.SpiderDonut") + +--- Creates a spider donut +--- @return Item.SpiderDonut +function SpiderDonutItem:new() + self = Class:new(SpiderDonutItem, { + "spider_donut", -- item identifier + "ITEM_SPIDER_DONUT_NAME", -- item name + "ITEM_SPIDER_DONUT_SHORTNAME", -- item short name + "ITEM_SPIDER_DONUT_DESCRIPTION", -- item description + 12, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(7) + -- the price at which the item will be sold in the shop + self:setSellPrice(30) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_SPIDER_DONUT_DESCRIPTION_SHOP") + + return self +end + +function SpiderDonutItem:getDialogueTexts() + -- Set Default Dialogue Text + local dialogue_text = Lang.translate(self:getUseTexts()[1], Lang.translate(self:getName())) .. "\n" .. self:getHealText() + -- Check if the player is in a battle + if World.isInBattle() then + -- Generate a random number + local rand = love.math.random(0, 10) + -- Override dialogue text with a comment based on the random number + if rand > 9 then + dialogue_text = Lang.translate("ITEM_SPIDER_DONUT_USE") + end + end + return { dialogue_text } +end + +return SpiderDonutItem diff --git a/engine/items/starfait.lua b/engine/items/starfait.lua new file mode 100644 index 0000000..5faec9e --- /dev/null +++ b/engine/items/starfait.lua @@ -0,0 +1,26 @@ +--- @class Item.Starfait : Dummy.Item.Consumable +local StarfaitItem = Class(ItemConsumable, "Item.Starfait") + +--- Creates a starfait +--- @return Item.Starfait +function StarfaitItem:new() + self = Class:new(StarfaitItem, { + "starfait", -- item identifier + "ITEM_STARFAIT_NAME", -- item name + "ITEM_STARFAIT_SHORTNAME", -- item short name + "ITEM_STARFAIT_DESCRIPTION", -- item description + 14, + "drink" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(60) + -- the price at which the item will be sold in the shop + self:setSellPrice(10) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_STARFAIT_DESCRIPTION_SHOP") + + return self +end + +return StarfaitItem diff --git a/engine/items/temmie_flakes.lua b/engine/items/temmie_flakes.lua new file mode 100644 index 0000000..6027da7 --- /dev/null +++ b/engine/items/temmie_flakes.lua @@ -0,0 +1,26 @@ +--- @class Item.TemmieFlakes : Dummy.Item.Consumable +local TemmieFlakesItem = Class(ItemConsumable, "Item.TemmieFlakes") + +--- Creates a temmie flakes +--- @return Item.TemmieFlakes +function TemmieFlakesItem:new() + self = Class:new(TemmieFlakesItem, { + "temmie_flakes", -- item identifier + "ITEM_TEMMIE_FLAKES_NAME", -- item name + "ITEM_TEMMIE_FLAKES_SHORTNAME", -- item short name + "ITEM_TEMMIE_FLAKES_DESCRIPTION", -- item description + 2, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(2) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_TEMMIE_FLAKES_DESCRIPTION_SHOP") + + return self +end + +return TemmieFlakesItem diff --git a/engine/items/unisicle.lua b/engine/items/unisicle.lua new file mode 100644 index 0000000..fd93a2e --- /dev/null +++ b/engine/items/unisicle.lua @@ -0,0 +1,26 @@ +--- @class Item.Unisicle : Dummy.Item.Consumable +local UnisicleItem = Class(ItemConsumable, "Item.Unisicle") + +--- Creates a unisicle +--- @return Item.Unisicle +function UnisicleItem:new() + self = Class:new(UnisicleItem, { + "unisicle", -- item identifier + "ITEM_UNISICLE_NAME", -- item name + "ITEM_UNISICLE_SHORTNAME", -- item short name + "ITEM_UNISICLE_DESCRIPTION", -- item description + 11, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(1) + -- the price at which the item will be sold in the shop + self:setSellPrice(2) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_UNISICLE_DESCRIPTION_SHOP") + + return self +end + +return UnisicleItem diff --git a/engine/mods/froggit/mod.lua b/engine/mods/froggit/mod.lua index c67eb32..1e0d1ee 100644 --- a/engine/mods/froggit/mod.lua +++ b/engine/mods/froggit/mod.lua @@ -19,14 +19,7 @@ function mod:load() Player.setLV(1) -- add items - Player.addItem(ItemConsumable:new( - "monster_candy", - "FROGGIT_MOD_MONSTER_CANDY_NAME", - "FROGGIT_MOD_MONSTER_CANDY_SHORTNAME", - "", - 50, - "food" - )) + Player.addItem(require("items.monster_candy"):new()) Player.addItem(ItemEquipment:new( "toy_knife", "FROGGIT_MOD_TOY_KNIFE_NAME", diff --git a/engine/mods/world_example/assets/langs/en.txt b/engine/mods/world_example/assets/langs/en.txt index 45ed427..2bae46f 100644 --- a/engine/mods/world_example/assets/langs/en.txt +++ b/engine/mods/world_example/assets/langs/en.txt @@ -81,11 +81,15 @@ WORLD_EXAMPLE_MOD_WORLD_SHOP_DUMMY_TALK_PAT_TEXT_2=* (...but it doesn't respond. WORLD_EXAMPLE_MOD_WORLD_SHOP_DUMMY_TALK_SIDE_TEXT=. . . # Items -WORLD_EXAMPLE_MOD_ITEM_MONSTER_CANDY_NAME=Monster Candy -WORLD_EXAMPLE_MOD_ITEM_MONSTER_CANDY_SHORTNAME=MnstrCndy -WORLD_EXAMPLE_MOD_ITEM_MONSTER_CANDY_DESCRIPTION=* "Monster Candy" - Heals 10 HP\n* Has a distinct,[wait:5] \n non-licorice flavor. -WORLD_EXAMPLE_MOD_ITEM_MONSTER_CANDY_DESCRIPTION_SHOP=Heals 10 HP\n(Licorice-\nfree\nguaranteed.) WORLD_EXAMPLE_MOD_ITEM_BLANKET_NAME=Blanket WORLD_EXAMPLE_MOD_ITEM_BLANKET_SHORTNAME=Blanket WORLD_EXAMPLE_MOD_ITEM_BLANKET_DESCRIPTION=* "Blanket" - Armor DF 1\n* The fabric is very soft. -WORLD_EXAMPLE_MOD_ITEM_BLANKET_DESCRIPTION_SHOP=Armor: 1DF\n({} DF)\n(It makes\nyou sleepy...) \ No newline at end of file +WORLD_EXAMPLE_MOD_ITEM_BLANKET_DESCRIPTION_SHOP=Armor: 1DF\n({} DF)\n(It makes\nyou sleepy...) + +# This overrides engine content +ITEM_BISICLE_NAME=Bisicle SP +ITEM_BISICLE_SHORTNAME=BscleSP +ITEM_BISICLE_SHORTNAME2=BscleSP +ITEM_BISICLE_DESCRIPTION=* "Bisicle SP" - Heals 11 HP\n* It's like a regular bisicle,[wait:5]\n but local to a mod! +ITEM_BISICLE_DESCRIPTION_SHOP=Heals 11HP x 2\nspecil +BATTLE_BISICLE_USE=* You eat one half of it.[wait:5]\n* You feel special. \ No newline at end of file diff --git a/engine/mods/world_example/mod.lua b/engine/mods/world_example/mod.lua index 121a317..53fed62 100644 --- a/engine/mods/world_example/mod.lua +++ b/engine/mods/world_example/mod.lua @@ -85,14 +85,14 @@ function WorldExampleMod:loadSaveData() -- equipped weapon if save_data.weapon ~= nil then if save_data.weapon ~= "stick" then - Player.setWeapon(modRequire("scripts.items." .. save_data.weapon):new()) + Player.setWeapon(tryRequire("scripts.items." .. save_data.weapon, "items." .. save_data.weapon):new()) end end -- equipped armor if save_data.armor ~= nil then if save_data.armor ~= "bandage" then - Player.setArmor(modRequire("scripts.items." .. save_data.armor):new()) + Player.setArmor(tryRequire("scripts.items." .. save_data.armor, "items." .. save_data.armor):new()) end end @@ -134,7 +134,7 @@ function WorldExampleMod:loadItem(item_id) item = bandage end else - item = modRequire("scripts.items." .. item_id):new() + item = tryRequire("scripts.items." .. item_id, "items." .. item_id):new() end return item end @@ -193,8 +193,15 @@ function WorldExampleMod:onEncounterEnd(encounter) WorldExampleMod:setTitle("WORLD_EXAMPLE_MOD_TITLE") end ---- Updates the mod, called on every game update +--- Updates the mod, called on every game updatez --- @param dt number -function WorldExampleMod:update(dt) end +function WorldExampleMod:update(dt) + if Input.isPressed("f1") then + if not World.isInBattle() then + local encounter = modRequire("scripts.encounters.dummy"):new() + World.startEncounter(encounter) + end + end +end return WorldExampleMod diff --git a/engine/mods/world_example/scripts/items/bisicle.lua b/engine/mods/world_example/scripts/items/bisicle.lua new file mode 100644 index 0000000..f719602 --- /dev/null +++ b/engine/mods/world_example/scripts/items/bisicle.lua @@ -0,0 +1,35 @@ +--- @class Item.Bisicle : Dummy.Item.Consumable +local BisicleItem = Class(ItemConsumable, "Item.Bisicle") + +--- Creates a bisicle +--- @return Item.Bisicle +function BisicleItem:new() + self = Class:new(BisicleItem, { + "bisicle", -- item identifier + "ITEM_BISICLE_NAME", -- item name + "ITEM_BISICLE_SHORTNAME", -- item short name + "ITEM_BISICLE_DESCRIPTION", -- item description + 11, + "food" + }) + + -- the price the player will pay to buy the item in the shop + self:setBuyPrice(15) + -- the price at which the item will be sold in the shop + self:setSellPrice(5) + -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item + self:setShopDescription("ITEM_BISICLE_DESCRIPTION_SHOP") + + self.use_texts = { + "ITEM_BISICLE_USE" + } + + return self +end + +function BisicleItem:onUse() + local unisicle = require("items.unisicle"):new() + Player.addItem(unisicle) +end + +return BisicleItem diff --git a/engine/mods/world_example/scripts/items/monster_candy.lua b/engine/mods/world_example/scripts/items/monster_candy.lua deleted file mode 100644 index 79460d9..0000000 --- a/engine/mods/world_example/scripts/items/monster_candy.lua +++ /dev/null @@ -1,26 +0,0 @@ ---- @class WorldExample.Item.MonsterCandy : Dummy.Item.Consumable -local MonsterCandyItem = Class(ItemConsumable, "WorldExample.Item.MonsterCandy") - ---- Creates a monster candy ---- @return WorldExample.Item.MonsterCandy -function MonsterCandyItem:new() - self = Class:new(MonsterCandyItem, { - "monster_candy", -- item identifier - "WORLD_EXAMPLE_MOD_ITEM_MONSTER_CANDY_NAME", -- item name - "WORLD_EXAMPLE_MOD_ITEM_MONSTER_CANDY_SHORTNAME", -- item short name - "WORLD_EXAMPLE_MOD_ITEM_MONSTER_CANDY_DESCRIPTION", -- item description - 10, - "food" - }) - - -- the price the player will pay to buy the item in the shop - self:setBuyPrice(15) - -- the price at which the item will be sold in the shop - self:setSellPrice(5) - -- the text that will appear in the shop item info at the top right on the buy menu when hovering an item - self:setShopDescription("WORLD_EXAMPLE_MOD_ITEM_MONSTER_CANDY_DESCRIPTION_SHOP") - - return self -end - -return MonsterCandyItem diff --git a/engine/mods/world_example/scripts/world/shop/dummy_shop.lua b/engine/mods/world_example/scripts/world/shop/dummy_shop.lua index 49f6c9a..a6e4cf3 100644 --- a/engine/mods/world_example/scripts/world/shop/dummy_shop.lua +++ b/engine/mods/world_example/scripts/world/shop/dummy_shop.lua @@ -41,11 +41,11 @@ end --- Prepares the shop items function DummyShop:prepareItems() - local MonsterCandy = modRequire("scripts.items.monster_candy") - -- amount `-1` for infinite stock + local MonsterCandy = require("items.monster_candy") + -- amount `-1` for infinite stocks self:addItem(MonsterCandy, -1) - local BlanketItem = modRequire("scripts.items.blanket") + local BlanketItem = require("items.blanket") local blanket_amount = 1 -- track wether the blanket has been bought if WorldExampleMod.flag["dummy_shop_blanket"] == 1 then diff --git a/engine/utils/utils.lua b/engine/utils/utils.lua index df08acd..315f2e7 100644 --- a/engine/utils/utils.lua +++ b/engine/utils/utils.lua @@ -7,6 +7,19 @@ function modRequire(modname) return require("mods." .. mod:getId() .. "." .. modname) end +--- Tries to require a module from the current mod, or the base game if it fails. +--- @param modname string +--- @param altname string +--- @return unknown +function tryRequire(modname, altname) + local mod = ModList.getCurrentMod() + local success, result = pcall(modRequire, modname) + if success then + return result + else + return require(altname) + end +end -- table -- -- https://gist.github.com/revolucas/dd1ecccfca32d558fddf70ddb39eb8a6