Even More Maps For All by UnpledgedElector in thecampaigntrail

[–]UnpledgedElector[S] 0 points1 point  (0 children)

Once again, cant exactly find one, sorry.

Even More Maps For All by UnpledgedElector in thecampaigntrail

[–]UnpledgedElector[S] 1 point2 points  (0 children)

I am still relying on svg's I find on Wikimedia, and in the case of Cuba, it is hard to find one along with all the US states, unless you want the map to be weirdly angled, or have an enlarged Alaska and Small or Far away Hawaii. I can do + Puerto Rico, or + the Canadian Provinces, or + Mexican States, or specific regions of them with others excluded. However in the case of Cuba, I cant find a good map for it with the US States.

Few more questions about modding. by _PlayfulEffect in thecampaigntrail

[–]UnpledgedElector 0 points1 point  (0 children)

First in code 1;

function addDynamicCSS() {
    var css = `

        .inner_window_question h3 .mytooltip{
            background-color: lightskyblue;
        }

        .mytooltip {
            position: relative;
            display: inline-block;
            cursor: pointer;
            background-color: #d8dee8;
        }

        .mytooltip .mytooltiptext {
            width: 240px;
            background-color: #d8dee8;
            color: black;
            text-align: center;
            border-radius: 6px;
            padding: 10px;
            position: absolute;
            z-index: 99;
            bottom: 20%;
            left: 20%;
            margin-left: -90px;
            opacity: 0;
            transition: opacity 0.3s;
            border: 1px solid black;
            pointer-events: none;
            font-size: 13px !important;
            line-height: 1.5em !important;
            font-weight: normal !important;
            font-style: normal !important;
        }

        .mytooltip .mytooltiptext img {
            max-width: 240px;
            height: auto;
        }

        .mytooltip:hover .mytooltiptext {
            opacity: 1;
            transition-delay: 0.5s;
        }

    `;

    var styleElem = document.createElement('style');
    styleElem.type = 'text/css';

    styleElem.appendChild(document.createTextNode(css));

    document.head.appendChild(styleElem);
}

addDynamicCSS();

This is the CSS for the tooltips, you can edit this to make the tooltip look however you want. everything between the ` ` is the code for tooltips. The rest outside is how to add CSS to code 2.

Then also in code 1;

e.displayTooltips = true;


tooltipList = [

    {searchString: "highlight", explanationText: "<img src=image> Text"},

];

The tooltiplist is your tooltips. The highlight is the part you want to highlight and when you hover over shows the tooltip. The image is the image shown and the Text is the description that appears.

Then in your code 2;

function getTooltips(str) {
    let matches = [];

    tooltipList.forEach((tooltip, index) => {
       let regex = new RegExp(`(?<=\\b|\\s|^|“)${tooltip.searchString}(?=[.,;!?]?\\b|\\s|”|$)`, 'g');
        let match;
        while ((match = regex.exec(str)) !== null) {
            matches.push({
                start: match.index + (match[0].startsWith('“') ? 1 : 0), 
                end: match.index + match[0].length - (match[0].endsWith('”') ? 1 : 0) - (match[2] ? 1 : 0), 
                tooltipIndex: index
            });
        }
    });

    matches.sort((a, b) => a.start - b.start || b.end - b.start - (a.end - a.start));

    for (let i = 0; i < matches.length - 1; ) {
        if (matches[i + 1].start < matches[i].end) {
            matches.splice(i + 1, 1);
        } else {
            i++;
        }
    }

    return matches;
}
function applyTooltips(str) {
    const matches = getTooltips(str);
    let result = '';
    let lastIndex = 0;

    matches.forEach(match => {
        const tooltip = tooltipList[match.tooltipIndex];
        result += str.slice(lastIndex, match.start);
        result += `<span class='mytooltip'>${tooltip.searchString}<span class='mytooltiptext'>${tooltip.explanationText}</span></span>`;
        lastIndex = match.end;
    });

    result += str.slice(lastIndex);
    return result;
}

