Skip to content

Instantly share code, notes, and snippets.

View warmist's full-sized avatar
💭
Making a game or sth

Warmist warmist

💭
Making a game or sth
View GitHub Profile
@warmist
warmist / imbue.lua
Last active December 15, 2016 16:23
imbue
function set_histfig_material(item,base_material,figure_id)
local figure_base=219
local creature_base=19
item:setMaterial(figure_base+base_material-creature_base)
item:setMaterialIndex(figure_id)
end
function reaction_imbue(reaction,reaction_product,unit,input_items,input_reagents,output_items,call_native)
--printall(input_items[1])
local mat_source=input_items[1]
local mat=mat_source:getActualMaterial()
local args={...}
flags=flags or {}
local ann=df.global.announcements.flags
if args[1]=='-s' then
print('saving')
for k,v in pairs(ann) do
flags[k]=copyall(v)
end
elseif args[1]=='-r' then
print('restoring')
@warmist
warmist / http.lua
Last active December 13, 2016 18:28
Work in progress
-- this requires a plugin that draws the map: https://github.com/warmist/dfhack/tree/twbt_experiments
--[[
Ideas for future:
microtransactions (for rooms and stuff :D) jkjk
assignment to locations (e.g. performance etc)
see if idle location can be used for direct dwarf control
more info about dwarf
possesions (with a way to add/remove them)
rooms
artifacts
#pragma once
//source: https://github.com/WG21-SG14/SG14/blob/master/SG14/inplace_function.h
#include <type_traits>
#include <functional>
namespace stdext
{
constexpr size_t InplaceFunctionDefaultCapacity = 32;
constexpr size_t InplaceFunctionDefaultAlignment = 16;
@warmist
warmist / my_lib.hpp
Last active August 2, 2017 13:07
Misc cpp functions
template<typename T,long N>
constexpr long countof(T(&)[N]){return N;}
//TODO: add this -http://stackoverflow.com/a/24881903
//TODO: file embedding lib
/*
void GetResourceAsString(int nResourceID, CStringA &strResourceString)
{
HRSRC hResource = FindResource(NULL, MAKEINTRESOURCE(nResourceID), L"DATA");
HGLOBAL hResHandle = LoadResource(NULL, hResource);
#ifndef VIRIDIS_HPP_INCLUDED
#define VIRIDIS_HPP_INCLUDED
void map_to_viridis(float v, uint8_t& r, uint8_t& g, uint8_t& b);
#endif
#ifdef VIRIDIS_IMPLEMENTATION
const double viridis_map[] = {
0.26700401, 0.00487433, 0.32941519,
0.26851048, 0.00960483, 0.33542652,
local args={...}
local site
for k,v in ipairs(df.global.world.world_data.sites) do
if dfhack.TranslateName(v.name)==args[1] then
site=v
end
end
if site==nil then
@warmist
warmist / needs.lua
Created March 27, 2016 15:47
A needs manipulation script.
-- this following part is for our documentation
--[[=begin
needs
=====
shows needs of a unit.
=end]]
local args={...} --let's get the command line arguments to a nice table
function set_tile_type(pos,tile_type )
local block=dfhack.maps.getTileBlock(pos)
block.tiletype[math.fmod(pos.x,16)][math.fmod(pos.y,16)]=tile_type
end
local args={...}
set_tile_type(copyall(df.global.cursor),tonumber(args[1]))
@warmist
warmist / appveyor.yml
Last active March 6, 2016 16:13
appveyor.yml
version: 1.0.{build}
branches:
only:
- develop
skip_tags: true
configuration: Release
clone_depth: 1
clone_folder: c:\projects\dfhack
init:
- cmd: >-