Update 'mbchc-local.user.js'

This commit is contained in:
Mute 2022-07-05 17:53:00 +00:00
parent 6663c2eede
commit e6a35024c8

View File

@ -34,7 +34,7 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER
RE_PREF_ACTIVITY_ME: /^@/, RE_PREF_ACTIVITY_ME: /^@/,
RE_PREF_ACTIVITY: /^@@/, RE_PREF_ACTIVITY: /^@@/,
RE_ACT_CHARS: /^<(\d+)?:(\d+)?>/, RE_ACT_CHARS: /^<(\d+)?:(\d+)?>/,
RE_TZ: /(?:GMT|UTC)([+-]\d\d?)/, RE_TZ: /(?:GMT|UTC)([+-]\d\d?)/i,
RGB_MUTE: "#6c2132", RGB_MUTE: "#6c2132",
RGB_POLLY: "#81b1e7", RGB_POLLY: "#81b1e7",
UTC_OFFSET: new Date().getTimezoneOffset() * 60 * 1000, UTC_OFFSET: new Date().getTimezoneOffset() * 60 * 1000,
@ -163,6 +163,19 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER
{ Tag: "activity", Description: "[Message]: Send a custom activity (or \"@@Message\", or \"@Message\" as yourself)", Action: (argline, cmdline, args) => { window.MBCHC.command_activity(argline, cmdline, args) } }, { Tag: "activity", Description: "[Message]: Send a custom activity (or \"@@Message\", or \"@Message\" as yourself)", Action: (argline, cmdline, args) => { window.MBCHC.command_activity(argline, cmdline, args) } },
{ Tag: "do", Description: ": Do an activity, as if clicked on its button (\"/do\" for help)", Action: (argline, cmdline, args) => { window.MBCHC.command_do(argline, cmdline, args) } }, { Tag: "do", Description: ": Do an activity, as if clicked on its button (\"/do\" for help)", Action: (argline, cmdline, args) => { window.MBCHC.command_do(argline, cmdline, args) } },
], ],
calculate_maps: function() {
this.DO_DATA = {verbs: {}, zones: {}}
for (let [verbs, data] of Object.entries(this.MAP_ACTIONS)) {
let unwound = {}
for (let [zones, actions] of Object.entries(data)) {
let all = (actions.all) ? actions.all.split("|") : []
let processed = {self: (actions.self) ? actions.self.split("|").concat(all) : all, others: (actions.others) ? actions.others.split("|").concat(all) : all}
for (let zone of zones.split(",")) unwound[`Item${zone}`] = processed
}
for (let verb of verbs.split("|")) this.DO_DATA.verbs[verb] = unwound
}
for (let [ag, zones] of Object.entries(this.MAP_ZONES)) for (let i in zones) this.DO_DATA.zones[zones[i]] = ag
},
settings: function(setting = null) { settings: function(setting = null) {
let settings = window.Player.OnlineSettings.MBCHC || {} let settings = window.Player.OnlineSettings.MBCHC || {}
return(setting ? settings[setting] : settings) return(setting ? settings[setting] : settings)
@ -209,9 +222,15 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER
run_activity: function(char, ag, action) { try { run_activity: function(char, ag, action) { try {
char.FocusGroup = window.AssetGroupGet(char.AssetFamily, ag) char.FocusGroup = window.AssetGroupGet(char.AssetFamily, ag)
if (!char.FocusGroup) throw "invalid AssetGroup" if (!char.FocusGroup) throw "invalid AssetGroup"
let activity = window.ActivityAllowedForGroup(char, char.FocusGroup.Name).find( a => a.Name === action) let activity = window.ActivityAllowedForGroup(char, char.FocusGroup.Name, true).find( a => a.Name === action)
if (!activity) throw "invalid activity" if (!activity) throw "invalid activity"
if (activity.Name.endsWith("Item")) {
var dict = [{Tag: "NextAsset", AssetName: "SpankingToys"}, {Tag: "FocusAssetGroup", AssetGroupName: ag}, {Tag: "SourceCharacter", Text: window.CharacterNickname(window.Player), MemberNumber: window.Player.MemberNumber}]
dict.push({Tag: "DestinationCharacter", Text: window.CharacterNickname(char), MemberNumber: char.MemberNumber})
window.ServerSend("ChatRoomChat", {Type: "Action", Content: `ActionActivity${activity.Name}`, Dictionary: dict})
} else {
window.ActivityRun(char, activity) window.ActivityRun(char, activity)
}
} finally { } finally {
char.FocusGroup = null char.FocusGroup = null
} }, } },
@ -293,11 +312,11 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER
find_timezone: function(char) { find_timezone: function(char) {
let timezones = this.settings("timezones") let timezones = this.settings("timezones")
if (timezones && timezones[char.MemberNumber]) return(timezones[char.MemberNumber]) if (timezones && timezones[char.MemberNumber]) return(timezones[char.MemberNumber])
let match = char.Description.match(this.RE_TZ) let match = (char.Description) ? char.Description.match(this.RE_TZ) : null
if (match) return(Number.parseInt(match[1])) if (match) return(Number.parseInt(match[1]))
return(null) return(null)
}, },
player_enters_room: function() { player_enters_room: function() { // FIXME: Description may not be ready yet
this.hello() this.hello()
for (let i in window.ChatRoomCharacter) { for (let i in window.ChatRoomCharacter) {
let char = window.ChatRoomCharacter[i] let char = window.ChatRoomCharacter[i]
@ -350,20 +369,28 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER
this.send_activity(message) this.send_activity(message)
} catch (x) { this.report(x) } } }, } catch (x) { this.report(x) } } },
command_do: function(argline, cmdline, args) { try { command_do: function(argline, cmdline, args) { try {
if (args.length < 1) { // 1. verb target
} // 2. arousal for items
if (args.length < 1) return(this.inform("<div>Usage: /do VERB [ZONE] [TARGET]</div><div>Available verbs:</div>" + Object.keys(this.MAP_ACTIONS).join(", ") + "<div>Available zones:</div>" + Object.keys(this.DO_DATA.zones).join(", ")))
let [verb, zone, target] = args
if (!this.DO_DATA.verbs[verb]) throw `unknown verb "${verb}"`
let zones = this.DO_DATA.verbs[verb]
if (1 === Object.keys(zones).length) zone = this.MAP_ZONES[Object.keys(zones)[0]][0]
if (!zone) throw "zone missing"
let ag = this.DO_DATA.zones[zone]
let char = window.Player let char = window.Player
if ("-" !== args[0]) { if (target && ((zones[ag].self.length < 1) || (zones[ag].others.length > 0))) {
let id = Number.parseInt(args[0]) char = this.id2char(target)
let char = this.id2char(id) if (!char) throw "invalid target"
} }
if (!char) throw "invalid member number" let type = (char.MemberNumber === window.Player.MemberNumber) ? "self" : "others"
if (args.length < 2) { let available = window.ActivityAllowedForGroup(char, ag)
} let toy = window.InventoryGet(window.Player, "ItemHands")
if (args.length < 3) { if (toy && toy.Asset.Name === "SpankingToys") available.push(window.AssetAllActivities(char.AssetFamily).find(a => a.Name === window.InventorySpankingToysGetActivity(window.Player)))
} let actions = zones[ag][type]
let ag = args[1] if (!actions) throw `zone "${zone}" invalid for verb "${verb}"`
let action = args[2] let action = actions.find(name => available.find(a => a.Name === name))
if (!action) throw "invalid action"
this.run_activity(char, ag, action) this.run_activity(char, ag, action)
} catch (x) { this.report(x) } }, } catch (x) { this.report(x) } },
loader: function() { loader: function() {
@ -374,6 +401,7 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER
this.RE_ACTIVITY = RegExp(`^${this.CommandsKey}activity `) this.RE_ACTIVITY = RegExp(`^${this.CommandsKey}activity `)
this.PREF_ACTIVITY = `${this.CommandsKey}activity ` this.PREF_ACTIVITY = `${this.CommandsKey}activity `
// Actions // Actions
this.calculate_maps()
this.patch_handheld() this.patch_handheld()
window.Player.MBCHC = {VERSION: this.VERSION} window.Player.MBCHC = {VERSION: this.VERSION}
window.CommandCombine(this.COMMANDS) window.CommandCombine(this.COMMANDS)