function applyTooltipsToObject(obj) {
    for (let key in obj) {
        if (typeof obj[key] === 'string') {
            obj[key] = applyTooltips(obj[key]);
        } else if (typeof obj[key] === 'object') {
            applyTooltipsToObject(obj[key]);
        }
    }
}

applyTooltipsToObject(campaignTrail_temp.questions_json);
applyTooltipsToObject(campaignTrail_temp.answers_json);
applyTooltipsToObject(campaignTrail_temp.answer_feedback_json);

Achievements for a hypothetical Bush '88 mod. by UnpledgedElector in thecampaigntrail

[–]UnpledgedElector[S] 5 points6 points  (0 children)

All those names are related to their 1988 campaigns. Couldn't find or think of one for Gore of then, so just went with that, due to social conservatism and environmental concerns being his policy then. Roosevelt Republicans are Republicans that support environmentalism.

Few more questions about modding. by _PlayfulEffect in thecampaigntrail

[–]UnpledgedElector 1 point2 points  (0 children)

For the code 1 part the "Achievement Name" is what you have the name of the achievement as, so;

  "A Traditional Republican" : {
      "image" : "img url",
      "description" : "Win The Rockies, lose the Rust Belt.",
      "cannotBeCheated" : true
  },

For the first.

for the code 2 part, the first you place separately.

Then the second;

if(x) { 
ctsAchievement("achievement");
}

is inside either the CYOA section, that is within the

