KCDS 1.2.5

KCDS 1.2.5

Clothing mods are worn, books install at every start and can show pictures made at run time, furnished houses keep their own doors, beds and ladders, and scripts can place cooking pots of their own.

New

  • Prop.spawn('prefab:<name>', position, orientation, 1, { doors: false }) builds a game prefab without the doors it hangs in its openings (each a prefab of its own that holds an AnimDoor). A house keeps its interior (clip volume, environment probe, interior fog), so it is lit as an interior, and its floors give footsteps, while you hang the doors you want with Door.spawn. An unknown option or a doors value that is not true or false throws a TypeError; a mesh still takes only 'static', 'rigid' or 'none'.
  • SmartObject.spawn({ blueprint, position, rotation, furniture: false }) builds only a blueprint's use (lying in a bed, sitting on a bench or chair, a station's work) without the blueprint's own model, so the use serves a model of your own placed there, such as a level's royal bed copied with Prop.spawn('bed_double_royal_a', ...). smartObject.furniture tells which it is, and toJSON() keeps furniture: false. A furniture value that is not true or false throws a TypeError.
  • SiegeLadder.spawn(kind, position, orientation, dimension, shape): shape { model, height, lean }, each optional, makes the ladder any of the game's ladder meshes (objects/manmade/common_fixtures/ladders/, by path or file name) with its own rung height (0.5 to 15 m) and lean (0 to 45 degrees); the kind gives what is left out. A mesh that is not a ladder or a value out of range throws a RangeError, an unknown key a TypeError. A World Architect export (server.js) now stands every whole ladder model exactly as the author placed it: that mesh, the work's rotation, no extra lean, and a rung height from the length in its name (ladder_rustic_300: 2.75 m). Export your work again to get this.
  • Book.image({ rgba, width, height }) makes a page picture from pixels the client script makes while it runs: rgba holds width * height * 4 bytes (R, G, B, A, rows from the top; a Uint8Array, Uint8ClampedArray or array), each side 1 to 2048. It is sent and mounted like a .dds the resource ships, once per content, and its name goes in Book.open's images (or the page markup). A picture that should sit at one place on the page is drawn into a transparent picture of the page's size. Malformed pixels throw a TypeError, a side out of range a RangeError.
  • Book.available() is false when the game's book reading did not start in this game; Book.open then returns null and Book.lastFailure() says to restart the game. Book.write called before bookOpened returns false and lastFailure() says to call it from bookOpened.
  • Writing in a book (Book.write(true)) shows a blinking caret after the text typed so far, as a text field does, and it goes when writing ends. Scripts still get only the text.
  • bookWritingEnded(id, page, text) carries the text written on the page, as the last bookTextChanged had it ('' when nothing was typed). The docs give both events as clients send them: bookTextChanged(id, page, text) and bookWritingEnded(id, page, text).
  • Items.register(id, { ..., category: 'document' }) lists a type whose visual is a document with the books and letters in the inventory, and Items.info gives it category 'document'. Its use action stays yours: playerCustomItemUse, not the game's reading. category is 'miscItem' (the default) or 'document'; anything else, or 'document' with a visual that is not a document, throws a TypeError.
  • stashInteract(player, stash, action) also fires with 'lockpick' and 'unlock' when a player picked a server-locked stash's lock or opened it with its key in their game, after the server's own checks. Return false to keep the stash locked: no stashUnlocked follows, and the player's game locks it again at their next open.
  • Npc.setAppearance({ beard: 'm_beard_00' }) shaves an NPC clean whatever beard its soul has: the barber's "Clean Shave" now fits every male face (Appearances.beards lists it, Appearances.random can draw it, and the character creator shows it as "Clean shave").
  • CookPot.spawn({ position, rotation, kind, dimension }) places one of the game's fireplaces with its cauldron, the village hearth ('home', the default) or the campfire ('camp'), as a cooking pot the server keeps like a level's. It returns the pot's GUID, starts empty with no meal, and after setFood, refill or topUpFrom players see its meal and fill, eat from it and get its fire as setFire holds it, as at any pot. CookPot.all lists it (in its dimension only), and CookPot.remove(guid) takes it and its fireplace away; it also goes when the resource that placed it stops. A kind other than 'home' or 'camp' throws a TypeError, and remove returns false for a level's pot.
  • Door.models() lists, and Door.spawn takes, every door leaf the game ships in objects/characters/assets/doors/, also those no level hangs (placements 0): lvl4_doors_double_a_left (the left wing of that double door), lvl4_door_h_right, lvl4_door_h_long_left and _right, lvl3_door_townhouse_d_right, lvl3_door_townhouse_g_red_right, lvl3_door_prison_right_cs and gate_a.

Fixes

  • Many registered item types: with about 470 or more types from Items.register, a joining player stopped receiving anything the server sent (Player.emit, Events.broadcast, World.snapToGround answers), with no error, while their own messages still reached the server. The whole list of types and of their names went as one message, and a message over 64 KB made a packet the player's game could not read, which the server sent again and again ahead of everything else. The lists now go in messages of about 12 KB, so all 4096 types Items.register allows reach the player, and any message too long for a packet is refused with a line in the server log instead of holding up the others.
  • Clothing mods: a mod's Libs/Tables/Character/CharacterComponent__<name>.xml with its item__<name>.xml loaded, but its clothing could not be worn: equip was greyed out, and Player.equip took the shirt off and drew nothing. The game reads a patch of that table as trees of their own beside its own, so the patch's path down to its clothing was a second, bare copy without the real nodes' values (the folder the model paths start from, the armour type). The player's game now merges such patches into the game's own clothing table at its start, along the path of names the patch gives, and mounts the merged table in their place. The mod's clothing is worn and drawn.
  • Books: on the first start of the game after an update the log said "BOOK unavailable" and books could not be opened or written in until the game was restarted. The book's lookup of a game function came after another feature had already hooked it; it now takes that function's address from that feature.
  • Web views: a page with the keyboard (Web.focus(id, true)) got an End keydown about every 47 ms, with no keyup, from a key that Windows reported as held although nobody pressed it. Lists scrolled to their end, a focused select jumped to its last option and End handlers fired over and over. A key already held when the page takes the keyboard is now left out until it is let go.
  • Stashes: a successful pick of a server-locked stash (an adopted level chest locked by a script) now reaches the server however the game opened the lock, so stashUnlocked(stash, player, 'pick') follows and the stash opens. A failed pick no longer counts as an unlock.
  • Level edits: a hidden bush, grass or stone of the level (LevelEdit.apply with hidden: true, or hidden with World Architect) that the level had merged into its vegetation cells stayed drawn, and the client log counted it as waiting ("LEVEL edits N: ... waiting"). Such plants are instances in the merged mesh of their 16 m cell, not objects of their own, so the edit never found them. A hidden edit now also hides the merged instances of its mesh within half a metre of its place, also in cells that load later, and shows them again when the edit is removed or no longer hides.
  • Chat.isOpen() stays false while the player writes in a book: writing borrows the chat's input line, and a resource that replaces the chat took the typing.

Docs

  • Events.toServer, Events.broadcast and player.emit: a string payload that is already JSON text arrives parsed ('{"a":1}' as the object { a: 1 }, '42' as 42), with no JSON.parse needed.
  • Game mods: how a clothing patch is merged into the game's table and which names its path must give.

Clients and servers of this version go together: ladders, registered item types and smart objects send new fields.