Smith

COG

General

You can place an autoexec.cog file in your JK directory to have a COG load and run regardless of what level is loaded.

It will be instantiated after all level cogs are instantiated, so its resulting ID will be equal to the total number of level cogs; but it will be lower than any subsequently loaded inventory cogs.

Language features

Strings!! Yes, the “flex” value type in Smith’s COG engine natively supports text and even seamless conversion between strings and other value types. This does not cause any issues with existing JK assets, but unlocks great flexibility for levels/mods designed for Smith. For example, SetThingModel(player, "kyh4.3do"); is totally cool. Even MoveToFrame(door, "2", "12.35"); is perfectly valid; the parsing to int and float happens automatically since MoveToFrame is expecting numerical values for those arguments.

I also plan to add support for using the binary addition operator to concatenate strings (eg. blah = playername + " is a tool";) and for unary postfix increment (eg. for(x=0; x<100; x++)). These features aren’t implemented right now but it’s really easy to do so and some rainy day I’m writing code instead of information webpages then it’ll get in there.

allows user to pick file. flags 0x0 for opening file (must exist), flags 0x1 for saving file. filter format is like “Text Files (*.txt)|*.txt”. note this does not actually open or create a file; just returns a file path. returns -1 if canceled

Bitmap

Calling BitmapCreate will generate a permanent bitmap object. It is your responsibility to either keep reusing it or call BitmapDestroy when finished otherwise memory leak will occur.

Verbs

Verb

Description

bmpID = BitmapCreate(width, height)

create a new bitmap. make sure to call BitmapDestroy when finished to avoid memory leak

BitmapDestroy(bmpID)

frees bitmap from memory

BitmapClear(bmpID, color)

color is specified as string, either “r g b” or “r g b a” with each component being 0.0 - 1.0

bmpID = BitmapLoad(filename)

loads a jpg,png,bmp as a new bitmap. make sure to call BitmapDestroy when finished to avoid memory leak

bmpID = BitmapRenderWorld(thing, width, height, fov)

renders the world from a thing’s perspective, generating a bitmap of the desired width/height, and with the specified camera field-of-view. make sure to call BitmapDestroy when finished to avoid memory leak

generates a fake .mat file in memory with the specified name and colormap and cel. can be used to override existing materials. optional last parameter defines an emissive map if desired

Example: Security Camera (render-to-texture)

Repeatedly render the world from a ghost thing’s perspective into a bitmap. Inject that bitmap as a fake material filename of “rendertest.mat” and set the texture of the security TV’s surface to it.
Also pregenerates a horizontal “scanlines” overlay to superimpose to make it look more like a tv screen.