Skip to content

Instantly share code, notes, and snippets.

View wanderrful's full-sized avatar

Wanderrful wanderrful

  • United States of America
View GitHub Profile
@wanderrful
wanderrful / todoui.rs
Last active September 16, 2022 04:50
Bevy TodoMVC example
use bevy::app::{Plugin, App};
use bevy::ecs::component::Component;
use bevy::ecs::event::{EventReader, EventWriter};
use bevy::ecs::change_detection::ResMut;
use bevy::ecs::prelude::Res;
use bevy::log::info;
use bevy::prelude::{KeyCode, NodeBundle};
use bevy::input::Input;
use bevy::ecs::system::{Commands, Query};
use bevy::hierarchy::BuildChildren;
@wanderrful
wanderrful / timestamp.ts
Last active March 11, 2020 07:03 — forked from jonkemp/timestamp.js
Print out a nicely formatted timestamp in TypeScript.
export function fn_getTimeStamp(): Object {
// Create a date object with the current time
let now: Date = new Date();
// Create an array with the current month, day and time
let date: Array<String> = [ String(now.getMonth() + 1), String(now.getDate()), String(now.getFullYear()) ];
// Create an array with the current hour, minute and second
let time: Array<String> = [ String(now.getHours()), String(now.getMinutes())];
// If seconds and minutes are less than 10, add a zero
for (let i of time) {
if ( Number(i) < 10 ) {
@wanderrful
wanderrful / initCountdownTimer.sqf
Last active June 6, 2017 08:59
This is my personally preferred method for creating a countdown timer in Arma 3.
//*** Initialize the countdown timer for all players
sv_currentTime = 5*60;
[ "itemAdd", [
"countdownTimer", {
sv_currentTime = sv_currentTime - 1;
if (sv_currentTime isEqualTo 0) then {
sv_currentTime = nil;
"EveryoneLost" call BIS_fnc_endMissionServer;
};
},
@wanderrful
wanderrful / GetEntitiesByPrefix.sqf
Created June 5, 2017 23:46
Example usage: if you have a bunch of triggers all with the prefix "trg_", then you can assemble them all into an array by saying "trg" call sxf_fnc_getEntitiesByPrefix;
//Example usage:
//if you have a bunch of triggers all with the prefix "trg_", then you can assemble them all into an array by saying:
//"trg_" call sxf_fnc_getEntitiesByPrefix;
sxf_fnc_getEntitiesByPrefix = {
_tempList = [];
_i = count _tempList;
while { _i = _i + 1; !isNil (_this + str _i) } do {
_tempList pushBack ( missionNamespace getVariable [(_this + str _i), objNull] );
};
_tempList
@wanderrful
wanderrful / JetScript.sqf
Created June 2, 2017 04:53
My jet rearm/refuel/repair script for Arma 3. Requires triggers called "trg_rearmZone", "trg_refuelZone", and "trg_repairZone" where each trigger is set to "Any Player", "Repeatable", and "Server Only".
//*** Configure the aircraft rearm and refuel triggers (requires SERVERSIDE context only!)
sxf_fnc_stripAircraft = {
//_this must be the aircraft vehicle itself
{
if (_x != "CMFlareLauncher") then //i don't know how to re-add this back into the chaff slot for some reason... :'c
{
_this removeWeaponTurret [_x, [-1]];
};
} forEach (_this weaponsTurret [-1]);
{
/*
Assumed file path: mission-folder\tagus\fnc_whiteListArsenal.sqf
If you put the script file elsewhere, make sure you reference it correctly!
I spent 3 hours while working on this pulling my hair out because I wrote / instead of \ when calling the execVM.
I hate everything right now.
Syntax:
[object, boolean] execVM "tagus\fnc_whiteListTheArsenal.sqf";
@wanderrful
wanderrful / gist:2592498
Created May 4, 2012 06:13
Euclidean Algorithm in C++
=begin
I found this randomly and wanted to save it for future reference.
Let a, b denote the numerator and denomator, respectively. Let 'gcd' denote the Greatest Common Divisor of both a and b.
=end
if(a==0 || b==0)
return gcd = 1;
else