Giter VIP home page Giter VIP logo

avrae-oneliners's Introduction

Welcome to my Github! 👋

Hi there! I'm a student who's interested in coding with Python, and I'm currently learning Java.

📈 GitHub Stats

🔧Technology and Tools

avrae-oneliners's People

Contributors

1drturtle avatar adalbar3333 avatar thereverendb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

avrae-oneliners's Issues

[CODE] Reset at a specific point in real time

Code Snippet

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>

What does it do?

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.

Common Use-Cases

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.

Replacables:

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.

Get Combatants from Targets — Nested Dict Version

Get Combatants from Targets — With Group Support (AKA Nested Dicts)

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>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.