Skip to content

Instantly share code, notes, and snippets.

@msg555
msg555 / sample.cpp
Created July 28, 2017 23:01
Restore air charges when player collects dust
const int MAX_PLAYERS = 4;
class script {
/* We don't actually use the scene object in this script, but most will. */
scene@ g;
/* Keep track of how much dust we had in the last frame. */
array<int> dust_last;
/* Keep track of how much dust we had when the last checkpoint was saved. */
@msg555
msg555 / aitest.cpp
Created July 29, 2017 16:12
Create and setup an AI controller
class script {
bool firstFrame;
script() {
firstFrame = true;
}
void step(int entities) {
if (!firstFrame) {
return;
const int MAX_PLAYERS = 4;
class script {
scene@ g;
array<controllable@> players;
script() {
@g = get_scene();
players.resize(MAX_PLAYERS);
}
@msg555
msg555 / audio.txt
Created August 4, 2017 00:38
Audio names in DF
All Stream Names
amb_birds
amb_hollow
amb_city
amb_crickets
amb_wind
amb_machinery
amb_computers
amb_rain
class script {
scene@ g;
int frame;
script() {
@g = get_scene();
frame = 0;
}
void step(int entities) {
@msg555
msg555 / sprite_example.cpp
Last active October 12, 2017 17:23
An example of how to embed, build, and use custom sprites with dustscripts.
const string EMBED_test1 = "test1.png";
const string EMBED_test2 = "test2.png";
class script {
int frame_count;
sprites@ spr;
script() {
frame_count = 0;
@spr = create_sprites();
@msg555
msg555 / sounddemo.cpp
Created October 20, 2017 18:46
An example of how to embed and use custom sounds with dustscripting.
const string EMBED_sound1 = "test1.ogg";
class script {
scene@ g;
script() {
@g = get_scene();
}
void build_sounds(message@ msg) {
class script {
scene@ g;
textfield@ txt;
int init_filth;
int init_filth_block;
int init_enemy;
script() {
@g = get_scene();
@msg555
msg555 / intcode.py
Last active December 8, 2019 07:46
Solution to day 7
import abc
import asyncio
import itertools
import sys
class Instruction(metaclass=abc.ABCMeta):
PARAMS = 0
def __init__(self, comp, offset, mode):
@msg555
msg555 / 10-integral.cpp
Created December 11, 2019 21:52
Float free solution to Advent Day 10
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;