added some hooks and user custom tag , effects

This commit is contained in:
Ayush Saini 2021-04-02 14:00:25 +05:30
parent be7e8c63de
commit 91af4a8027
12 changed files with 131 additions and 4 deletions

View file

@ -168,6 +168,8 @@ class ScoreScreenActivity(Activity[EmptyPlayer, EmptyTeam]):
from bastd.actor.text import Text from bastd.actor.text import Text
from ba import _language from ba import _language
super().on_begin() super().on_begin()
import custom_hooks as chook
chook.score_screen_on_begin(self._stats)
# Pop up a 'press any button to continue' statement after our # Pop up a 'press any button to continue' statement after our
# min-view-time show a 'press any button to continue..' # min-view-time show a 'press any button to continue..'

View file

@ -279,6 +279,8 @@ class App:
from bastd import maps as stdmaps from bastd import maps as stdmaps
from bastd.actor import spazappearance from bastd.actor import spazappearance
from ba._enums import TimeType from ba._enums import TimeType
import custom_hooks
custom_hooks.on_app_launch()
cfg = self.config cfg = self.config

View file

@ -308,6 +308,7 @@ def party_invite_revoke(invite_id: str) -> None:
transition='out_right') transition='out_right')
import privateserver as pvt import privateserver as pvt
import custom_hooks as chooks
def filter_chat_message(msg: str, client_id: int) -> Optional[str]: def filter_chat_message(msg: str, client_id: int) -> Optional[str]:
"""Intercept/filter chat messages. """Intercept/filter chat messages.
@ -316,9 +317,10 @@ def filter_chat_message(msg: str, client_id: int) -> Optional[str]:
Should filter and return the string to be displayed, or return None Should filter and return the string to be displayed, or return None
to ignore the message. to ignore the message.
""" """
pvt.handlechat(msg,client_id); pvt.handlechat(msg,client_id)
del client_id # Unused by default. return chooks.filter_chat_message(msg,client_id)
return msg
def local_chat_message(msg: str) -> None: def local_chat_message(msg: str) -> None:

View file

@ -70,6 +70,8 @@ class PlayerSpaz(Spaz):
self.last_player_held_by: Optional[ba.Player] = None self.last_player_held_by: Optional[ba.Player] = None
self._player = player self._player = player
self._drive_player_position() self._drive_player_position()
import custom_hooks
custom_hooks.playerspaz_init(self._player)
# Overloads to tell the type system our return type based on doraise val. # Overloads to tell the type system our return type based on doraise val.

View file

@ -0,0 +1,16 @@
def filter_chat_message(msg,client_id):
return msg
def on_app_launch():
#something
def score_screen_on_begin(_stats):
#stats
def playerspaz_init(player):
#add tag,rank,effect

View file

@ -0,0 +1,10 @@
{
"customtag":{
"pb-id":"smoothy",
"pb-45":"something"
},
"customeffects":{
"pb-id":"ice",
"pb-id":"scorch",
}
}

View file

@ -1,7 +1,7 @@
# Released under the MIT License. See LICENSE for details. # Released under the MIT License. See LICENSE for details.
roles={} roles={}
data={} data={}
custom={}
def roles(): def roles():
global roles global roles
@ -86,4 +86,53 @@ def commit():
f=open("roles.json",'w') f=open("roles.json",'w')
json.dump(roles,f,indent=4) json.dump(roles,f,indent=4)
f.close() f.close()
#======================= CUSTOM EFFECTS/TAGS ===============
def custom():
global custom
if custom=={}:
f=open("custom.json","r")
dat=json.loads(f.read())
custom=dat
f.close()
return custom
def set_effect(effect,id):
global custom
_custom=custom()
_custom['customeffects'][id]=effect
custom=_custom
commit_c()
def set_tag(tag,id):
global custom
_custom=custom()
_custom['customtag'][id]=tag
custom=_custom
commit_c()
def remove_effect(id):
global custom
_custom=custom()
_custom['customeffects'].pop(id)
custom=_custom
commit_c()
def remove_tag(id):
global custom
_custom=custom()
_custom['customtag'].pop(id)
custom=_custom
commit_c()
def commit_c():
global custom
f=open("custom.json",'w')
json.dump(custom,f,indent=4)
f.close()

5
dist/ba_root/mods/spaz/modifyspaz.py vendored Normal file
View file

@ -0,0 +1,5 @@

View file

View file

39
dist/ba_root/mods/tools/Logger.py vendored Normal file
View file

@ -0,0 +1,39 @@
import ba,_ba
import datetime;
import os
# ct stores current time
path=_ba.env()['python_directory_user']
serverdata=os.path.join(path,"serverData" + os.sep)
class log(object):
def __init__(self,msg,type='sys'):
ct = datetime.datetime.now()
msg=ct+msg
if type=='chat':
f=open(serverdata+"Chat Logs.log","a+")
elif type=='playerjoin':
f.open(serverdata+"joining.log","a+")
elif type=='chatcmnd':
f.open(serverdata+"cmndusage.log","a+")
else:
f=open(serverdata+"logs.log","a+")
f.write(msg)
f.close()