Skip to content

Instantly share code, notes, and snippets.

View joskuijpers's full-sized avatar

Jos Kuijpers joskuijpers

  • The Netherlands
View GitHub Profile
------------ ADD SNOW
layers = tonumber(layers)
-- Transform to world parallelogram
local x,z, widthX,widthZ, heightX,heightZ = Utils.getXZWidthAndHeight(g_currentMission.terrainDetailHeightId, startWorldX, startWorldZ, widthWorldX, widthWorldZ, heightWorldX, heightWorldZ)
if self.snowMaskId ~= nil then
-- Set snow type where we have no other heaps or masked areas on the map.
-- Set mask for the target density map: the current value should be 0 (not existent).
function loadMap()
if server then
self.data = {["temperature"]={},["rain"]={}}
self:loadFromXML(defaultpath)
if mod file exists then
self:loadFromXML(mod file path)
end
end
local i = 0
while true do
local key = string.format("bla.gt(%i)", i)
if not hasXMLKey(file, key) then
break
end
-- Get the values here using key.."#val"
i = i + 1
@joskuijpers
joskuijpers / ideas.md
Last active November 29, 2016 21:22
Mod ideas

Ideas

Banking

  • Variable interest rates with GUI (and with economy integration)
  • Three types of loans
    • Short loan 60% equity 1 or 2 years high interest downpay
    • Mortagage 150% equity LifeLong medium interest
  • Investment 500% equity LifeLong low interest
return x()
.then(() => y())
.catch(() => {
return a()
.then(() => b());
});
EQUALS
return x()
All resources are accessed using SPhereFS protocol
Default root is ~sgm/
If / is not prefixed, it is implied
/ equals to ~sgm/
I want:
./ or ../ to start from current file
class Game {
constructor() {
assert(false && "Can't create another Game object");
}
get name() {
return "MyGame";
}
function logClass(targetClass: any): () => void {
let originalClass = targetClass;
// Function to create new instances of a class.
function construct(constructor: Function, args: any[]): any {
let cls = function(): void {
return constructor.apply(this, args);
};
cls.prototype = constructor.prototype;
function unwrapAsyncValue<T>(value: any, cb: (_err: any, _value: T) => void): void {
Promise.join(value, (unwrappedValue: any) => {
if (typeof unwrappedValue === "function") {
unwrappedValue(cb);
} else {
cb(null, unwrappedValue);
}
}).catch((err: Error) => cb(err, null));
}
@joskuijpers
joskuijpers / gist:1f9d57870eed11eca506
Created July 30, 2014 12:43
Sample output from generic pool and pool, using poolLog.
Small explanation: first, watch this in a way you can see 1 line in full length, else it is unreadable.
* 'create client' is a message from pool.connect() in pool.js, after pool.acquire has been called. Here i set a variable to the client, called ___key,with a small text and the current date. This is to recognize the client.
* Then you see messages from the generic pool: they are from the ide remover, that is scheduled when a client is inside the pool (not used). At the end of the functon, if number of client in the pool > 0, it reschedules, otherwise, it does not reschedule.
* Then it figures the client has timed out (timeout here being the pool timeout, defined in the configuration. I put it very very fast in order to be able to test this reasonably. (reap 500ms, idle timeout 10s).
* 'ended' is in pool.destroy() (factory). It will then set _destroying to true and poolCount to undefined, and call client.end() (stream).
* generic pool tells us that all clients are removed (correctly so).
* Then the error come