Skip to content

Instantly share code, notes, and snippets.

@2-3
2-3 / bloodex.md
Last active May 14, 2019 09:58
Collection of notes on the BloodEX scripting API

BloodEX Scripting

This document is a collection of notes on the BloodEX scripting API. These are just first impressions and are in no way guaranteed to be correct. This is intended to serve as starting point to everyone looking to create custom content for BloodEX and will hopefully soon be made obsolete by official documentation. It's a work in progress and I plan on focusing on including some useful code examples next.

All information regarding KEX/BloodEX (but not Build or Blood) collected in this document was gathered from plaintext files included in the remaster. Nothing was reverse-engineered.

To be precise, these were my sources:

  • The BloodEX.kpf file included in the game.
  • The Blood Alpha source code.
  • Scripts I wrote for BloodEX to test occurence and behavior of components which existed in the Alpha, and I suspected to exist in BloodEX.
@2-3
2-3 / chez-proc-source.scm
Created February 16, 2019 01:09
Returns a procedures source-code (for Chez)
(define-syntax proc-source
(syntax-rules ()
((_ id)
(let* ((v0 (inspect/object id))
(v1 (v0 'code))
(v2 (v1 'source))
(v3 (open-output-string))
(_ (v2 'write v3)))
(get-output-string v3)))))
@2-3
2-3 / aif.scm
Last active December 18, 2018 18:39
(define-syntax aif
(syntax-rules ()
((_ i c t e)
(let ((i c))
(if i t e)))))
@2-3
2-3 / obj_scm.js
Last active December 14, 2018 20:51
function make_object(_super, _recvs_) {
var _recvs = Object.assign(
{ lookup: function(s, al) { return _lookup(al[0]); },
super: function(s, al) { return _call(_super('lookup', [al[0]]), al.slice(1)); }}, _recvs_);
var _lookup = function(n) {
if (n in _recvs) { return _recvs[n]; }
else if (_super != undefined) { return _super('lookup', [n]);}
else { throw 'InvalidMessage'; }}
@2-3
2-3 / obj_5.scm
Last active December 14, 2018 19:48
(define (point% x y)
(make-object
#f
(list 'posn (lambda (s al) (list x y)))
(list 'eql? (lambda (s al) (if (equal? (s 'posn) ((car al) 'posn)) #t #f)))
(list 'sum (lambda (s al) (+ x y)))))
(define (point3d% x y z)
(make-object
(point% x y)
@2-3
2-3 / obj_4.scm
Last active December 14, 2018 16:04
(define (make-object super% . recvs_)
(letrec ((recvs (append recvs_ (list
(list 'lookup (lambda (s al) (lookup (car al))))
(list 'super (lambda (s al) (call
(super% 'lookup (car al))
(cdr al)))))))
(lookup (lambda (n) (or (find (lambda (r) (eq? (car r) n)) recvs)
(and super% (super% 'lookup n))
(error n "Unable to answer message."))))
(self (lambda (n . al) (call (lookup n) al)))
(define (make-object . recvs)
(letrec ((lookup (lambda (n) (or (find (lambda (r) (eq? (car r) n)) recvs)
(error n "Unable to answer message."))))
(self (lambda (n . al) (call (lookup n) al)))
(call (lambda (r al) (apply (cadr r) (list self al)))))
(lambda (msg . args)
(call (lookup msg) args))))
(define (counter% i)
(make-object
(list 'get (lambda (s al) i))
(list '+ (lambda (s al) (counter% (+ (s 'get) (car al)))))
(list '- (lambda (s al) (counter% (- (s 'get) (car al)))))))
@2-3
2-3 / obj_1.scm
Last active December 12, 2018 12:56
(define (counter% i)
(lambda (msg arg)
(case msg
((get) i)
((+) (counter% (+ i arg)))
((-) (counter% (- i arg)))
(else (error msg "Unable to answer message.")))))
@2-3
2-3 / bestfetch.sh
Created November 12, 2015 18:11
rice
#!/bin/sh
# Prints system information
# Lightweight alternative to screenfetch etc.
echo "It's a UNIX system, probably!";