No, probably not. CMCT only lets you access the config values, i18n values, tokens, and internal assets of another mod for use in your own mod. But it does not let you edit those things in any other mod. It's read only, not read and write.
If you are the one making a mod with CMCT, then that means you have improperly written your token (probably misspelled a config option). Otherwise, it means a different mod in your mod list is using CMCT and either a) they have written the token wrong or b) the mod they were originally trying to check has changed their config options. As a user, you cannot fix this.
CMCT 2.0.0 will have better error handling in the future, sorry for now.
Hey, I was hoping you could give a fellow mod developer help with a question. I'm looking to use CMCT to check if seeds are enabled across mods for a global mixed seed. I'm leveraging Item Extensions for this. Item Extensions API supports Game State Queries for its Conditions, but I can only find examples of CMCT being used in When objects with CP.
Is there a way to use CMCT in a Game State Query? If so, could you provide a code snippet example? I can't tell if I'm massively overcomplicating this or not, haha...
CMCT tokens are just Content Patcher tokens and Content Patcher tokens can be used just about anywhere, including inside Conditions fields. For example: "Condition": "{{Spiderbuttons.CMCT/Config: Author.ModName, SomeOption}}"
If that config option (SomeOption) has a value of "true" then this is the equivalent of writing: "Condition": "true"
That said, these are still Content Patcher tokens. They only work in Content Patcher mods. If you're making a C# mod, you can maybe use Content Patcher's conditions API to check CMCT tokens, though I haven't personally used it before and am unfamiliar with it. But for the purposes of Item Extensions, checking directly for a value of "true" (or "false") like above or using a Content Patcher Query token to compare a config value to something else should work. As long as the final result of your tokens resolve to either "true" or "false" it should work, since "true" and "false" are valid Game State Queries themselves.
If you need further help either with CMCT or with understanding how to use Content Patcher tokens in general (like the Query token mentioned), I'd recommend joining the Stardew Valley discord and asking in the making-mods-general channel! People other than me will probably be able to help in there, too.
Awesome, thank you! The additional context and insight is very helpful.
I did notice after more digging that a there were a couple of different valid tokens for those condition queries, including true/false. Makes sense, but I wasn't sure if that would actually work or not. Also looks like strings are valid, at which point you can check if it contains|true or contains|false as well, which should again resolve to a bool value, and again work.
I guess it really is a lot like string preprocessing and substitution, like many other template languages. Neat.
Hmm, I'm not able to reproduce this error myself and someone else running tests for me didn't encounter it either... I can look into it more this evening, but in the meantime can you send me a log from smapi.io/log?
Heya! Without a log I can't say for certain, however I think this may have been due to an issue with SMAPI itself that was fixed in SMAPI 4.1.4, so please try updating your SMAPI first to see if the error goes away!
I'm not going to lie, Spider. You've been doing God's work for the modding community. It's so revolutionary. Because of you, CP modders have basically unlimited possibilities now! I'm really grateful for you, and I'm sure the rest of the community is as well. Amazing job. 👏👏👏
I'm very appreciative of this and super glad you think so! I figure if I can't make gorgeous art or tilesheets or stuff like that like many others can, the least I can do is make up for it with the code I can write to make others lives easier c:
If you are the same John Marley from the Stardew discord, then you are actually the reason I finally made this mod in the first place! So, thanks for giving me the last push I needed to actually do it (:
20 comments
[内容补丁] Mod 'Cross-Mod Compatibility Tokens' 添加了自定义令牌 'Spiderbuttons.CMCT/Config',但失败了,可能无法正常工作。有关详细信息,请参阅日志。
怎么解决?
CMCT 2.0.0 will have better error handling in the future, sorry for now.
Is there a way to use CMCT in a Game State Query? If so, could you provide a code snippet example? I can't tell if I'm massively overcomplicating this or not, haha...
Thanks
"Condition": "{{Spiderbuttons.CMCT/Config: Author.ModName, SomeOption}}"
If that config option (SomeOption) has a value of "true" then this is the equivalent of writing:
"Condition": "true"
That said, these are still Content Patcher tokens. They only work in Content Patcher mods. If you're making a C# mod, you can maybe use Content Patcher's conditions API to check CMCT tokens, though I haven't personally used it before and am unfamiliar with it. But for the purposes of Item Extensions, checking directly for a value of "true" (or "false") like above or using a Content Patcher Query token to compare a config value to something else should work. As long as the final result of your tokens resolve to either "true" or "false" it should work, since "true" and "false" are valid Game State Queries themselves.
If you need further help either with CMCT or with understanding how to use Content Patcher tokens in general (like the Query token mentioned), I'd recommend joining the Stardew Valley discord and asking in the making-mods-general channel! People other than me will probably be able to help in there, too.
I did notice after more digging that a there were a couple of different valid tokens for those condition queries, including true/false. Makes sense, but I wasn't sure if that would actually work or not. Also looks like strings are valid, at which point you can check if it contains|true or contains|false as well, which should again resolve to a bool value, and again work.
I guess it really is a lot like string preprocessing and substitution, like many other template languages. Neat.
[SMAPI] - Cross-Mod Compatibility Tokens 1.1.2 because it's no longer compatible. Please check for a new version at https://smapi.io/mods
I'm really grateful for you, and I'm sure the rest of the community is as well. Amazing job. 👏👏👏