"Give Clothes" button/action/menu doesn't partition items

ensembien

Member
Jul 27, 2023
15
1
So when you interacti with a crew member and click the "Give Clothes" button, it only shows the first 14 items. The function should utilize the chunkUpAnArray() pattern used in the sibling functions "Return Clothes" and "Destroy Clothes". For reference, below is my implementation based on one of the said functions, with some irrelevant code removed (inventory space check). I also attached it as a file.
Code:
                    addButton(1, "Give Clothes", (function o() {
                            clearOutput(),
                            e.header(),
                            clearMenu();
                            var arr = pc.inventory.storage.reduce(function(s, o, i){
                                var n = 0;
                                switch (o.type) {
                                case GLOBAL.CLOTHING:
                                case GLOBAL.ARMOR:
                                    n = o instanceof ve.S ? 0 : e.inventory.armor.is(o) ? 2 : 1;
                                    break;
                                case GLOBAL.LOWER_UNDERGARMENT:
                                    n = e.inventory.lowerUndergarment.is(o) ? 2 : 1;
                                    break;
                                case GLOBAL.UPPER_UNDERGARMENT:
                                    n = e.inventory.upperUndergarment.is(o) ? 2 : 1;
                                    break;
                                }
                                if (n) { s.push({i: i, n: n, o: o}); }
                                return s;
                            }, []).sort(function (e, t) {return e.o.shortName.localeCompare(t.o.shortName)});
                            if (arr.length > 13) {
                                clearMenu();
                                for (var n = window.chunkUpAnArray(arr, 13), w = function () {
                                    var e = n[r],
                                    t = _t.m.toTitleCase(e[0].o.shortName),
                                    o = _t.m.toTitleCase(e[e.length - 1].o.shortName),
                                    a = t.charAt(0),
                                    i = o.charAt(0),
                                    s = a === i ? a : "".concat(a, " - ").concat(i);
                                    addButton(r, "Outfits [".concat(s, "]"), (function () {
                                            return u(e)
                                        }), "Selection of Outfits", t === o ? t : "".concat(t, " through ").concat(o, "."))
                                }, r = 0; r < n.length; r++)
                                    w()
                            } else
                                u(arr);
                            function u(t) {
                                clearMenu();
                                var a,
                                n = 0,
                                i = YT(t);
                                try {
                                    var s = function () {
                                        var t,
                                        o = a.value;
                                        e.uniqueItems && e.uniqueItems.some((function (e) {
                                                return o instanceof e
                                            })) ? ("Bess" === e.getClassName() && (t = "These highly adjustable JoyCo products are exclusive for use with " + bess.mf("Ben-14", "Bess-13") + " units."), addDisabledButton(n, o.shortName, _t.m.toDisplayCase(o.longName), t)) : z(o, n);
                                        n++
                                    };
                                    for (i.s(); !(a = i.n()).done; )
                                        s()
                                } catch (e) {
                                    i.e(e)
                                }
                                finally {
                                    i.f()
                                }
                                addButton(14, "Back", o)
                            }
                            function z(x, idx) {
                                var t = x.i;
                                var n = x.n;
                                var o = pc.inventory.storage[t],
                                i = o.getClassName();
                                switch (1 === n && (e.inventory.hasItem(i) && (n = 3), pc.inventory.storage[t].hasFlag(GLOBAL.ITEM_FLAG_UNDROPPABLE) && (n = -1)), n) {
                                case 1:
                                    addItemButton(idx, pc.inventory.storage[t], (function () {
                                            return l(t)
                                        }));
                                    break;
                                case 2:
                                    addDisabledButton(idx, pc.inventory.storage[t].shortName, _t.m.toDisplayCase(pc.inventory.storage[t].longName), "".concat(e.short, " is already wearing one of these!"));
                                    break;
                                case 3:
                                    addDisabledButton(idx, pc.inventory.storage[t].shortName, _t.m.toDisplayCase(pc.inventory.storage[t].longName), "".concat(e.short, " already has one of these."));
                                    break;
                                case -1:
                                    addDisabledButton(idx, pc.inventory.storage[t].shortName, _t.m.toDisplayCase(pc.inventory.storage[t].longName), "You cannot drop this item.")
                                }
                            }
                            0 === arr.length ? output("<b>You don’t have anything to give ".concat(e.short, " right now.</b>\n\n")) : output("Which clothes do you want to give ".concat(e.short, "?\n\n"));
                            function l(t) {
                                function a(t) {
                                    var a = pc.inventory.storage[t];
                                    clearOutput(),
                                    i(a),
                                    e.header(),
                                    function () {
                                        switch (e.getClassName()) {
                                        case "Reaha":
                                            output("<i>“I’ve got a present for you!”</i>"),
                                            output("\n\n<i>“Ooh! What is it?”</i> she asks, looking at you expectantly."),
                                            a.sexiness >= 5 ? output(" <i>“Oh, cute!”</i> Reaha giggles as you hand over " + a.description + ". She puts it up against herself, showing off her cute new outfit for you. You tell her it looks good on her, earning a smile from her. <i>“Thank you so much, [pc.name]! I’ll go change!”</i>") : a.defense >= 3 ? (output(" <i>“Armor?”</i> Reaha asks, raising an eyebrow, but taking " + a.description + " anyway. <i>“Neat. I haven’t really worn much armor since the army, but I appreciate the thought!"), isSillyModeEnabled() ? output(" This’ll keep me nice and safe in case somebody tries to rustle me, right?") : output(" This’ll come in handy in case we ever get boarded, I’m sure."), output(" I’ll go put this on - thanks, [pc.name]. Glad to know you’re looking out for me!”</i>")) : a.shields >= 5 ? (output(" <i>“Wow, a shield generator,”</i> Reaha says as you hand over " + a.description + ". <i>“Us poor grunts didn’t even get these back in the army. Then again, I mostly sat around in a tank anyway!”</i> she laughs, taking " + a.description + "."), output("\n\n<i>“Thanks for this, [pc.name],”</i> she adds with a smile. <i>“It’ll keep me nice and safe!”</i>")) : a.sexiness < 0 ? output(" <i>“...Oh,”</i> she says, the excitement fading from her voice as she sees the ugly " + a.description + " on offer. <i>“Um, thanks, [pc.name].”</i>") : a.longName.indexOf("cow") >= 0 ? (output(" <i>“Moo!”</i> Reaha cheers as she takes in the pretty cow’s clothing. <i>“Hehe, thanks [pc.name], it’s adorable! I feel like I shouldn’t like cow-print, but... it’s just so cute! I love it!”</i>"), output("\n\nShe catches you in a big hug, squeezing her tits tight against your [pc.chest]. <i>“I’ll go change. Be a shame if someone took advantage of me while I did,”</i> she adds with a lusty wink.")) : (output(" <i>“Aww, thank you!”</i> Reaha says, taking the proffered " + a.description + " from you. Once you’ve handed it over, Reaha "), pc.tallness > reaha.tallness + 4 ? output("leans up on her tip-toes and") : output("leans in and"), output(" gives you a peck on the cheek. <i>“You’re too sweet, [pc.name]. I’ll go change into this right away!”</i>"));
                                            break;
                                        case "Mitzi":
                                            output("\n\n<i>“Holyshitreally?”</i> Mitzi hugs your [pc.leg] crushingly tight. Little bimbo tears streak down her cheeks. <i>“You’re the best, [pc.Master]. Mitzi is going to wear this for you right now!”</i>\n\nUnsurprisingly, she makes it look hot as hell."),
                                            pc.hasStatusEffect("Mitzi Dressed") || pc.createStatusEffect("Mitzi Dressed"),
                                            pc.setStatusMinutes("Mitzi Dressed", 5760)
                                        }
                                    }
                                    (),
                                    pc.inventory.storage.splice(t, 1),
                                    processTime(2),
                                    clearMenu(),
                                    addButton(0, "Next", o)
                                }
                                clearOutput(),
                                e.header(),
                                output("Are you sure you want to give ".concat(e.short, " ").concat(pc.inventory.storage[t].description, "?")),
                                clearMenu(),
                                addButton(0, "Yes", (function () {
                                        return a(t)
                                    }), "Yes", "Give ".concat(e.short, " the clothes.")),
                                addButton(1, "No", o, "No", "Keep the clothes.")
                            }
                            s(),
                            addButton(14, "Back", t)
                        }), "Give Clothes", "Hand over some of your clothes to ".concat(a, ".")),
 

Attachments

  • give_clothes.js.txt
    7.1 KB · Views: 0
Last edited:

ensembien

Member
Jul 27, 2023
15
1
Updated the original post since mine also was buggy - thanks to copypasta, the outer function i was clobbered by the local function i defined inside the "for (var n = window.chunkUpAnArray(arr, 13), i = function()...)" loop. So I simply renamed thelocal function to w, i.e.
Code:
for (var n = window.chunkUpAnArray(arr, 13), w = function(){
...
}, r = 0; r < n.length; r++)
  w()
No idea why on earth it was working before.