An alternate interface for DroidScript to app.*.
This project is currently in beta and unstable: large chunks of code may suddenly change or appear. If something seems missing, try uninstalling/reinstalling.
yarn add https://github.com/EGM/droidscript-alt
MIT
import { alt } from "droidscript-alt"
function OnStart() {
const layout = alt.createLayout("Linear", "VCenter,FillXY");
const text = alt.createText("Hello")
.setTextSize(32);
layout.addChild(text);
alt.addLayout(layout);
}
Some differences from the standard basic example:
-
The
importstatement. This project is meant to be modularized. Create layouts in one file, import them into a main app if you want. -
Camel-casing. Method names have been changed from
GetType()togetType(), more inline with mainstream programming practices. -
object.set*methods returns the object it modifies, so multiple set methods can be chained together. Someobject.add*also chain, such as.addChild.
Other differences that aren't shown:
-
Types. Because TypeScript.
-
Standardized parameter names. For example
clr,color, andcolourare all nowcolorandtxtandtextare nowtext. -
Abbreviated parameters have been expanded. For example
AdjustColor(hue,sat,bright,cont)is nowadjustColor(hue,saturation,brightness,contrast), as this works better with Intellisense and TypeScript tools working with the source code.
This wasn't created because DroidScript is broken, it works great.
I started out wanting a better way to organize my code than what was offered -- just wanting to write a quick type file and use TypeScript and Rollup to pull everything together. Suddenly it was like finding out how sausage was made. Soon it became easier to rewrite app.js objects and functions as classes.
