#Reference config from another mod?

40 messages · Page 1 of 1 (latest)

quick mantle
#

/config/sandwichable.json has a config called infoTooltipKeyBind which can be either SHIFT, CTRL, or ALT, which falls in line with KubeJS item tooltips' keys. I'd like to be able to make an if statement that can essentially reference back to this config and/or a default tooltip from Sandwichable to check for which key is enabled in the sandwichable.json config file and subsequently base which key the script checks for on that. (The third attached image is where I am with things at the current moment; a static tooltip. The fourth is an example of the tooltips from Sandwichable in-game.)

ancient magnetBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

thin lark
#

you can use JsonIO to read/write the file if you know the path

snow hornetBOT
#

Here's a simple snippet showing how to use JsonIO to read/write JSON files anywhere within the Minecraft folder:

// Reading the contents of the file from the given path
let config = JsonIO.read('kubejs/config/myawesomeconfig.json')

// Writing to an existing/new file
JsonIO.write('kubejs/config/myawesomeconfig.json', {settings: 'creeper', weirdblock: 'minecraft:end_gateway'})
quick mantle
snow hornetBOT
#

Paste version of hamsammie_detect_info_key.js from @quick mantle

quick mantle
#

To clarify, I don't have very much scripting knowledge. I don't let myself be spoonfed, however. I might ask ChatGPT for assistance on certain sections, but I do also write my own code and correct theirs. The section from lines 13 to 25 was majorly written by them. Everything else was me or the Wiki.

I'd imagine this is likely fine since I'm not using their code in full, but if this is still a breach of rule 6, I will take it down. My main reason for even seeking help from there to begin with is because I've had questions in the past go unanswered for months, both here and in other servers which use forums for assistance.

Ironically, the one thing forums were meant to help make better actually gets worse when using forums. This is why I heavily respect servers which have a quick support channel for people who don't want to wait 9 months for an answer.

thin lark
quick mantle
#
// Writing to an existing/new file
JsonIO.write('kubejs/config/myawesomeconfig.json', {settings: 'creeper', weirdblock: 'minecraft:end_gateway'})
thin lark
#

if you don't want to write, just don't add that line

quick mantle
#

My issue is needing to find a specific config value. I don't know how.

thin lark
#

what does console.log(config.infoTooltipKeybind) output?

#

try console.log(config) ?

quick mantle
#

[16:44:22] [INFO] hamsammie_detect_info_key.js#11: undefined

#
[16:58:48] [INFO] hamsammie_detect_info_key.js#11: {showInfoTooltips=true, infoTooltipKeyBind=SHIFT, slowEatingLargeSandwiches=false, baseSandwichEatTime=32, itemOptions={knives=[{itemId=sandwichable:stone_kitchen_knife, value=1, sharpness=132}, {itemId=sandwichable:kitchen_knife, value=3, sharpness=850}, {itemId=sandwichable:golden_kitchen_knife, value=5, sharpness=225}, {itemId=sandwichable:diamond_kitchen_knife, value=8, sharpness=1025}, {itemId=sandwichable:netherite_kitchen_knife, value=20, sharpness=1984}, {itemId=sandwichable:glass_kitchen_knife, value=1, sharpness=0}], saltItem=sandwichable:salt, cucumberItem=sandwichable:cucumber, pickledCucumberItem=sandwichable:pickled_cucumber, burntFoodItem=sandwichable:burnt_food, burntMorselItem=sandwichable:burnt_morsel}, saltySandGenOptions={saltySand=true}, shrubGenOptions={spawnTries=10}, saltPoolGenOptions={saltPools=true, drySaltPools=true}} [java.util.LinkedHashMap]
#

... is this a case of cAsE sEnSiTiVe naming?

#

it's spelled right later on but not there, oops

thin lark
#

propably

quick mantle
#

yup, case sensitive stuff.

#

Okay, so now the issue is...

#

... Hold $==={key}=== for info.

#

It should say SHIFT instead of $==={key}===.

thin lark
#

Try this
Hold ${key} for info

quick mantle
#

Why does the example on the wiki say this if that's the case?

ItemEvents.tooltip(event => {
  // ...
  // Show the name of the player who owns the skull in a skulls tooltip
  event.addAdvanced('minecraft:player_head', (item, advanced, text) => {
    let playerName = item.nbt?.SkullOwner?.Name
    if (playerName) {
      text.add(Text.red(`The head of $==={playerName}===`))
    }
  })
  // ...
})
quick mantle
thin lark
#

Yeah, some of the wiki is outdated but most are still helpful.

#

Is everything fine now?

quick mantle
#

Seems like it. I'll need to check one more time though.

thin lark
#

Good. You can ping me if you find other issues, or close the ticket if everything works properly.

quick mantle
#

Can do. 👍

#

... Hmm... It exists twice now.

#

I stand corrected. It seems to have been a load error. Reloading client scripts in-game fixed the duplicate.

#

Gonna close and re-open the game and see if it occurs again. If it does, I'll provide a client log. If it doesn't, I'll cycle my game one more time, just to be certain, but it may already be good.

#

Yup, duplicated again. All tooltips provided by the client are.

Gonna provide all three logs for this since some textures aren't loading when they should be either, namely my custom textures for the items piercingpaxels:upgrade_unbreakable and piercingpaxels:upgrade_restoration.

snow hornetBOT
#

Paste version of client.log, server.log, startup.log from @quick mantle

quick mantle
#

@thin lark Silent ping in case you're already watching the chat - sorry if that's the case.

thin lark
#

don't worry. Let me check the script and the log

quick mantle
#

If you need me to provide any other scripts based on what's shown, let me know. Some of my scripts are for a private modpack and should probably be provided via DM. (The sandwichable addon is technically one of them, but I imagine deleting the attached file will remove it from where the view link is later on, and it's also less serious of a thing to release than some of the others.)

thin lark