> Write a blog post about this code trick:
import logging
import os
from funcy import monkey
from django.db.models.query_utils import DeferredAttribute
local rosetta = { | |
mod = "mod_necro" | |
// source_lang = "en" | |
lang = "ru" | |
version = "0.3.0" | |
// minVersion = "0.2.1" | |
} | |
local function green(text) { | |
return ::Const.UI.getColorized(text + "", ::Const.UI.Color.PositiveValue) |
import asyncio | |
class AbstractToken: | |
async def wait(self, is_async=True): # A placeholder for the real thing | |
await asyncio.sleep(0.2) | |
return | |
async def wrap(self, task): | |
future = asyncio.ensure_future(task) |
// Cycle bros | |
local bros = World.getPlayerRoster().getAll(); | |
foreach (bro in bros) { | |
logInfo(bro.getName()); | |
// ... | |
} | |
// Add skill to a bro | |
local bro = ::getBro("Hubert") | |
local trait = this.new("scripts/skills/traits/master_trait"); |
// Cook and Blacksmith fix | |
::mods_queue(hx.ID, null, function () { | |
logInfo("load hitpoints debug and fix"); | |
local inAssetManagerUpdate = false; | |
local gen = ::rng_new(); | |
::mods_hookNewObjectOnce("states/world/asset_manager", function (o) { | |
this.logInfo("hx: hook asset_manager"); | |
local update = o.update; |
Script Error | |
the index 'getID' does not exist | |
Function: | |
onUse -> scripts/skills/actives/cascade_skill.nut : 90 | |
Variables: | |
ret = True, target = Table, _targetTile = Instance, _user = Instance, this = Table | |
Function: | |
-> msu/hooks/skills/skill.nut : 334 | |
Variables: | |
use = Function, targetEntity = Table, container = Instance, _forFree = True, _targetTile = Instance, this = Table |
::mods_hookExactClass("ai/tactical/behaviors/ai_engage_ranged", function (o) { | |
local function isRelevant(_actor) { | |
return !_actor.isNull() && !_actor.m.IsDying && _actor.m.IsAlive; | |
} | |
local function cleanup(_b) { | |
_b.m.ValidTargets = _b.m.ValidTargets.filter(@(_, t) isRelevant(t.Actor)); | |
_b.m.PotentialDanger = _b.m.PotentialDanger.filter(@(_, a) isRelevant(a)); | |
} |
> Write a blog post about this code trick:
import logging
import os
from funcy import monkey
from django.db.models.query_utils import DeferredAttribute
import gc | |
import sys | |
import types | |
from collection import deque | |
import random | |
def getsize(obj): | |
BLACKLIST = type, types.ModuleType, types.FunctionType | |
if isinstance(obj, BLACKLIST): |
::mods_registerMod("mod_fix_ambitions", 0.1, "Fix ambitions not fullfilling"); | |
::mods_queue("mod_fix_ambitions", "mod_hooks(>=19)", function() { | |
this.logInfo("fa: loading"); | |
::mods_hookNewObject("ambitions/ambition_manager", function(obj) { | |
this.logInfo("fa: hook ambition manager"); | |
local update = obj.update; | |
obj.update = function() { | |
this.logInfo("fa: ambitions.update available=" + this.isAvailable() + " ambition=" + this.m.ActiveAmbition); |
def getsize(obj): | |
import sys | |
from types import ModuleType, FunctionType | |
from gc import get_referents | |
BLACKLIST = type, ModuleType, FunctionType | |
if isinstance(obj, BLACKLIST): | |
raise TypeError('getsize() does not take argument of type: '+ str(type(obj))) | |
seen_ids = set() | |
size = 0 | |
objects = [obj] |