Update 'mbchc-local.user.js'
This commit is contained in:
parent
6663c2eede
commit
e6a35024c8
|
@ -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: /^@@/,
|
||||
RE_ACT_CHARS: /^<(\d+)?:(\d+)?>/,
|
||||
RE_TZ: /(?:GMT|UTC)([+-]\d\d?)/,
|
||||
RE_TZ: /(?:GMT|UTC)([+-]\d\d?)/i,
|
||||
RGB_MUTE: "#6c2132",
|
||||
RGB_POLLY: "#81b1e7",
|
||||
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: "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) {
|
||||
let settings = window.Player.OnlineSettings.MBCHC || {}
|
||||
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 {
|
||||
char.FocusGroup = window.AssetGroupGet(char.AssetFamily, ag)
|
||||
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"
|
||||
window.ActivityRun(char, 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)
|
||||
}
|
||||
} finally {
|
||||
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) {
|
||||
let timezones = this.settings("timezones")
|
||||
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]))
|
||||
return(null)
|
||||
},
|
||||
player_enters_room: function() {
|
||||
player_enters_room: function() { // FIXME: Description may not be ready yet
|
||||
this.hello()
|
||||
for (let i in window.ChatRoomCharacter) {
|
||||
let char = window.ChatRoomCharacter[i]
|
||||
|
@ -346,25 +365,33 @@ var bcModSdk=function(){"use strict";const o="1.0.2";function e(o){alert("Mod ER
|
|||
}
|
||||
} catch (x) { this.report(x) } },
|
||||
command_activity: function(argline, cmdline, args) { if (!this.empty(argline)) { try {
|
||||
let message = this.normalise_message(cmdline.replace(this.RE_ACTIVITY, ''), {trim: true, dot: true, up: true})
|
||||
this.send_activity(message)
|
||||
let message = this.normalise_message(cmdline.replace(this.RE_ACTIVITY, ''), {trim: true, dot: true, up: true})
|
||||
this.send_activity(message)
|
||||
} catch (x) { this.report(x) } } },
|
||||
command_do: function(argline, cmdline, args) { try {
|
||||
if (args.length < 1) {
|
||||
}
|
||||
let char = window.Player
|
||||
if ("-" !== args[0]) {
|
||||
let id = Number.parseInt(args[0])
|
||||
let char = this.id2char(id)
|
||||
}
|
||||
if (!char) throw "invalid member number"
|
||||
if (args.length < 2) {
|
||||
}
|
||||
if (args.length < 3) {
|
||||
}
|
||||
let ag = args[1]
|
||||
let action = args[2]
|
||||
this.run_activity(char, ag, action)
|
||||
// 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
|
||||
if (target && ((zones[ag].self.length < 1) || (zones[ag].others.length > 0))) {
|
||||
char = this.id2char(target)
|
||||
if (!char) throw "invalid target"
|
||||
}
|
||||
let type = (char.MemberNumber === window.Player.MemberNumber) ? "self" : "others"
|
||||
let available = window.ActivityAllowedForGroup(char, ag)
|
||||
let toy = window.InventoryGet(window.Player, "ItemHands")
|
||||
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]
|
||||
if (!actions) throw `zone "${zone}" invalid for verb "${verb}"`
|
||||
let action = actions.find(name => available.find(a => a.Name === name))
|
||||
if (!action) throw "invalid action"
|
||||
this.run_activity(char, ag, action)
|
||||
} catch (x) { this.report(x) } },
|
||||
loader: function() {
|
||||
if (this.LOADED) return //FIXME: unhook if hooked, no need to call this every time
|
||||
|
@ -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.PREF_ACTIVITY = `${this.CommandsKey}activity `
|
||||
// Actions
|
||||
this.calculate_maps()
|
||||
this.patch_handheld()
|
||||
window.Player.MBCHC = {VERSION: this.VERSION}
|
||||
window.CommandCombine(this.COMMANDS)
|
||||
|
|
Loading…
Reference in New Issue
Block a user