#Hardcore Girl Mod - Deleting all items on death

52 messages · Page 1 of 1 (latest)

ornate saffron
#

why is there a ai generated picture of a woman

#

???

#

do you think that’s gonna make people want to help you

warped trail
#

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.

ornate saffron
#

thats just not true

warped trail
fair sparrow
#

so how exactly did you implement the approach for wiping the inventory?

warped trail
#

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"]
}
ornate saffron
#

your wipe shouldn't really be in init

#

should be in update

warped trail
fair sparrow
#

^ 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).

warped trail
#
{
  "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

fair sparrow
#

I assume that you're just trying to make it wipe the inventory without any sort of check for the time being, correct?

warped trail
fair sparrow
warped trail
#

But at this point, if I can manage to delete anything at all, that would already be amazing.

warped trail
#

But those files are not related to the same mod version, (the quest one, the tech one , etc)

fair sparrow
#

I'm aware

warped trail
#

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.

fair sparrow
#

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)

warped trail
#

👍

#

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.

fair sparrow
#

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

warped trail
#

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.

fair sparrow
#

have you been checking the logs for errors?

warped trail
#

yes

fair sparrow
#

alright

#

just trying to get a baseline of understanding

warped trail
#

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


fair sparrow
#

I'd use a genericScriptContext, e.g.
player.config.patch

[
  {"op": "add", "path": "/genericScriptContexts/trueHardcore", "value": "/path/to/script.lua"}
]
warped trail
#

Hum alright

#

So you would recommend script only, no tech and no quest?

fair sparrow
#

yep

#

just the script and that patch I just mentioned

warped trail
#

Ok, thank you. So how many files? Only 2 are needed, right? And I suppose the folder structure is really important given the paths?

fair sparrow
#

/path/to/script.lua is completely arbitrary

#

you just need to make sure that the folder structure matches what path you specify

warped trail
#

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!

fair sparrow
#

no problem 👍

wide nova
#

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