Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
TypeScript

mekselperter
Registered User
Quote
2023-09-25 08:25:30

Heyoo,

Found this engine a while ago, been noodling around every now and then.. :3

Now whilst downloading some scripts from you guys here and there, I noticed no-one is leveraging TypeScript at all ?

Couldn't really find anything on it either..

Soo, I'm nearly done creating types for everything in CC.

Let me know if you guys are interested :)

I'm adding some "advanced" typings, like this, for example:


interface SceneNode {
id: string
Type: NodeTypes
Name: string
Position: vector3d
Rotation: vector3d
Scale: vector3d
Visible: boolean
}

type NodeKeys = Exclude<keyof NodeProps, 'id'>

/**
* Sets the property value of a scene node.
* - The name is displayed in the editor's property window.
* @param node
* @param property
* @param value
*/
function ccbSetSceneNodeProperty<P extends NodeKeys>(
node: SceneNode,
property: P extends 'Visible' ? P : never,
value: boolean
): void
function ccbSetSceneNodeProperty<P extends NodeKeys>(
node: SceneNode,
property: P extends 'Position' | 'Rotation' | 'Scale' ? P : never,
...args: [value: vector3d] | [x: number, y: number, z: number]
): void
function ccbSetSceneNodeProperty<P extends NodeKeys>(
node: SceneNode,
property: P extends 'Type' ? P : never,
value: NodeTypes
): void
function ccbSetSceneNodeProperty<P extends NodeKeys>(
node: SceneNode,
property: P extends 'Name' ? P : never,
value: string
): void



okeoke
Registered User
Quote
2023-09-25 09:37:08

Hi mekselperter,

Are you talking about typescript declaration files, i.e. d.ts? I've written one to use for vscode autocomplete, you can find it here if you need it:https://drive.google.com/file/d/...


mekselperter
Registered User
Quote
2023-09-25 10:02:15

Ah cool, that could've saved me a bit of time :) !

I'm stealing a couple of lines from there haha !

I'm adding a few TypeScript magics on top of that :)


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "I?ternational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact