#Hardcore Girl Mod - Deleting all items on death
52 messages · Page 1 of 1 (latest)
I had to include an image in the post, and the folder for the mod I’m making is called Hardcore Girl, which represents and reflects me. That was also the image I had generated for the mod.
No you don't????
thats just not true
Ohhh okay, my bad then — I thought I had to, there was this big shiny “add image” button staring at me… so I did. 😅
so how exactly did you implement the approach for wiping the inventory?
I've tried multiple things but I'm a complet noob
so for exemple , I've tried this :
truehardcore_wipe.lua
if world.getProperty("truehardcore_wipe_done") then return end
world.setProperty("truehardcore_wipe_done", true)
local inventories = { "mainBag", "tileBag", "actionBar" }
for _, inv in ipairs(inventories) do
local items = player.inventoryItems(inv)
for _, item in ipairs(items) do
if not item.essential then
player.consumeItem({name=item.name, count=item.count}, true, false, inv)
end
end
end
end
function update(dt) end
function uninit() end
{
"name" : "truehardcore_wipe",
"scripts" : ["/scripts/truehardcore_wipe.lua"]
}
👍
^ plus, using world.getProperty and world.setProperty isn't a good idea. That sets properties across the whole world (which other entities can access too).
Yeah that's what I though, so I also tried adding a quest or a tech
{
"id" : "truehardcore_wipe_quest",
"title" : "Invisible Hardcore Wipe Quest",
"text" : "",
"completionText" : "",
"script" : "/scripts/truehardcore_wipe_quest.lua",
"icon" : "/interface/quests/quest.png",
"categories" : ["main"],
"planetMode" : "none",
"hidden" : true,
"moneyRange" : [0, 0],
"rewards" : []
}
{
"name" : "truehardcore_wipe",
"type" : "body",
"rarity" : "common",
"displayName" : "True Hardcore Wipe",
"scripts" : ["/tech/body/truehardcore/truehardcore_wipe.lua"],
"icon" : "/interface/tech/blank.png",
"description" : "Invisible tech that wipes inventory for hardcore players.",
"shortDescription" : "True Hardcore Wipe"
}
function init()
if player.mode() ~= "hardcore" then
tech.setParentDirectives("")
tech.setVisible(false)
tech.setToolUsageSuppressed(false)
tech.setPersistent(false)
tech.setActive(false)
return
end
sb.logInfo("[TrueHardcore] Tech initialized for hardcore player")
wipeInventory()
status.addEphemeralEffect("truehardcore_wipe", math.huge)
end
function update(dt)
end
function uninit()
end
function wipeInventory()
sb.logInfo("[TrueHardcore] Wiping inventory…")
local essentialItems = root.assetJson("/player.config").essentialItems or {}
local essentialsSet = {}
for _, v in pairs(essentialItems) do
essentialsSet[v] = true
end
local bags = {
"mainBag",
"tile",
"objectBag",
"actionBar",
"swap",
"materialBag"
}
local totalWiped = 0
for _, bag in ipairs(bags) do
for _, item in pairs(player.inventoryItems(bag)) do
if item and item.name and not essentialsSet[item.name] then
local success = player.consumeItem({name=item.name, count=item.count, parameters=item.parameters}, false, true)
if success then
totalWiped = totalWiped + item.count
end
end
end
end
sb.logInfo(string.format("[TrueHardcore] Inventory wiped. Total items removed: %d", totalWiped))
player.radioMessage({text = "^red;Votre inventaire a été purgé.^reset;", unique = true})
end
It’s my first mod, so I’m just experimenting and figuring things out sry
I assume that you're just trying to make it wipe the inventory without any sort of check for the time being, correct?
At first, I wanted to make a distinction between the inventory “tabs” — to still drop the components, but delete the weapons, clothes, armor, and the first tab that holds the weapons and tools.
btw what kind of file is this defining?
But at this point, if I can manage to delete anything at all, that would already be amazing.
I've made tons of test, for at least 10 version of the mod so I just copy past some of the files to help you get a global idea of things I'm struggling with.
But those files are not related to the same mod version, (the quest one, the tech one , etc)
I'm aware
So before starting over from scratch, I wanted to hear some opinions about what works, the latest game updates, etc., just to know what I’m dealing with — or for someone to tell me, for example, that it’s hopeless because it’s hardcoded, that kind of thing.
alright so the individual components are entirely possible
checking the player's health, getting all items in the inventory, and consuming one item (which can be scaled to all items)
👍
The thing is, at some point I started wondering if I might have a compatibility issue with my other mods — especially FU — if I was modifying files with the same name, that kind of thing.
however, the way that you did it (going through the player's items bag by bag) might not work (at least not anymore)
player.inventoryItems is not listed in the documentation
Oh, okay. That might be related, because the problem I kept running into was that even though my mod was always detected, the status, quest, or tech would never get added, and therefore the effect would never trigger.
have you been checking the logs for errors?
yes
there was no error cause the effect wasnt applying
I've also tried this :
function init()
status.addEphemeralEffect("truehardcore_wipe", math.huge)
end
function update(dt)
status.addEphemeralEffect("truehardcore_wipe", 1.0)
end
function uninit()
end
I'd use a genericScriptContext, e.g.
player.config.patch
[
{"op": "add", "path": "/genericScriptContexts/trueHardcore", "value": "/path/to/script.lua"}
]
Ok, thank you. So how many files? Only 2 are needed, right? And I suppose the folder structure is really important given the paths?
/path/to/script.lua is completely arbitrary
you just need to make sure that the folder structure matches what path you specify
Okay, I’ll get back to it after dinner :p You gave me back a bit of courage and hope, lol. We’ll see how it turns out — thanks for your help!
no problem 👍
where did you get the names tileBag and player.inventoryItems, and why did you later swap tileBag for just tile
why do you think actionBar and swap are bags that holds its own items? if you knew about mainBag, you would've seen that it's called materialBag, not tileBag, and also that actionBar,tile, and swap are not in the list of bags
why are you trying to access essentialItems of player.config. that has never existed
why do you think icon is something quests accept. where did you see it used
why is the script for your quest in the scripts folder instead of the quest scripts folder. you would've seen the quest scripts folder while in the quests folder to see how quests are formatted, or you would've seen that whatever quest you referenced uses a script in the quest scripts folder
displayName is not a thing for techs. /interface/tech is not where tech icons are stored
tech.setPersistent and tech.setActive do not exist and never have. both of these names, and the fact that you'd even consider using a tech that stays active on the player, make me think whatever wrote it was unaware that players can only have one tech active per slot (such as a generative AI model)
why would you need to tech.setVisible(false) for an invisible tech w/o animation
how could you have made 10 different versions without trying to find out how a tech gets added to the player or how a quest becomes active
why did your tech wipe the player's inventory then give them a status effect that, based on its name, also wipes their inventory
all of this makes me think you're using generative AI to try and make the mod for you. my advice, based on how it's constantly tried to use things that do not exist, is to try making the mod without it. you'll need to investigate starbound's assets and read its lua documentation yourself, and it will be a slow process, but it's the best way for you to make this mod aside from paying someone who knows how to mod to do it