Initial commit
This commit is contained in:
544
scripts/phones/phones_commands.dsc
Normal file
544
scripts/phones/phones_commands.dsc
Normal file
@@ -0,0 +1,544 @@
|
||||
## CALL
|
||||
phones_commands_phonecall:
|
||||
debug: false
|
||||
type: command
|
||||
name: phonecall
|
||||
aliases:
|
||||
- call
|
||||
description: Call using a phone!
|
||||
usage: /phonecall (number/contact/message)
|
||||
permission: phones.command.phonecall
|
||||
tab complete:
|
||||
- if <context.server>:
|
||||
- determine <list[]>
|
||||
- if <player.has_flag[phones_call]>:
|
||||
- determine <list[<<>message<>>]>
|
||||
- determine <player.flag[phones].get[contacts].keys.if_null[<list[]>]>
|
||||
script:
|
||||
# checks...
|
||||
- if <context.source_type> != player:
|
||||
- narrate "<&c>Please run this command as a player."
|
||||
- stop
|
||||
- define incall <player.has_flag[phones_call_clickable].not.and[<player.has_flag[phones_call]>]>
|
||||
# mid call?
|
||||
- if !<[incall]>:
|
||||
# waiting call?
|
||||
- if <player.has_flag[phones_call_clickable]>:
|
||||
- narrate "<&c>Please wait for the call to be accepted, or unequip to cancel the call."
|
||||
- stop
|
||||
# no
|
||||
- if <context.args.size> < 1:
|
||||
- narrate "<&c>Invalid use. First, call a number. Please try /<context.alias> (number/contact)."
|
||||
- stop
|
||||
# definitions
|
||||
- define receiver <context.args.get[1]>
|
||||
- define target <proc[phones_get_owner].context[<player>|<[receiver]>]>
|
||||
- if !<player.item_in_hand.flag[phones].if_null[false]>:
|
||||
- narrate "<&c>Please hold a phone in your hand, and ensure it is powered on."
|
||||
- stop
|
||||
# invalid number/contact
|
||||
- if <[target]> == null:
|
||||
- narrate "<&c>Invalid phone number or contact <[receiver]>. Please try again."
|
||||
- stop
|
||||
# lmao
|
||||
- if <player> == <[target]>:
|
||||
- narrate "<&c>You can't call yourself!"
|
||||
- stop
|
||||
# blocked
|
||||
- if <player.flag[phones].get[blocked].contains[<[target]>].if_null[false]>:
|
||||
- narrate "<&c>The receiver is currently in your blocked numbers."
|
||||
- stop
|
||||
- if <[target].flag[phones].get[blocked].contains[<player>].if_null[false]>:
|
||||
- narrate "<&c>The receiver is unable to be contacted at this time. Try again later."
|
||||
- stop
|
||||
# not online/no phone/phone is off/etc...
|
||||
- if !<proc[phones_has_phone].context[<[target]>]>:
|
||||
- narrate "<&c>The receiver is unable to be contacted at this time. Try again later."
|
||||
- stop
|
||||
# mid call...
|
||||
- if <[target].has_flag[phones_call]>:
|
||||
- narrate "<&c>The receiver is currently busy. Try again later."
|
||||
- stop
|
||||
# call...
|
||||
- define relative <proc[phones_relative_name].context[<[target]>|<player>]>
|
||||
- define player <player>
|
||||
# if accepted, go in
|
||||
- clickable save:accept until:30s:
|
||||
- if !<[target].item_in_hand.flag[phones].if_null[false]>:
|
||||
- narrate targets:<[target]> "<&c>Please hold a phone before accepting the call, and ensure it is powered on."
|
||||
- stop
|
||||
- nbs stop targets:<[target]>
|
||||
- clickable cancel:<[player].flag[phones_call_clickable]>
|
||||
- flag <[target]> phones_call:<[player]>
|
||||
- flag <[player]> phones_call:<[target]>
|
||||
- flag <[player]> phones_call_clickable:!
|
||||
- flag <[target]> phones_is_maybe_called:!
|
||||
- narrate targets:<[player]> "<&2>*** <&a><[receiver]> <&a>picked up the phone."
|
||||
- narrate targets:<[target]> "<&2>*** <&a>You picked up the phone."
|
||||
- define callgroup <list[<[player]>|<[target]>]>
|
||||
- narrate targets:<[callgroup]> <&f>
|
||||
- narrate targets:<[callgroup]> "<&7>Talk using <&e>/call (message)<&7>."
|
||||
- narrate targets:<[callgroup]> "<&e>Unequip <&7>your phone to <&c>end <&7>the call."
|
||||
- narrate targets:<[callgroup]> <&f>
|
||||
#
|
||||
# before accepted
|
||||
- if !<[target].has_flag[phones_is_maybe_called]>:
|
||||
- nbs file:data/phones/songs/<[target].flag[phones].get[ringtone].if_null[Bad Apple]> play targets:<[target]>
|
||||
- narrate targets:<[target]> "<&6>*** <&e>You're being called by <&e><[relative]><&7>."
|
||||
- narrate targets:<[target]> "<&hover[<&a>Click to accept call from <[relative]>...]><element[<&a><&l>[ ACCEPT ]].on_click[<entry[accept].command>]><&end_hover>"
|
||||
# wait...
|
||||
- flag <player> phones_call:<[target]>
|
||||
- flag <player> phones_call_clickable:<entry[accept].id>
|
||||
- flag <[target]> phones_is_maybe_called:true expire:30s
|
||||
- narrate "<&6>*** <&e>You started to ring <&7><[receiver]>"
|
||||
- narrate "<&7>Unequip your phone to cancel the call."
|
||||
- else:
|
||||
# yes
|
||||
- if <context.args.size> < 1:
|
||||
- narrate "<&c>Invalid use. You are mid-call - please try /<context.alias> (message)."
|
||||
- narrate "<&7>Note: you can unequip the phone to end the current call."
|
||||
- stop
|
||||
# definitions
|
||||
- define target <player.flag[phones_call]>
|
||||
- define message <context.args.get[1].to[last].space_separated>
|
||||
# speak...
|
||||
- define final "<&6>[<&7>P<&6>] <&f><placeholder[essentials_nickname].player[<player>]> <proc[chat_special_group].context[<player>]><proc[chat_roles_group].context[<player>]> <proc[character_get_name].context[<player>]> <&f>says <&dq><[message]><&f><&dq> over the phone."
|
||||
- narrate targets:<player.location.find_players_within[10].include[<[target]>].deduplicate> <[final]>
|
||||
|
||||
## callw, cally use similar routines
|
||||
phones_command_call_common_routine:
|
||||
debug: false
|
||||
type: task
|
||||
script:
|
||||
# checks...
|
||||
- if <context.source_type> != player:
|
||||
- narrate "<&c>Please run this command as a player."
|
||||
- define continue false
|
||||
- stop
|
||||
- define incall <player.has_flag[phones_call_clickable].not.and[<player.has_flag[phones_call]>]>
|
||||
# mid call?
|
||||
- if !<[incall]>:
|
||||
# waiting call?
|
||||
- if <player.has_flag[phones_call_clickable]>:
|
||||
- narrate "<&c>Please wait for the call to be accepted, or unequip to cancel the call."
|
||||
- define continue false
|
||||
- stop
|
||||
# no
|
||||
- narrate "<&c>Invalid use. First, call a number. Please try /call (number/contact)."
|
||||
- define continue false
|
||||
- else:
|
||||
# yes
|
||||
- if <context.args.size> < 1:
|
||||
- narrate "<&c>Invalid use. You are mid-call - please try /<context.alias> (message)."
|
||||
- narrate "<&7>Note: you can unequip the phone to end the current call."
|
||||
- define continue false
|
||||
- stop
|
||||
# definitions
|
||||
- define target <player.flag[phones_call]>
|
||||
- define message <context.args.get[1].to[last].space_separated>
|
||||
|
||||
phones_command_phonecallwhisper:
|
||||
debug: false
|
||||
type: command
|
||||
name: phonecallwhisper
|
||||
aliases:
|
||||
- callwhisper
|
||||
- callw
|
||||
description: Whisper over the phone while in a call.
|
||||
usage: /phonecallwhisper (message)
|
||||
permission: phones.command.phonecallwhisper
|
||||
tab complete:
|
||||
- if <context.server>:
|
||||
- determine <list[]>
|
||||
- if <player.has_flag[phones_call]>:
|
||||
- determine <list[<<>message<>>]>
|
||||
- determine <list[]>
|
||||
script:
|
||||
- define continue true
|
||||
- inject phones_command_call_common_routine
|
||||
- if !<[continue]>:
|
||||
- stop
|
||||
# speak...
|
||||
- define final "<&6>[<&7>P<&6>] <&f><placeholder[essentials_nickname].player[<player>]> <proc[chat_special_group].context[<player>]><proc[chat_roles_group].context[<player>]> <proc[character_get_name].context[<player>]> <&8>whispers <&6><&sq><&7><[message]><&6><&sq> <&8>over the phone."
|
||||
- narrate targets:<player.location.find_players_within[3].include[<[target]>].deduplicate> <[final]>
|
||||
|
||||
phones_command_phonecallyell:
|
||||
debug: false
|
||||
type: command
|
||||
name: phonecallyell
|
||||
aliases:
|
||||
- callyell
|
||||
- cally
|
||||
description: Yell over the phone while in a call.
|
||||
usage: /phonecallyell (message)
|
||||
permission: phones.command.phonecallyell
|
||||
tab complete:
|
||||
- if <context.server>:
|
||||
- determine <list[]>
|
||||
- if <player.has_flag[phones_call]>:
|
||||
- determine <list[<<>message<>>]>
|
||||
- determine <list[]>
|
||||
script:
|
||||
- define continue true
|
||||
- inject phones_command_call_common_routine
|
||||
- if !<[continue]>:
|
||||
- stop
|
||||
# speak...
|
||||
- define final "<&6>[<&7>P<&6>] <&f><placeholder[essentials_nickname].player[<player>]> <proc[chat_special_group].context[<player>]><proc[chat_roles_group].context[<player>]> <proc[character_get_name].context[<player>]> <&6>yells <&sq><&f><[message].to_uppercase><&6><&sq> over the phone."
|
||||
- narrate targets:<player.location.find_players_within[25].include[<[target]>].deduplicate> <[final]>
|
||||
|
||||
## langcall, langcallw, langcally use similar routines
|
||||
phones_command_call_language_common_routine:
|
||||
debug: false
|
||||
type: task
|
||||
script:
|
||||
# checks...
|
||||
- if <context.source_type> != player:
|
||||
- narrate "<&c>Please run this command as a player."
|
||||
- define continue false
|
||||
- stop
|
||||
- define incall <player.has_flag[phones_call_clickable].not.and[<player.has_flag[phones_call]>]>
|
||||
# mid call?
|
||||
- if !<[incall]>:
|
||||
# waiting call?
|
||||
- if <player.has_flag[phones_call_clickable]>:
|
||||
- narrate "<&c>Please wait for the call to be accepted, or unequip to cancel the call."
|
||||
- define continue false
|
||||
- stop
|
||||
# no
|
||||
- narrate "<&c>Invalid use. First, call a number. Please try /call (number/contact)."
|
||||
- define continue false
|
||||
- else:
|
||||
# yes
|
||||
- if <context.args.size> < 2:
|
||||
- narrate "<&c>Invalid use. You are mid-call - please try /<context.alias> (language) (message)."
|
||||
- narrate "<&7>Note: you can unequip the phone to end the current call."
|
||||
- define continue false
|
||||
- stop
|
||||
# definitions
|
||||
- define target <player.flag[phones_call]>
|
||||
- define language <context.args.get[1].to_sentence_case>
|
||||
- if !<player.flag[chat_languages].contains[<[language]>].if_null[false]>:
|
||||
- narrate "<&c>Your character cannot speak in <[language]>."
|
||||
- define continue false
|
||||
- stop
|
||||
- define message <context.args.get[2].to[last].space_separated>
|
||||
|
||||
phones_command_phonelangcall:
|
||||
debug: false
|
||||
type: command
|
||||
name: phonelangcall
|
||||
aliases:
|
||||
- langcall
|
||||
description: Speak over the phone in a different language.
|
||||
usage: /phonelangcall (language) (message)
|
||||
permission: phones.command.phonelangcall
|
||||
tab complete:
|
||||
- if <context.server>:
|
||||
- determine <list[]>
|
||||
- if <player.has_flag[phones_call]>:
|
||||
- if <context.args.size> <= 0:
|
||||
- determine <player.flag[chat_languages].if_null[<list[]>]>
|
||||
- if <context.args.size> <= 1:
|
||||
- determine <list[<<>message<>>]>
|
||||
- determine <list[]>
|
||||
script:
|
||||
- define continue true
|
||||
- inject phones_command_call_language_common_routine
|
||||
- if !<[continue]>:
|
||||
- stop
|
||||
# speak...
|
||||
- define final_known "<&6>[<&7>P<&6>] <&f><placeholder[essentials_nickname].player[<player>]> <proc[chat_special_group].context[<player>]><proc[chat_roles_group].context[<player>]> <proc[character_get_name].context[<player>]> <&f>says <&dq><&o><[message]><&f><&dq> in <[language]> over the phone."
|
||||
- define final_unknown "<&6>[<&7>P<&6>] <&f><placeholder[essentials_nickname].player[<player>]> <proc[chat_special_group].context[<player>]><proc[chat_roles_group].context[<player>]> <proc[character_get_name].context[<player>]> <&f>says something in <[language]> over the phone."
|
||||
- define all <player.location.find_players_within[10].include[<[target]>].deduplicate>
|
||||
- define speakers <[all].filter_tag[<[filter_value].flag[chat_languages].contains[<[language]>].if_null[false]>]>
|
||||
- define others <[all].exclude[<[speakers]>]>
|
||||
- narrate targets:<[speakers]> <[final_known]>
|
||||
- narrate targets:<[others]> <[final_unknown]>
|
||||
|
||||
phones_command_phonelangcallwhisper:
|
||||
debug: false
|
||||
type: command
|
||||
name: phonelangcallwhisper
|
||||
aliases:
|
||||
- langcallwhisper
|
||||
- langcallw
|
||||
description: Whisper over the phone in a different language.
|
||||
usage: /phonelangcallwhisper (language) (message)
|
||||
permission: phones.command.phonelangcallwhisper
|
||||
tab complete:
|
||||
- if <context.server>:
|
||||
- determine <list[]>
|
||||
- if <player.has_flag[phones_call]>:
|
||||
- if <context.args.size> <= 0:
|
||||
- determine <player.flag[chat_languages].if_null[<list[]>]>
|
||||
- if <context.args.size> <= 1:
|
||||
- determine <list[<<>message<>>]>
|
||||
- determine <list[]>
|
||||
script:
|
||||
- define continue true
|
||||
- inject phones_command_call_language_common_routine
|
||||
- if !<[continue]>:
|
||||
- stop
|
||||
# speak...
|
||||
- define final_known "<&6>[<&7>P<&6>] <&f><placeholder[essentials_nickname].player[<player>]> <proc[chat_special_group].context[<player>]><proc[chat_roles_group].context[<player>]> <proc[character_get_name].context[<player>]> <&f>whispers <&dq><&o><[message]><&f><&dq> in <[language]> over the phone."
|
||||
- define final_unknown "<&6>[<&7>P<&6>] <&f><placeholder[essentials_nickname].player[<player>]> <proc[chat_special_group].context[<player>]><proc[chat_roles_group].context[<player>]> <proc[character_get_name].context[<player>]> <&f>whispers something in <[language]> over the phone."
|
||||
- define all <player.location.find_players_within[3].include[<[target]>].deduplicate>
|
||||
- define speakers <[all].filter_tag[<[filter_value].flag[chat_languages].contains[<[language]>].if_null[false]>]>
|
||||
- define others <[all].exclude[<[speakers]>]>
|
||||
- narrate targets:<[speakers]> <[final_known]>
|
||||
- narrate targets:<[others]> <[final_unknown]>
|
||||
|
||||
phones_command_phonelangcallyell:
|
||||
debug: false
|
||||
type: command
|
||||
name: phonelangcallyell
|
||||
aliases:
|
||||
- langcallyell
|
||||
- langcally
|
||||
description: Yell over the phone in a different language.
|
||||
usage: /phonelangcallyell (language) (message)
|
||||
permission: phones.command.phonelangcallyell
|
||||
tab complete:
|
||||
- if <context.server>:
|
||||
- determine <list[]>
|
||||
- if <player.has_flag[phones_call]>:
|
||||
- if <context.args.size> <= 1:
|
||||
- determine <player.flag[chat_languages].if_null[<list[]>]>
|
||||
- if <context.args.size> <= 2:
|
||||
- determine <list[<<>message<>>]>
|
||||
- determine <list[]>
|
||||
script:
|
||||
- define continue true
|
||||
- inject phones_command_call_language_common_routine
|
||||
- if !<[continue]>:
|
||||
- stop
|
||||
# speak...
|
||||
- define final_known "<&6>[<&7>P<&6>] <&f><placeholder[essentials_nickname].player[<player>]> <proc[chat_special_group].context[<player>]><proc[chat_roles_group].context[<player>]> <proc[character_get_name].context[<player>]> <&f>yells <&dq><&o><[message].to_uppercase><&f><&dq> in <[language]> over the phone."
|
||||
- define final_unknown "<&6>[<&7>P<&6>] <&f><placeholder[essentials_nickname].player[<player>]> <proc[chat_special_group].context[<player>]><proc[chat_roles_group].context[<player>]> <proc[character_get_name].context[<player>]> <&f>yells something in <[language]> over the phone."
|
||||
- define all <player.location.find_players_within[25].include[<[target]>].deduplicate>
|
||||
- define speakers <[all].filter_tag[<[filter_value].flag[chat_languages].contains[<[language]>].if_null[false]>]>
|
||||
- define others <[all].exclude[<[speakers]>]>
|
||||
- narrate targets:<[speakers]> <[final_known]>
|
||||
- narrate targets:<[others]> <[final_unknown]>
|
||||
|
||||
## PHONE UTILITIES
|
||||
phones_commands_phonenumber:
|
||||
debug: false
|
||||
type: command
|
||||
name: phonenumber
|
||||
aliases:
|
||||
- number
|
||||
- pn
|
||||
description: View your phone number.
|
||||
usage: /phonenumber
|
||||
permission: phones.command.phonenumber
|
||||
script:
|
||||
# checks...
|
||||
- if <context.source_type> != player:
|
||||
- narrate "<&c>Please run this command as a player."
|
||||
- stop
|
||||
# ok
|
||||
- define number <player.flag[phones].get[number]>
|
||||
- narrate format:formats_prefix <proc[phones_nicer_format].context[<[number]>]>
|
||||
|
||||
## PHONE CONTACTS
|
||||
phones_commands_phonecontacts:
|
||||
debug: false
|
||||
type: command
|
||||
name: phonecontacts
|
||||
aliases:
|
||||
- contacts
|
||||
description: View your contacts.
|
||||
usage: /phonecontacts (page)
|
||||
permission: phones.command.contacts
|
||||
tab completions:
|
||||
1: <<>page<>>
|
||||
script:
|
||||
- if <context.source_type> != player:
|
||||
- narrate "<&c>Please run this command as a player."
|
||||
- stop
|
||||
- define contacts <player.flag[phones].get[contacts].if_null[<map[]>]>
|
||||
- if <[contacts].is_empty>:
|
||||
- run phones_contacts_print def.player:<player> def.page:0
|
||||
- stop
|
||||
- define page 0
|
||||
- if <context.args.size> >= 1:
|
||||
- define page <context.args.get[1]>
|
||||
- if !<[page].is_integer>:
|
||||
- narrate "<&c>The page must be an integer between 1 and <[contacts].size.sub[1].div_int[6].add[1]>."
|
||||
- stop
|
||||
- define page <[page].sub[1]>
|
||||
- if <[page]> < 0 || <[page]> > <[contacts].size.sub[1].div_int[6]>:
|
||||
- narrate "<&c>The page must be an integer between 1 and <[contacts].size.sub[1].div_int[6].add[1]>."
|
||||
- stop
|
||||
- run phones_contacts_print def.player:<player> def.page:<[page]>
|
||||
|
||||
phones_commands_phoneaddcontact:
|
||||
debug: false
|
||||
type: command
|
||||
name: phoneaddcontact
|
||||
aliases:
|
||||
- addcontact
|
||||
- ac
|
||||
description: Add a contact.
|
||||
usage: /phoneaddcontact (number) (name)
|
||||
permission: phones.command.phoneaddcontact
|
||||
tab completions:
|
||||
1: <<>number<>>
|
||||
2: <<>unique name<>>
|
||||
script:
|
||||
- if <context.source_type> != player:
|
||||
- narrate "<&c>Please run this command as a player."
|
||||
- stop
|
||||
- if <context.args.size> < 2:
|
||||
- narrate "<&c>Invalid use. Please try /<context.alias> (number) (name)."
|
||||
- stop
|
||||
- define number <context.args.get[1].replace[-].with[]>
|
||||
- define isnumber <[number].regex_matches[^[0-9]+$]>
|
||||
- if !<[isnumber]> || !<server.flag[phones].contains[<[number]>]>:
|
||||
- narrate "<&c>Number <context.args.get[1]> <&c>is not a valid number. Did you type it correctly?"
|
||||
- stop
|
||||
- define name <context.args.get[2].to_lowercase>
|
||||
- define isvalid <[name].regex_matches[^[a-z_]+$]>
|
||||
- if !<[isvalid]>:
|
||||
- narrate "<&c>Name <context.args.get[2]> <&c>is invalid. Contact names must only contain alphabetical characters and/or the underscore (_) character."
|
||||
- stop
|
||||
- if <player.flag[phones].get[contacts].contains[<[name]>].if_null[false]>:
|
||||
- narrate "<&c>You already have a contact named <[name]><&c>. Please pick a new name or manage your contacts from your home screen."
|
||||
- stop
|
||||
- define target <server.flag[phones].get[<[number]>]>
|
||||
- if <[target]> == <player>:
|
||||
- narrate "<&c>You can't add yourself as a contact!"
|
||||
- stop
|
||||
- if <player.flag[phones].get[contacts].values.contains[<[target]>].if_null[false]>:
|
||||
- define found
|
||||
- foreach <player.flag[phones].get[contacts]> key:whoname as:who:
|
||||
- if <[who]> == <[target]>:
|
||||
- define found <[whoname]>
|
||||
- foreach stop
|
||||
- narrate "<&c>You already have this contact added, using the contact name: <[found]><&c>."
|
||||
- stop
|
||||
- define contacts <player.flag[phones].get[contacts].if_null[<map[]>]>
|
||||
- define contacts <[contacts].with[<[name]>].as[<[target]>]>
|
||||
- flag <player> phones:<player.flag[phones].with[contacts].as[<[contacts]>]>
|
||||
- narrate format:formats_prefix "Added new contact <[name]> <&7>, targetting phone number <[number]>."
|
||||
|
||||
phones_commands_phoneremovecontact:
|
||||
debug: false
|
||||
type: command
|
||||
name: phoneremovecontact
|
||||
aliases:
|
||||
- removecontact
|
||||
- rc
|
||||
description: Remove a contact.
|
||||
usage: /phoneremovecontact (number) (name)
|
||||
permission: phones.command.phoneremovecontact
|
||||
tab completions:
|
||||
1: <player.flag[phones].get[contacts].keys.if_null[<list[]>]>
|
||||
script:
|
||||
- if <context.source_type> != player:
|
||||
- narrate "<&c>Please run this command as a player."
|
||||
- stop
|
||||
- if <context.args.size> < 1:
|
||||
- narrate "<&c>Invalid use. Please try /<context.alias> (name)."
|
||||
- stop
|
||||
- define name <context.args.get[1].to_lowercase>
|
||||
- if !<player.flag[phones].get[contacts].contains[<[name]>].if_null[false]>:
|
||||
- narrate "<&c>You do not have a contact named <[name]>."
|
||||
- stop
|
||||
- define contacts <player.flag[phones].get[contacts].if_null[<map[]>]>
|
||||
- define contacts <[contacts].exclude[<[name]>]>
|
||||
- flag <player> phones:<player.flag[phones].with[contacts].as[<[contacts]>]>
|
||||
- narrate format:formats_prefix "Removed contact <&e><[name]><&7>."
|
||||
|
||||
## TEXT MESSAGES
|
||||
phones_commands_phonetext:
|
||||
debug: false
|
||||
type: command
|
||||
name: phonetext
|
||||
aliases:
|
||||
- text
|
||||
description: Text a number or a contact!
|
||||
usage: /phonetext (number/contact) (message)
|
||||
permission: phones.command.phonetext
|
||||
tab completions:
|
||||
1: <player.flag[phones].get[contacts].keys.if_null[<list[]>]>
|
||||
2: <<>message<>>
|
||||
script:
|
||||
# checks...
|
||||
- if <context.source_type> != player:
|
||||
- narrate "<&c>Please run this command as a player."
|
||||
- stop
|
||||
- if <context.args.size> < 2:
|
||||
- narrate "<&c>Invalid use. Please try /<context.alias> (number/contact) (message)."
|
||||
- stop
|
||||
# definitions
|
||||
- define receiver <context.args.get[1].replace[-].with[]>
|
||||
- define message <context.args.get[2].to[last].space_separated>
|
||||
- define target <proc[phones_get_owner].context[<player>|<[receiver]>]>
|
||||
# no phone
|
||||
- if !<player.item_in_hand.flag[phones].if_null[false]>:
|
||||
- narrate "<&c>Please hold a phone in your hand, and ensure it is powered on."
|
||||
- stop
|
||||
# invalid number/contact
|
||||
- if <[target]> == null:
|
||||
- narrate "<&c>Invalid phone number or contact <&e><[receiver]><&c>. Please try again."
|
||||
- stop
|
||||
# lmao
|
||||
- if <player> == <[target]>:
|
||||
- narrate "<&c>You can't text yourself!"
|
||||
- stop
|
||||
# blocked
|
||||
- if <player.flag[phones].get[blocked].contains[<[target]>].if_null[false]>:
|
||||
- narrate "<&c>The receiver is currently in your blocked numbers."
|
||||
- stop
|
||||
- if <[target].flag[phones].get[blocked].contains[<player>].if_null[false]>:
|
||||
- narrate "<&c>The receiver is unable to be contacted at this time. Try again later."
|
||||
- stop
|
||||
# send text...
|
||||
- run phones_texts_store def.player:<player> def.target:<[target]> def.contents:<[message]>
|
||||
|
||||
## BLOCKED
|
||||
phones_commands_phoneblock:
|
||||
debug: false
|
||||
type: command
|
||||
name: phoneblock
|
||||
aliases:
|
||||
- phoneunblock
|
||||
- phblock
|
||||
- phunblock
|
||||
description: Add a contact.
|
||||
usage: /phoneblock (number))
|
||||
permission: phones.command.phoneblock
|
||||
tab completions:
|
||||
1: <list[<<>number<>>].include[<player.flag[phones].get[blocked].parse_tag[<[parse_value].flag[phones].get[number]>].if_null[<list[]>]>]>
|
||||
script:
|
||||
- if <context.source_type> != player:
|
||||
- narrate "<&c>Please run this command as a player."
|
||||
- stop
|
||||
- if <context.args.size> < 1:
|
||||
- narrate "<&c>Invalid use. Please try /<context.alias> (number)."
|
||||
- stop
|
||||
#
|
||||
- define number <context.args.get[1].replace[-].with[]>
|
||||
- define isnumber <[number].regex_matches[^[0-9]+$]>
|
||||
- if !<[isnumber]> || !<server.flag[phones].contains[<[number]>]>:
|
||||
- narrate "<&c>Number <context.args.get[1]> <&c>is not a valid number. Did you type it correctly?"
|
||||
- stop
|
||||
#
|
||||
- define target <server.flag[phones].get[<[number]>]>
|
||||
- if <[target]> == <player>:
|
||||
- narrate "<&c>You can't block your own phone number!"
|
||||
- stop
|
||||
#
|
||||
- if !<player.flag[phones].get[blocked].contains[<[target]>].if_null[false]>:
|
||||
- define blocked <player.flag[phones].get[blocked].if_null[<list[]>]>
|
||||
- define blocked <[blocked].include[<[target]>]>
|
||||
- flag <player> phones:<player.flag[phones].with[blocked].as[<[blocked]>]>
|
||||
- narrate format:formats_prefix "<&c>Blocked <&7>phone number <&e><[number]><&7>."
|
||||
- else:
|
||||
- define blocked <player.flag[phones].get[blocked].if_null[<list[]>]>
|
||||
- define blocked <[blocked].exclude[<[target]>]>
|
||||
- flag <player> phones:<player.flag[phones].with[blocked].as[<[blocked]>]>
|
||||
- narrate format:formats_prefix "<&a>Unblocked <&7>phone number <&e><[number]><&7>."
|
||||
455
scripts/phones/phones_tasks.dsc
Normal file
455
scripts/phones/phones_tasks.dsc
Normal file
@@ -0,0 +1,455 @@
|
||||
####
|
||||
## GENERAL STUFF
|
||||
####
|
||||
|
||||
phones_get_owner:
|
||||
debug: false
|
||||
type: procedure
|
||||
definitions: player|receiver
|
||||
script:
|
||||
- define receiver <[receiver].replace[(].with[].replace[)].with[].replace[-].with[]>
|
||||
- define isnumber <[receiver].regex_matches[^[0-9]+$]>
|
||||
- define target null
|
||||
- if <[isnumber]>:
|
||||
- define target <server.flag[phones].get[<[receiver]>].if_null[null]>
|
||||
- else:
|
||||
- define target <[player].flag[phones].get[contacts].get[<[receiver]>].if_null[null]>
|
||||
- determine <[target]>
|
||||
|
||||
phones_has_phone:
|
||||
debug: false
|
||||
type: procedure
|
||||
definitions: player
|
||||
script:
|
||||
- if !<[player].is_online>:
|
||||
- determine false
|
||||
- foreach <[player].inventory.map_slots> key:slot as:item:
|
||||
- if <[item].flag[phones].if_null[false]>:
|
||||
- determine true
|
||||
- determine false
|
||||
|
||||
phones_relative_name:
|
||||
debug: false
|
||||
type: procedure
|
||||
definitions: player|who
|
||||
script:
|
||||
- if <[player].flag[phones].get[contacts].values.contains[<[who]>].if_null[false]>:
|
||||
- determine <[player].flag[phones].get[contacts].filter_tag[<[filter_value].equals[<[who]>]>].keys.get[1]>
|
||||
- determine <[who].flag[phones].get[number]>
|
||||
|
||||
phones_clean_message:
|
||||
debug: false
|
||||
type: procedure
|
||||
definitions: message
|
||||
script:
|
||||
- define clean <empty>
|
||||
# remove channel marker
|
||||
- if <[message].starts_with[#]>:
|
||||
- define message <[message].substring[3]>
|
||||
# format actions
|
||||
- foreach <[message].split[*]> as:section:
|
||||
- if <[section].trim.length> == 0:
|
||||
- foreach next
|
||||
- if <[loop_index].is_odd>:
|
||||
- define clean "<[clean]> <&f><&dq><[section].trim><&f><&dq>"
|
||||
- else:
|
||||
- define clean "<[clean]> <&e><[section].trim>"
|
||||
# good
|
||||
- determine <[clean].trim>
|
||||
|
||||
|
||||
phones_get_contact_state:
|
||||
debug: false
|
||||
type: procedure
|
||||
definitions: player|target
|
||||
script:
|
||||
- if <[target].flag[phones].get[contacts].values.contains[<[player]>].if_null[false]>:
|
||||
- if <[target].is_online>:
|
||||
- if <proc[phones_has_phone].context[<[target]>]>:
|
||||
- determine online
|
||||
- determine offline
|
||||
- determine invisible
|
||||
|
||||
phones_nicer_format:
|
||||
debug: false
|
||||
type: procedure
|
||||
definitions: number
|
||||
script:
|
||||
- determine "<&7>(+81) <&e>(<[number].substring[1,3]>)-<[number].substring[4,6]>-<[number].substring[7,10]>"
|
||||
|
||||
phones_get_number:
|
||||
debug: false
|
||||
type: procedure
|
||||
definitions: player
|
||||
script:
|
||||
- determine <[player].flag[phones].get[number]>
|
||||
|
||||
####
|
||||
## GUIS
|
||||
####
|
||||
|
||||
phones_gui_home:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player
|
||||
script:
|
||||
- define inventory "<inventory[generic[size=54;title=<&f>邑邑邑邑鄀<&0>邒]]>"
|
||||
# settings
|
||||
- define settings <item[name_tag]>
|
||||
- adjust def:settings "display:<&6>Settings"
|
||||
- inventory set destination:<[inventory]> slot:13 origin:<[settings]>
|
||||
# contacts
|
||||
- define contacts <item[book]>
|
||||
- adjust def:contacts "display:<&6>Contacts"
|
||||
- inventory set destination:<[inventory]> slot:14 origin:<[contacts]>
|
||||
# texts
|
||||
- define texts <item[writable_book]>
|
||||
- adjust def:texts "display:<&6>Messages"
|
||||
- define notifications_textmessages <[player].flag[phones_notifications].get[textmessages].values.size.if_null[null]>
|
||||
- if <[notifications_textmessages]> != null && <[notifications_textmessages]> != 0:
|
||||
- if <[notifications_textmessages]> > 99:
|
||||
- define notifications_textmessages 99+
|
||||
- adjust texts lore:<list[<&c>● <&7>You have <&6><[notifications_textmessages]> <&7>unread|<&7>text conversations.]>
|
||||
- inventory set destination:<[inventory]> slot:15 origin:<[texts]>
|
||||
# music
|
||||
- define music <item[jukebox]>
|
||||
- adjust def:music "display:<&6>Blocky Music <&3>♫"
|
||||
- adjust def:music "lore:<&7>(music from <&e>noteblock.world<&7>)"
|
||||
- inventory set destination:<[inventory]> slot:22 origin:<[music]>
|
||||
# number
|
||||
- define number <item[player_head]>
|
||||
- adjust def:number "display:<&6>Your Number"
|
||||
- adjust def:number lore:<list[<&e><proc[phones_nicer_format].context[<[player].flag[phones].get[number]>]>||<&7>You may also view your number|<&7>using /phonenumber.]>
|
||||
- flag <[number]> phones_target_skull_uuid:<[player].uuid>
|
||||
- inventory set destination:<[inventory]> slot:41 origin:<[number]>
|
||||
#
|
||||
- inventory open player:<[player]> destination:<[inventory]>
|
||||
- run phones_target_skulls_update def.player:<[player]>
|
||||
|
||||
# ---
|
||||
# --- contacts related
|
||||
# ---
|
||||
|
||||
phones_contacts_print:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player|page
|
||||
script:
|
||||
- define contacts <[player].flag[phones].get[contacts].if_null[<map[]>]>
|
||||
- if <[contacts].is_empty>:
|
||||
- narrate targets:<[player]> format:formats_prefix "You don't have any contacts."
|
||||
- stop
|
||||
- define contactslist <[contacts].keys.get[<[page].mul[6].add[1]>].to[<[page].add[1].mul[6]>].if_null[<list[]>]>
|
||||
- narrate targets:<[player]> format:formats_prefix "<&e>OpenPhones Contacts<&nl>"
|
||||
# show contacts
|
||||
- foreach <[contactslist]> as:receiver:
|
||||
- define target <[contacts].get[<[receiver]>]>
|
||||
# state
|
||||
- define contactstate <proc[phones_get_contact_state].context[<[player]>|<[target]>]>
|
||||
- if <[contactstate]> == invisible:
|
||||
- define contactstate <&7>⏺
|
||||
- else if <[contactstate]> == online:
|
||||
- define contactstate <&a>⏺
|
||||
- else if <[contactstate]> == offline:
|
||||
- define contactstate <&c>⏺
|
||||
#
|
||||
- define contact "<[contactstate]> <&e><proc[phones_nicer_format].context[<proc[phones_get_number].context[<[target]>]>]> <&7><&o>(<[receiver]>)"
|
||||
- narrate <[contact]>
|
||||
# page buttons
|
||||
- define prevpage <&7><<>--
|
||||
- define nextpage <&7>--<>>
|
||||
- if <[page]> > 0:
|
||||
- clickable usages:1 until:60s save:prev:
|
||||
- execute as_player "phonecontacts <[page]>"
|
||||
- define prevpage "<element[<&a><<>--].on_click[<entry[prev].command>]>"
|
||||
- if <[contacts].size> > <[page].add[1].mul[6]>:
|
||||
- clickable usages:1 until:60s save:next:
|
||||
- execute as_player "phonecontacts <[page].add[2]>"
|
||||
- define nextpage "<element[<&a>--<>>].on_click[<entry[next].command>]>"
|
||||
- narrate targets:<[player]> "<&nl><[prevpage]> <&6>Page <[page].add[1]>/<[contacts].size.sub[1].div[6].round_down.add[1]> <[nextpage]>"
|
||||
|
||||
# ---
|
||||
# --- texts related
|
||||
# ---
|
||||
|
||||
phones_texts_store:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player|target|contents
|
||||
script:
|
||||
- narrate targets:<[player]> format:formats_prefix "Sending..."
|
||||
#
|
||||
- define playertexts phones_texts_<[player].uuid>_<[target].uuid>
|
||||
- if <util.has_file[data/phones/texts/<[player].uuid>_<[target].uuid>.yml]>:
|
||||
- ~yaml id:<[playertexts]> load:data/phones/texts/<[player].uuid>_<[target].uuid>.yml
|
||||
- else:
|
||||
- ~yaml id:<[playertexts]> create
|
||||
- yaml id:<[playertexts]> set messages.<util.time_now.escaped>:<map[].with[origin].as[sender].with[value].as[<[contents]>]>
|
||||
- ~yaml savefile:data/phones/texts/<[player].uuid>_<[target].uuid>.yml id:<[playertexts]>
|
||||
- ~yaml id:phones_texts_<[player].uuid>_<[target].uuid> unload
|
||||
#
|
||||
- define targettexts phones_texts_<[target].uuid>_<[player].uuid>
|
||||
- if <util.has_file[data/phones/texts/<[target].uuid>_<[player].uuid>.yml]>:
|
||||
- ~yaml id:<[targettexts]> load:data/phones/texts/<[target].uuid>_<[player].uuid>.yml
|
||||
- else:
|
||||
- ~yaml id:<[targettexts]> create
|
||||
- yaml id:<[targettexts]> set messages.<util.time_now.escaped>:<map[].with[origin].as[receiver].with[value].as[<[contents]>]>
|
||||
- ~yaml savefile:data/phones/texts/<[target].uuid>_<[player].uuid>.yml id:<[targettexts]>
|
||||
- ~yaml id:phones_texts_<[target].uuid>_<[player].uuid> unload
|
||||
# send
|
||||
- define relative <proc[phones_relative_name].context[<[player]>|<[target]>]>
|
||||
- narrate targets:<[player]> "<&6>[<&7>T<&6>] <&e>You ➠ <[relative]> <&2>sent '<[contents]>' via text"
|
||||
# notify or send
|
||||
- if <[target].is_online>:
|
||||
- if <[target].item_in_hand.has_flag[phones]>:
|
||||
- define inverserelative <proc[phones_relative_name].context[<[target]>|<[player]>]>
|
||||
- narrate targets:<[target]> "<&6>[<&7>T<&6>] <&e><[inverserelative]> ➠ You <&2>sent '<[contents]>' via text"
|
||||
- else:
|
||||
- narrate targets:<[target]> "<&6>[<&7>T<&6>] <&e>You received a text message."
|
||||
- else:
|
||||
- define notifications <[target].flag[phones_notifications].if_null[<map[]>]>
|
||||
- define textnotifications <[notifications].get[textmessages].if_null[<map[]>]>
|
||||
- define textnotifications <[textnotifications].with[<[player]>].as[<[textnotifications].get[<[player]>].if_null[0].add[1]>]>
|
||||
- define notifications <[notifications].with[textmessages].as[<[textnotifications]>]>
|
||||
- flag <[target]> phones_notifications:<[notifications]>
|
||||
|
||||
phones_texts_print:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player|target|page
|
||||
script:
|
||||
- narrate targets:<[player]> format:formats_prefix "Loading..."
|
||||
#
|
||||
- define playertexts phones_texts_<[player].uuid>_<[target].uuid>
|
||||
- ~yaml id:<[playertexts]> load:data/phones/texts/<[player].uuid>_<[target].uuid>.yml
|
||||
- define messages_size <yaml[<[playertexts]>].read[messages].size>
|
||||
- define message_keys <yaml[<[playertexts]>].read[messages].keys.reverse.get[<[page].mul[5].add[1]>].to[<[page].add[1].mul[5]>].if_null[<list[]>]>
|
||||
- define messages <map[]>
|
||||
- foreach <[message_keys]> as:timestamp:
|
||||
- define messages <[messages].with[<time[<[timestamp].unescaped>]>].as[<yaml[<[playertexts]>].read[messages.<[timestamp]>]>]>
|
||||
- ~yaml id:phones_texts_<[player].uuid>_<[target].uuid> unload
|
||||
#
|
||||
- define relative <proc[phones_relative_name].context[<[player]>|<[target]>]>
|
||||
- narrate targets:<[player]> format:formats_prefix "<&e>Messages with <[relative]><&nl>"
|
||||
- foreach <[messages]> key:timestamp as:message:
|
||||
- define when <util.time_now.duration_since[<[timestamp]>].formatted>
|
||||
- if <[message].get[origin]> == sender:
|
||||
- narrate targets:<[player]> "<&7>You: <&f><[message].get[value]> <&7>(<[when]> ago)"
|
||||
- else:
|
||||
- narrate targets:<[player]> "<&e><[relative]><&7>: <&f><[message].get[value]> <&7>(<[when]> ago)"
|
||||
# page buttons
|
||||
- define prevpage <&7><<>--
|
||||
- define nextpage <&7>--<>>
|
||||
- if <[page]> > 0:
|
||||
- clickable usages:1 until:60s save:prev:
|
||||
- run phones_texts_print def.player:<[player]> def.target:<[target]> def.page:<[page].sub[1]>
|
||||
- define prevpage "<element[<&a><<>--].on_click[<entry[prev].command>]>"
|
||||
- if <[messages_size]> > <[page].add[1].mul[5]>:
|
||||
- clickable usages:1 until:60s save:next:
|
||||
- run phones_texts_print def.player:<[player]> def.target:<[target]> def.page:<[page].add[1]>
|
||||
- define nextpage "<element[<&a>--<>>].on_click[<entry[next].command>]>"
|
||||
- narrate targets:<[player]> "<&nl><[prevpage]> <&6>Page <[page].add[1]>/<[messages_size].sub[1].div[5].round_down.add[1]> <[nextpage]>"
|
||||
# clear notifications?
|
||||
- if <[player].flag[phones_notifications].get[textmessages].get[<[target]>].if_null[0]> > 0:
|
||||
- define notifications <[player].flag[phones_notifications].if_null[<map[]>]>
|
||||
- define textnotifications <[notifications].get[textmessages].if_null[<map[]>]>
|
||||
- define textnotifications <[textnotifications].exclude[<[target]>]>
|
||||
- define notifications <[notifications].with[textmessages].as[<[textnotifications]>]>
|
||||
- flag <[player]> phones_notifications:<[notifications]>
|
||||
|
||||
phones_gui_texts:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player|page
|
||||
script:
|
||||
- define inventory "<inventory[generic[size=54;title=<&f>邑邑邑邑鄀<&1>邒]]>"
|
||||
- define textslist <util.list_files[data/phones/texts].filter[starts_with[<player.uuid>]].parse[split[_].get[2].split[.].get[1]].parse_tag[<player[<[parse_value]>]>].get[<[page].mul[16].add[1]>].to[<[page].add[1].mul[16]>].if_null[<list[]>]>
|
||||
# show contacts/numbers
|
||||
- foreach <[textslist]> as:target:
|
||||
- define receiver <proc[phones_relative_name].context[<[player]>|<[target]>]>
|
||||
- define textsender <item[player_head]>
|
||||
- adjust def:textsender display:<&e><[receiver]>
|
||||
- adjust def:textsender "lore:<list[<&7>Click to view your conversation.]>"
|
||||
# notifications
|
||||
- define notifications_text <[player].flag[phones_notifications].get[textmessages].get[<[target]>].if_null[null]>
|
||||
- if <[notifications_text]> != null:
|
||||
- if <[notifications_text]> > 99:
|
||||
- define notifications_text 99+
|
||||
- adjust def:textsender "lore:<[textsender].lore.include[|<&7>You have <&6><[notifications_text]> <&7>unread messages.]>"
|
||||
#
|
||||
- flag <[textsender]> phones:<[target]>
|
||||
- flag <[textsender]> phones_target_skull_uuid:<[target].uuid>
|
||||
- inventory set destination:<[inventory]> slot:<[loop_index].sub[1].div[3].round_down.mul[9].add[4].add[<[loop_index].sub[1].mod[3]>]> origin:<[textsender]>
|
||||
# back
|
||||
- define back <item[oak_door]>
|
||||
- adjust def:back display:<&7>Back
|
||||
- inventory set destination:<[inventory]> slot:50 origin:<[back]>
|
||||
# page buttons
|
||||
- if <[page]> > 0:
|
||||
- define prevpage <item[ender_pearl]>
|
||||
- adjust def:prevpage "display:<&a>Previous Page"
|
||||
- inventory set destination:<[inventory]> slot:49 origin:<[prevpage]>
|
||||
- if <[textslist].size> > <[page].add[1].mul[16]>:
|
||||
- define nextpage <item[ender_eye]>
|
||||
- adjust def:nextpage "display:<&a>Next Page"
|
||||
- inventory set destination:<[inventory]> slot:51 origin:<[nextpage]>
|
||||
#
|
||||
- inventory open player:<[player]> destination:<[inventory]>
|
||||
- run phones_target_skulls_update def.player:<[player]>
|
||||
|
||||
# each skull you want to change has to be flagged with phones_target_skull_uuid:<[target].uuid>
|
||||
phones_target_skulls_update:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player
|
||||
script:
|
||||
- define inventory <[player].open_inventory>
|
||||
- foreach <[inventory].map_slots> key:slot as:item:
|
||||
- if <[item].has_flag[phones_target_skull_uuid]>:
|
||||
- if <[inventory].viewers.if_null[<list[]>].is_empty>:
|
||||
- stop
|
||||
- define uuid <[item].flag[phones_target_skull_uuid]>
|
||||
- inventory adjust slot:<[slot]> skull_skin:<[uuid]>|<player[<[uuid]>].skin_blob.if_null[0000]>|<player[<[uuid]>].name> destination:<[inventory]>
|
||||
|
||||
####
|
||||
## NOTIFICATIONS
|
||||
####
|
||||
|
||||
phones_notify_text_messages:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player|delayseconds
|
||||
script:
|
||||
- wait <[delayseconds]>s
|
||||
- if !<[player].is_online>:
|
||||
- stop
|
||||
- define notifications_textmessages <[player].flag[phones_notifications].get[textmessages].values.filter[equals[0].not].sum.if_null[null]>
|
||||
- if <[notifications_textmessages]> == null || <[notifications_textmessages]> == 0:
|
||||
- stop
|
||||
- if <[notifications_textmessages]> > 99:
|
||||
- define notifications_textmessages 99+
|
||||
- narrate targets:<[player]> format:formats_prefix "You have <&6><[notifications_textmessages]> <&7>unread text conversations."
|
||||
|
||||
####
|
||||
## MUSIC APP
|
||||
####
|
||||
|
||||
phones_music_play:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player|songfile
|
||||
script:
|
||||
- if <[player].nbs_is_playing>:
|
||||
- nbs stop targets:<[player]>
|
||||
- nbs file:data/phones/songs/<[songfile]> play targets:<[player]>
|
||||
- narrate targets:<[player]> format:formats_prefix "Playing song..."
|
||||
|
||||
phones_music_stop:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player
|
||||
script:
|
||||
- if !<[player].nbs_is_playing>:
|
||||
- narrate targets:<[player]> format:formats_prefix "No song is playing right now."
|
||||
- stop
|
||||
- nbs stop targets:<[player]>
|
||||
- narrate targets:<[player]> format:formats_prefix "Stopped song."
|
||||
|
||||
phones_gui_music:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player|page|ringtone
|
||||
script:
|
||||
# ringtone selection mode?
|
||||
- define ringtone <[ringtone].if_null[false]>
|
||||
# make inventory
|
||||
- define inventory "<inventory[generic[size=54;title=<&f>邑邑邑邑鄀<&2>邒]]>"
|
||||
- if <[ringtone]>:
|
||||
- define inventory "<inventory[generic[size=54;title=<&f>邑邑邑邑鄀<&4>邒]]>"
|
||||
- define songsize <util.list_files[data/phones/songs].size>
|
||||
- define songsonpage <tern[<[ringtone]>].pass[15].fail[14]>
|
||||
- define songlist <util.list_files[data/phones/songs].parse[split[.].get[1]].filter[length.is_more_than[0]].get[<[page].mul[<[songsonpage]>].add[1]>].to[<[page].add[1].mul[<[songsonpage]>]>].if_null[<list[]>]>
|
||||
# show songs
|
||||
- foreach <[songlist]> as:songname:
|
||||
- define song <item[jukebox]>
|
||||
- adjust def:song display:<&e><[songname]>
|
||||
- adjust def:song "lore:<list[<&7>Click to start playing.]>"
|
||||
- flag <[song]> phones:<[songname]>
|
||||
- inventory set destination:<[inventory]> slot:<[loop_index].sub[1].div[3].round_down.mul[9].add[4].add[<[loop_index].sub[1].mod[3]>]> origin:<[song]>
|
||||
# stop
|
||||
- if !<[ringtone]>:
|
||||
- define stop <item[redstone_block]>
|
||||
- adjust def:stop display:<&c>Stop
|
||||
- inventory set destination:<[inventory]> slot:42 origin:<[stop]>
|
||||
# back
|
||||
- define back <item[oak_door]>
|
||||
- adjust def:back display:<&7>Back
|
||||
- inventory set destination:<[inventory]> slot:50 origin:<[back]>
|
||||
# page buttons
|
||||
- if <[page]> > 0:
|
||||
- define prevpage <item[ender_pearl]>
|
||||
- adjust def:prevpage "display:<&a>Previous Page"
|
||||
- inventory set destination:<[inventory]> slot:49 origin:<[prevpage]>
|
||||
- if <[songsize]> > <[page].add[1].mul[<[songsonpage]>]>:
|
||||
- define nextpage <item[ender_eye]>
|
||||
- adjust def:nextpage "display:<&a>Next Page"
|
||||
- inventory set destination:<[inventory]> slot:51 origin:<[nextpage]>
|
||||
#
|
||||
- inventory open player:<[player]> destination:<[inventory]>
|
||||
|
||||
###
|
||||
## SETTINGS
|
||||
###
|
||||
phones_gui_settings:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player
|
||||
script:
|
||||
- define inventory "<inventory[generic[size=54;title=<&f>邑邑邑邑鄀<&3>邒]]>"
|
||||
# ringtone
|
||||
- define ringtone <item[note_block]>
|
||||
- adjust def:ringtone display:<&6>Ringtone
|
||||
- adjust def:ringtone "lore:<&7>(music from <&e>noteblock.world<&7>)"
|
||||
- inventory set destination:<[inventory]> slot:4 origin:<[ringtone]>
|
||||
# blocked
|
||||
- define blocked <item[barrier]>
|
||||
- adjust def:blocked "display:<&6>Blocked Numbers"
|
||||
- inventory set destination:<[inventory]> slot:5 origin:<[blocked]>
|
||||
# back
|
||||
- define back <item[oak_door]>
|
||||
- adjust def:back display:<&7>Back
|
||||
- inventory set destination:<[inventory]> slot:50 origin:<[back]>
|
||||
#
|
||||
- inventory open player:<[player]> destination:<[inventory]>
|
||||
|
||||
phones_gui_settings_blocked:
|
||||
debug: false
|
||||
type: task
|
||||
definitions: player|page
|
||||
script:
|
||||
- define inventory "<inventory[generic[size=54;title=<&f>邑邑邑邑鄀<&5>邒]]>"
|
||||
- define blockedlist <[player].flag[phones].get[blocked].get[<[page].mul[16].add[1]>].to[<[page].add[1].mul[16]>].if_null[<list[]>]>
|
||||
# show blocked numbers
|
||||
- foreach <[blockedlist]> as:target:
|
||||
- define blockednumber <proc[phones_nicer_format].context[<[target].flag[phones].get[number]>]>
|
||||
- define blocked <item[player_head]>
|
||||
- adjust def:blocked display:<&e><[blockednumber]>
|
||||
- adjust def:blocked lore:<list[<&7>You may use /phoneunblock to unblock this number.]>
|
||||
- flag <[blocked]> phones_target_skull_uuid:<[target].uuid>
|
||||
- inventory set destination:<[inventory]> slot:<[loop_index].sub[1].div[3].round_down.mul[9].add[4].add[<[loop_index].sub[1].mod[3]>]> origin:<[blocked]>
|
||||
# back
|
||||
- define back <item[oak_door]>
|
||||
- adjust def:back display:<&7>Back
|
||||
- inventory set destination:<[inventory]> slot:50 origin:<[back]>
|
||||
# page buttons
|
||||
- if <[page]> > 0:
|
||||
- define prevpage <item[ender_pearl]>
|
||||
- adjust def:prevpage "display:<&a>Previous Page"
|
||||
- inventory set destination:<[inventory]> slot:49 origin:<[prevpage]>
|
||||
- if <[blockedlist].size> > <[page].add[1].mul[16]>:
|
||||
- define nextpage <item[ender_eye]>
|
||||
- adjust def:nextpage "display:<&a>Next Page"
|
||||
- inventory set destination:<[inventory]> slot:51 origin:<[nextpage]>
|
||||
#
|
||||
- inventory open player:<[player]> destination:<[inventory]>
|
||||
- run phones_target_skulls_update def.player:<[player]>
|
||||
185
scripts/phones/phones_world.dsc
Normal file
185
scripts/phones/phones_world.dsc
Normal file
@@ -0,0 +1,185 @@
|
||||
phones_world:
|
||||
debug: false
|
||||
type: world
|
||||
events:
|
||||
## assign new random number & handle notifications
|
||||
after player joins:
|
||||
- run phones_notify_text_messages def.player:<player> def.delayseconds:5
|
||||
#
|
||||
- if <player.has_flag[phones]>:
|
||||
- stop
|
||||
- define number <util.random.int[1000000].to[9999999]>
|
||||
- while <server.flag[phones].if_null[<map[]>].contains[377<[number]>]>:
|
||||
- define number <util.random.int[1000000].to[9999999]>
|
||||
- define number 377<[number]>
|
||||
- flag <player> phones:<map[].with[number].as[<[number]>]>
|
||||
- flag server phones:<server.flag[phones].if_null[<map[]>].with[<[number]>].as[<player>]>
|
||||
## phone drop, phone unequip, player logs off etc.
|
||||
on player drops item:
|
||||
- if <player.has_flag[phones_chat_input]>:
|
||||
- if <context.item.has_flag[phones].if_null[false]>:
|
||||
- determine cancelled
|
||||
- if <context.item.has_flag[phones].if_null[false]>:
|
||||
- nbs stop targets:<player>
|
||||
- inject phones_inject_end_call
|
||||
on player scrolls their hotbar:
|
||||
- if <player.inventory.slot[<context.previous_slot>].has_flag[phones]>:
|
||||
- inject phones_inject_end_call
|
||||
on player quits:
|
||||
- inject phones_inject_end_call
|
||||
after player clicks in inventory:
|
||||
- if !<player.item_in_hand.flag[phones].if_null[false]>:
|
||||
- inject phones_inject_end_call
|
||||
## boot up/down phone
|
||||
on player left clicks block:
|
||||
- if !<player.item_in_hand.has_flag[phones].if_null[false]>:
|
||||
- stop
|
||||
- if <player.open_inventory> != <player.inventory>:
|
||||
- stop
|
||||
- determine cancelled passively
|
||||
- if <player.has_flag[phones_chat_input]>:
|
||||
- flag <player> phones_chat_input:!
|
||||
- define state <player.item_in_hand.flag[phones].not>
|
||||
- inventory flag slot:hand phones:<[state]>
|
||||
- if <[state]>:
|
||||
- narrate format:formats_prefix "Powered <&a>on <&7>your phone."
|
||||
#
|
||||
- run phones_notify_text_messages def.player:<player> def.delayseconds:2
|
||||
- else:
|
||||
- narrate format:formats_prefix "Powered <&c>off <&7>your phone."
|
||||
- nbs stop targets:<player>
|
||||
- inject phones_inject_end_call
|
||||
## phone GUI
|
||||
on player right clicks block:
|
||||
- if !<player.item_in_hand.has_flag[phones].if_null[false]>:
|
||||
- stop
|
||||
- determine cancelled passively
|
||||
- if <player.has_flag[phones_call]>:
|
||||
- narrate "<&c>You are currently in the middle of a call (stop holding the phone to end the call)."
|
||||
- stop
|
||||
- if <player.has_flag[phones_chat_input]>:
|
||||
- flag <player> phones_chat_input:!
|
||||
- if !<player.item_in_hand.flag[phones]>:
|
||||
- narrate "<&c>Please turn on your phone (left click) to view the home screen."
|
||||
- stop
|
||||
- run phones_gui_home def.player:<player>
|
||||
|
||||
# used in ending a call because code repeats a lot
|
||||
phones_inject_end_call:
|
||||
debug: false
|
||||
type: task
|
||||
script:
|
||||
- if <player.has_flag[phones_is_maybe_called]>:
|
||||
- flag <player> phones_is_maybe_called:!
|
||||
- nbs stop
|
||||
- if !<player.has_flag[phones_call]>:
|
||||
- stop
|
||||
- define callwho <player.flag[phones_call]>
|
||||
- define iswaiting <player.has_flag[phones_call_clickable]>
|
||||
- flag <player> phones_call:!
|
||||
- if <[iswaiting]>:
|
||||
- clickable cancel:<player.flag[phones_call_clickable]>
|
||||
- flag <player> phones_call_clickable:!
|
||||
- if <[callwho].flag[phones_call].if_null[null]> == <player>:
|
||||
- narrate targets:<[callwho]> format:formats_prefix "Call was ended by the other side."
|
||||
- flag <[callwho]> phones_call:!
|
||||
- else:
|
||||
- nbs stop targets:<[callwho]>
|
||||
- narrate targets:<[callwho]> format:formats_prefix "The person on the other side hung up before you answered."
|
||||
- narrate format:formats_prefix "You ended the call."
|
||||
|
||||
## only gui handling
|
||||
phones_world_gui:
|
||||
debug: false
|
||||
type: world
|
||||
events:
|
||||
on player clicks in inventory:
|
||||
- if !<context.inventory.title.contains[鄀]>:
|
||||
- stop
|
||||
- determine cancelled passively
|
||||
- if <context.slot> > <context.inventory.size>:
|
||||
- stop
|
||||
- define title <context.inventory.title.substring[8]>
|
||||
# Home Page
|
||||
- if <[title]> == <&0>邒:
|
||||
- if <context.slot> == 13:
|
||||
- run phones_gui_settings def.player:<player>
|
||||
- if <context.slot> == 14:
|
||||
- inventory close
|
||||
- run phones_contacts_print def.player:<player> def.page:0
|
||||
- else if <context.slot> == 15:
|
||||
- flag <player> phones_gui_page:0
|
||||
- run phones_gui_texts def.player:<player> def.page:0
|
||||
- else if <context.slot> == 22:
|
||||
- flag <player> phones_gui_page:0
|
||||
- run phones_gui_music def.player:<player> def.page:0 def.ringtone:false
|
||||
- else if <[title]> == <&1>邒:
|
||||
- if <context.item.material.name> == ender_pearl:
|
||||
- define page <player.flag[phones_gui_page].sub_int[1]>
|
||||
- flag <player> phones_gui_page:<[page]>
|
||||
- run phones_gui_texts def.player:<player> def.page:<[page]>
|
||||
- else if <context.item.material.name> == ender_eye:
|
||||
- define page <player.flag[phones_gui_page].add_int[1]>
|
||||
- flag <player> phones_gui_page:<[page]>
|
||||
- run phones_gui_texts def.player:<player> def.page:<[page]>
|
||||
- else if <context.slot> == 50:
|
||||
- run phones_gui_home def.player:<player>
|
||||
- else if <context.item.material.name> == player_head:
|
||||
- inventory close
|
||||
- run phones_texts_print def.player:<player> def.target:<context.item.flag[phones]> def.page:0
|
||||
# Music
|
||||
- else if <[title]> == <&2>邒:
|
||||
- if <context.item.material.name> == ender_pearl:
|
||||
- define page <player.flag[phones_gui_page].sub_int[1]>
|
||||
- flag <player> phones_gui_page:<[page]>
|
||||
- run phones_gui_music def.player:<player> def.page:<[page]> def.ringtone:false
|
||||
- else if <context.item.material.name> == ender_eye:
|
||||
- define page <player.flag[phones_gui_page].add_int[1]>
|
||||
- flag <player> phones_gui_page:<[page]>
|
||||
- run phones_gui_music def.player:<player> def.page:<[page]> def.ringtone:false
|
||||
- else if <context.slot> == 50:
|
||||
- run phones_gui_home def.player:<player>
|
||||
- else if <context.slot> == 42:
|
||||
- inventory close
|
||||
- run phones_music_stop def.player:<player>
|
||||
- else if <context.item.material.name> == jukebox:
|
||||
- inventory close
|
||||
- run phones_music_play def.player:<player> def.songfile:<context.item.flag[phones]>
|
||||
# Settings
|
||||
- else if <[title]> == <&3>邒:
|
||||
- if <context.slot> == 4:
|
||||
- flag <player> phones_gui_page:0
|
||||
- run phones_gui_music def.player:<player> def.page:0 def.ringtone:true
|
||||
- if <context.slot> == 5:
|
||||
- flag <player> phones_gui_page:0
|
||||
- run phones_gui_settings_blocked def.player:<player> def.page:0
|
||||
- else if <context.slot> == 50:
|
||||
- run phones_gui_home def.player:<player>
|
||||
# Ringtone Select
|
||||
- else if <[title]> == <&4>邒:
|
||||
- if <context.item.material.name> == ender_pearl:
|
||||
- define page <player.flag[phones_gui_page].sub_int[1]>
|
||||
- flag <player> phones_gui_page:<[page]>
|
||||
- run phones_gui_music def.player:<player> def.page:<[page]> def.ringtone:true
|
||||
- else if <context.item.material.name> == ender_eye:
|
||||
- define page <player.flag[phones_gui_page].add_int[1]>
|
||||
- flag <player> phones_gui_page:<[page]>
|
||||
- run phones_gui_music def.player:<player> def.page:<[page]> def.ringtone:true
|
||||
- else if <context.slot> == 50:
|
||||
- run phones_gui_settings def.player:<player>
|
||||
- else if <context.item.material.name> == jukebox:
|
||||
- flag <player> phones:<player.flag[phones].with[ringtone].as[<context.item.flag[phones]>]>
|
||||
- run phones_gui_settings def.player:<player>
|
||||
- narrate format:formats_prefix "Changed your ringtone to <&e><context.item.display.strip_color><&7>."
|
||||
# Blocked
|
||||
- else if <[title]> == <&5>邒:
|
||||
- if <context.item.material.name> == ender_pearl:
|
||||
- define page <player.flag[phones_gui_page].sub_int[1]>
|
||||
- flag <player> phones_gui_page:<[page]>
|
||||
- run phones_gui_settings_blocked def.player:<player> def.page:<[page]>
|
||||
- else if <context.item.material.name> == ender_eye:
|
||||
- define page <player.flag[phones_gui_page].add_int[1]>
|
||||
- flag <player> phones_gui_page:<[page]>
|
||||
- run phones_gui_settings_blocked def.player:<player> def.page:<[page]>
|
||||
- else if <context.slot> == 50:
|
||||
- run phones_gui_settings def.player:<player>
|
||||
Reference in New Issue
Block a user