Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt McFarland MattMcFarland

View GitHub Profile
View add-ware-to-x4.md

Adding a new ware

Please consider every mentioning of {WARE_ID} to be replaced of what ware we want to add, and it must be lowercase to ensure compatibility across systems. Generally, we will be prefixing every ware we add with something unqiue to avoid any collision issues with other mods. This is mentioned as {PREFIX}

UPDATE: you can simplify this process by automating majority of the work using this tool.

Create new assets

To add a ware and the production of the ware to the game, the following files need to be created from scratch:

@MattMcFarland
MattMcFarland / readme.md
Last active Dec 1, 2020
Run X4 Foundations in debug mode with timestamped file names so you don't lose them.
View readme.md

Run X4 Foundations in debug mode.

The handy script below (x4-debug.bat) can be used as a shortcut to start x4 in debug mode. You get:

  • All debug messages turned on
  • All debug logs sent to a timestamped file, so you dont lose anything

Setup

Copy paste the code in the file below, then update the value for X4_EXE_PATH - change it to wherever X4.exe is located.

@MattMcFarland
MattMcFarland / Create a tree with path string.js
Created Jun 30, 2017
Create a tree with path string created by MattMcFarland - https://repl.it/JC8r/22
View Create a tree with path string.js
const pathString = 'one/two/three';
function buildTree(pathString) {
const pathArray = pathString.split('/')
let pathList = {}
for (var i = pathArray.length - 1; i >= 0; i--) {
let newObj = Object.assign({}, pathList);
pathList = {
[pathArray[i]]: newObj
View random-dungeon.lua
-- Copyright(c) Matt McFarland - 2017
-- MIT LICENSE
-- This will create rooms using the BSP method
rooms = {}
function _init()
local main_container = container(0, 6, 127, 121)
local max_depth = 6
local container_tree = split_container(main_container, max_depth)
@MattMcFarland
MattMcFarland / Grid.js
Created Apr 14, 2017
A 2d grid library (with unit tests)
View Grid.js
const assert = require('assert')
const transpose = (array) => array.reduce((p, n) => n.map((item, i) => [...(p[i] || []), n[i]]), [])
/**
* @class Grid
*/
class Grid {
/**
* @static transpose
* @param grid - grid to transpose
View test.lua
function _init()
my_grid = make_grid(10,10)
.map(set_wall)
my_grid.each(log)
room = my_grid
.select(4, 4, 7, 7)
.map(set_blank)
View js verify with chance.js
const jsc = require('jsverify')
const Chance = require('chance')
const chance = new Chance()
chance.mixin({
user: () => ({
first: chance.first(),
last: chance.last(),
email: chance.email()
})
})
View jsverify with random user.js
const emailGenerator = jsc.asciinestring.generator.map(str => `${str}@example.com`)
const arbUser = jsc.record({
first: jsc.asciinestring,
last: jsc.asciinestring,
email: jsc.bless({ generator: emailGenerator })
})
View jsverify with options.js
// lets test our user here:
const checkOptions = {
rngState: '074e9b5f037a8c21d6',
tests: 2
}
// lets test our user here:
jsc.check(jsc.forall(jsc.integer, arbUser, (a, user) => {
console.log({a, user})
return true
}), checkOptions)
View chance random and js verify.js
const jsc = require('jsverify')
const Chance = require('chance')
const chance = new Chance()
chance.mixin({
user: () => ({
first: chance.first(),
last: chance.last(),
email: chance.email()
})
})
You can’t perform that action at this time.