Without padding, you can't really see the background on the generation iframe
, but it applies nonetheless:
It's because the message is split by the whitespaces, meaning 'living room' would be split to 'living' and 'room'. You could remove the .split(...).map(...)
and just normalize the message with .toLowerCase()
i.e. message.content.toLowerCase()
then it should work for the 'living room'.
Here's a code that might be what you want:
const backgroundUrls = {
'beach': 'https://user-uploads.perchance.org/file/a4c99b37a4d466b9a3fac8c9864d92b7.webp',
'cottages': 'https://user-uploads.perchance.org/file/13a5f82ae06233afcd35df95c5ffe806.webp',
// Add more background keywords and URLs as needed
};
const avatarUrls = {
'ramon': 'https://user-uploads.perchance.org/file/c986b9d02086c6cf9833761199d2fc52.webp',
'kylie': 'https://user-uploads.perchance.org/file/a6ba77a96dfd17a50101eba227435c07.webp',
// Add more avatar keywords as needed
};
oc.thread.on("MessageAdded", function({message}) {
if (message.author == 'user') { // you can change which reply can trigger the code, currently it is the user triggering the code
let words = message.content.split(/[\s+']/gm).map(a => a.toLowerCase()) // just separates the text into words
let foundBG = Object.keys(backgroundUrls).find((a) => words.includes(a)); // finds the keyword that is found on the message
let foundAVATAR = Object.keys(avatarUrls).find((a) => words.includes(a));
if (foundBG) oc.thread.messages.at(-1).scene = { 'background': {'url': backgroundUrls[foundBG]} }; // if a background keyword is found, change the bg
if (foundAVATAR) oc.character.avatar.url = avatarUrls[foundAVATAR]; // if an avatar keyword is found, change the avatar
message.expectsReply = false; // this just tells the AI not to reply to the user's message (remove if you need the AI to reply)
}
});
Images are from my unfinished VN: a-trip-to-the-beach :)
Not sure if you knew, but you can navigate to the galleries via the menu when saving the image to the gallery, even if there isn't a gallery element on the page. But yes, it could save some space on the server if we can disable the gallery.
I don't think it was implemented. Only the data.inputs
on the onFinish
was added.
Ah, .sentenceCase
is used to only capitalize the 1st letter of the sentence. You might want to use .titleCase
to capitalize each word.
I didn't intend the comment to mean that the 'this issue should be ignored' but just stating an observation on the generators that I've seen in Perchance (maybe I intended it unconsciously, so sorry), but I get what you mean that it is quite limiting not to be able to use the regular ways of accessing/manipulating the DOM.
In most cases, I don't think people would directly use the document.body
(unless they are appending something to it) so this might be just for rare cases.
Most of the time, they would be working with what they have added on the HTML panel, and not on the parent of it.
It's was just found on the source. The AI apis are not so public, you have to use the plugin directly.
There isnt really a documentation to it, but it only accepts one parameter as far as I tested. Also it just returns recently updated generators up to a week regardless if you make the number large enough. If you want to retrieve generators by url, check the generator list template which is used to create the generator hubs.
Second this, so we can probably use 'anime' keywords in a 'realistic' model :)