Hi there! I'm a student who's interested in coding with Python, and I'm currently learning Java.
1drturtle / avrae-oneliners Goto Github PK
View Code? Open in Web Editor NEWCollection of One-Liners for use in Draconic.
Collection of One-Liners for use in Draconic.
The actual code.
!test <drac2>
start_time = 1_609_495_200 # 1 january 2021 10:00 GMT. The starting point for calculating the reset moments. Change this to an appropiate moment (for example the first monday of the year for weekly, the first noon for hourly, etc.)
HOUR = 3600 # amount of seconds in an hour/day/week
DAY = 86_400
WEEK = 604_800
period = DAY # the period
cvar = "last_run_time"
difference = int(time())- start_time # calculate the difference in seconds between now and start
times = floor(difference/period) # amount of days between then and now
last_reset = start_time+(period*times) # comes up with the unix timestamp from the last time it reset
last_run = int(get(cvar,0)) # checks the time since last run, 0 if this is the first time it is run
if last_run-last_reset >= 0: # if it is 0 or larger then that means the last time it was run was after the reset
return "You have done this already since last reset"
else:
character().set_cvar(cvar,now_time) # sets the time it was last run at
return "You can do the thing."
</drac2>
This code snippet calculates a reset point in real life time. For example, daily at noon in a specific timezone. The command can be run once during that time, and can only be run again after the reset point has passed.
This is useful for things that have a daily or weekly reset at a specific moment. Such as every monday at noon you can use a specific alias again.
start_time # A starting moment for when your system begins counting. For example, first noon of the year, first monday of the year at noon, etc. This is primarely important for daily or weekly systems
period # the amount of seconds that a period lasts (for example, a week)
cvar # the cvar that the time is stored to.
This takes any targets or groups made with -t
and tries to convert them into combatants, and then stores them in a list called combatants.
Drac1 Version
#Basic Variables
{{parse,c = argparse(&ARGS&),combat()}}
#Creates a list of targets that have been grabbed by -t
{{t = parse.get('t')}}
#tlist creates a list of combatants, either in their own list from the group, or by themselves. Combatants is a placeholder for the next line.
{{tlist, combatants = [c.get_combatant(x) or c.get_group(x).combatants for x in t],[]}}
#This searches for all the elements that are not lists and adds them to combatants, then joins the combatant-group list to the combatants list, allowing for everything to be in one list for further parsing.
{{[combatants.append(x) if not typeof(x)=='SafeList' else combatants.extend(x) for x in tlist]}}
Drac2 Version
<drac2>
#Basic Variables
parse, c = argparse(&ARGS&), combat()
#Creates a list of targets that have been grabbed by -t
targets = parse.get('t')
#Combatants is a placeholder for the next line.
combatants = []
#This is an if statement for targets that checks if an element in it is a combatant, and appends them to the combatants list, else it gets the list of combatants from the group and joins it to the combatants list, allowing for everything to be in one list for further parsing.
for x in targets:
if (combatant := combat().get_combatant(x) ):
combatants.append(combatant)
else:
combatants += combat().get_group(x).combatants
</drac2>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.