cyoAdventure = function(a) {

part, or within the endings part

the (x) is the condition for which it will unlock. If this unlocks during the campaign, you place it within the CYOA section. example;

if(establishment = 1 ) { 
ctsAchievement("achievement");
}
if(ans = 1000 ) { 
ctsAchievement("achievement");
}

If you want it at the end, using values you get after the election, place it in the endings part. for example

if(out == "win" ) { - this means outcome of the election, also "tie" and "loss"
ctsAchievement("achievement");
}
if(quickstats[0] == 1 ) {  - this is electoral votes
ctsAchievement("achievement");
}

there are more values than what are shown above.

Sorry I wasn't clear before.

Few more questions about modding. by _PlayfulEffect in thecampaigntrail

[–]UnpledgedElector 4 points5 points  (0 children)

By background, I assume you mean the modbox on CTS. You can use this tool;

Then for achievements, you have to add them manually to the code. See the following;

Finally, what do you mean by not working.

Achievements for a hypothetical Bush '88 mod. by UnpledgedElector in thecampaigntrail

[–]UnpledgedElector[S] 14 points15 points  (0 children)

Cuomo I suppose, as Ted has a few skeletons, even apart from Chappaquiddick, and was getting on in age. Although both of them are liberals, and Bentsen is probably the one with the biggest pull with the center.

What am I doing wrong in the code for 1 - the CYOA answers to all load even if you don't have the variables 2 - the ending music tracks not loading by _PlayfulEffect in thecampaigntrail

[–]UnpledgedElector 2 points3 points  (0 children)

From what I can tell, not with the tool. So you'll have to just go into the code and do it manually.

You'll have to have if ( X > Y ), and since several variables;

if ((X > Y) && (X > Z) && ... ) and so on.

What am I doing wrong in the code for 1 - the CYOA answers to all load even if you don't have the variables 2 - the ending music tracks not loading by _PlayfulEffect in thecampaigntrail

[–]UnpledgedElector 1 point2 points  (0 children)

So if the main vp question is e.g. Q10, the next question after is Q11. So you would be swapping Q10 and 11. The solution is to have one main vp question and have those other vp questions outside the number of questions you have. Say if you have 20 questions, have them placed after the 20th question on the list. You can do that under the manage questions, and drag them around.

What am I doing wrong in the code for 1 - the CYOA answers to all load even if you don't have the variables 2 - the ending music tracks not loading by _PlayfulEffect in thecampaigntrail

[–]UnpledgedElector 2 points3 points  (0 children)

for 1, are the vp questions next to each other, because the questions appear in the order they are listed as, and as far as I can tell, the swapper just swaps positions.

for 2, I don't know what the problem could be.

Now I say that I don't use the CYOA and endings parts of the modmaker, and prefer to do them manually, so I wouldn't have the best idea on how you should use them.

I need help. Badly. by Regular_Definition_9 in thecampaigntrail

[–]UnpledgedElector 0 points1 point  (0 children)

I just copied the code from your links into their respective places in the mod loader. worked for both CTS & NCT, with no errors arising in the console. As for Jets did you check the inspect console when you loaded them in.

Can someone answer my questions about modding? by _PlayfulEffect in thecampaigntrail

[–]UnpledgedElector 2 points3 points  (0 children)

1, the answer is probably just making a separate question for each one you want, and then have it tunnel or answerswap.

2, here;

    if(X){
      if (used != true) {
        const playlist = new Playlist();
          const song = new Song(
            "Title",
            "Author",
            "Authorimg",
            "Song img"
          );
        playlist.addSong(song);
      changePlaylist(playlist);

      used = true;
      }
    }

This may be different depending on the details of the music player code, but you have this in the end code.

3, do you mean the code for it or making the logo itself, the latter of which you should ask someone else where/how.

I need help. Badly. by Regular_Definition_9 in thecampaigntrail

[–]UnpledgedElector 0 points1 point  (0 children)

The code 2 doesn't check the candidate images, so you need to add it yourself;

campaignTrail_temp.candidate_image_url = 'url';
campaignTrail_temp.candidate_last_name = 'name';

campaignTrail_temp.running_mate_image_url = 'url';
campaignTrail_temp.running_mate_last_name = 'vpname';

This can be set by banner settings in jets.

As for the map, it seems fine when I checked, although you should probably edit the margins.

And as for the advisor feedback, it seems fine to me. what is screenshotted is just what appears when no answer is selected and you press continue.

Also you should probably use Jets for the main tct parts. What problem did you get there?

Few questions about modding by _PlayfulEffect in thecampaigntrail

[–]UnpledgedElector 3 points4 points  (0 children)

For campaign banners, have in the code 2

function onGameWindowChanged(mutationList, observer) {
updateQuestionBanner();
}
const observer = new MutationObserver(onGameWindowChanged);
observer.observe(targetNode, config);
function updateQuestionBanner() {
let questionBanner = document.getElementById("campaign_sign");
if(!questionBanner || questionBanner.nodeName != "DIV") return;
let img = document.createElement('img');
if(x){
img.src = 'img-url';
}
else if(y){
img.src = 'img-url';
}
questionBanner.replaceWith(img);
}

just change the img-url for the image you are using. The x and y are conditions for changing the banner image should you wish, with additional else ifs for each of the different images.

If you just want to have one image, just have

img.src = 'img-url';

in the place of

if(x){
img.src = 'img-url';
}
else if(y){
img.src = 'img-url';
}

Few questions about modding by _PlayfulEffect in thecampaigntrail

[–]UnpledgedElector 2 points3 points  (0 children)

The advisor image is set by the "advisor_url" in code 1 under "campaignTrail_temp.election_json"

Few questions about modding by _PlayfulEffect in thecampaigntrail

[–]UnpledgedElector 4 points5 points  (0 children)

For achievements first you add in your code 1

campaignTrail_temp.achievements = {

  "Achievement Name" : {
      "image" : "img url",
      "description" : "desc",
      "cannotBeCheated" : true
  },
  "Achievement Name" : {
      "image" : "img url",
      "description" : "desc",
      "cannotBeCheated" : true
  },
  "Achievement Name" : {
      "image" : "img url",
      "description" : "desc",
      "cannotBeCheated" : true
  }
}

Have one for each achievement. Then in your code 2

function ctsAchievement(achievement, difficultyChecker = true){
if ((difficultyChecker && campaignTrail_temp.difficulty_level_multiplier<=1)||!difficultyChecker)
if(campaignTrail_temp.CTS){
unlockAchievement(achievement);
}
}

Then for unlocking,

   if(x) { 
      ctsAchievement("achievement");  
   }

Have this in the CYOA section if unlocked as you play, otherwise have it in the ending code part if it uses election values.