Compare commits

..

2 Commits

Author SHA1 Message Date
f1e4f91461 functional 2021-06-28 16:50:16 -05:00
18b3debb53 functional 2021-06-28 16:27:03 -05:00
3 changed files with 47 additions and 40 deletions

46
ts-lua/dist/test.lua vendored
View File

@@ -161,9 +161,6 @@ function FeatureParent.prototype.____constructor(self, name, parent)
self.parentid = parent.id
self.parent:addChild(self)
end
print(
self:type()
)
self.feat = menu.add_feature(
name,
self:type(),
@@ -176,9 +173,9 @@ function FeatureParent.prototype.type(self)
return "parent"
end
function FeatureParent.prototype.hidden(self)
return Boolean(nil, self.feat.hidden)
return self.feat.hidden
end
function FeatureParent.prototype.sethidden(self, val)
function FeatureParent.prototype.setHidden(self, val)
self.feat.hidden = val
end
function FeatureParent.prototype.select(self)
@@ -239,7 +236,7 @@ function FeatureToggle.prototype.____constructor(self, name, parent, defaultvalu
defaultvalue = false
end
FeatureToggle.____super.prototype.____constructor(self, name, parent, handler)
self:setvalue(defaultvalue)
self:setValue(defaultvalue)
end
function FeatureToggle.prototype.type(self)
return "toggle"
@@ -247,7 +244,7 @@ end
function FeatureToggle.prototype.value(self)
return self.feat.on
end
function FeatureToggle.prototype.setvalue(self, val)
function FeatureToggle.prototype.setValue(self, val)
self.feat.on = val
end
function FeatureToggle.prototype.toggle(self)
@@ -262,7 +259,7 @@ function FeatureNum.prototype.____constructor(self, name, parent, defaultnum, ha
defaultnum = 0
end
FeatureNum.____super.prototype.____constructor(self, name, parent, handler)
self:setnum(defaultnum)
self:setNum(defaultnum)
end
function FeatureNum.prototype.type(self)
return "action_value_i"
@@ -270,25 +267,25 @@ end
function FeatureNum.prototype.num(self)
return self.feat.value_i
end
function FeatureNum.prototype.setnum(self, val)
function FeatureNum.prototype.setNum(self, val)
self.feat.value_i = val
end
function FeatureNum.prototype.min(self)
return self.feat.min_i
end
function FeatureNum.prototype.setmin(self, val)
function FeatureNum.prototype.setMin(self, val)
self.feat.min_i = math.floor(val + 0.5)
end
function FeatureNum.prototype.max(self)
return self.feat.max_i
end
function FeatureNum.prototype.setmax(self, val)
function FeatureNum.prototype.setMax(self, val)
self.feat.max_i = math.floor(val + 0.5)
end
function FeatureNum.prototype.step(self)
return self.feat.mod_i
end
function FeatureNum.prototype.setstep(self, val)
function FeatureNum.prototype.setStep(self, val)
self.feat.mod_i = math.floor(val + 0.5)
end
____exports.FeatureNumToggle = __TS__Class()
@@ -303,7 +300,7 @@ function FeatureNumToggle.prototype.____constructor(self, name, parent, defaultn
defaultvalue = false
end
FeatureNumToggle.____super.prototype.____constructor(self, name, parent, defaultnum, handler)
self:setvalue(defaultvalue)
self:setValue(defaultvalue)
end
function FeatureNumToggle.prototype.type(self)
return "value_i"
@@ -311,7 +308,7 @@ end
function FeatureNumToggle.prototype.value(self)
return self.feat.on
end
function FeatureNumToggle.prototype.setvalue(self, val)
function FeatureNumToggle.prototype.setValue(self, val)
self.feat.on = val
end
function FeatureNumToggle.prototype.toggle(self)
@@ -333,17 +330,12 @@ local FeatureAction = ____Feature.FeatureAction
local FeatureParent = ____Feature.FeatureParent
local fps = 60
local duration = 5
local testParent = __TS__New(FeatureParent, "class")
local testParent = __TS__New(FeatureParent, "test")
__TS__New(
FeatureAction,
"testClass",
"display box",
testParent,
function(____, f)
if f.parent then
print(
(("parent: " .. f.parent.name) .. "\nid: ") .. tostring(f.parent.id)
)
end
do
local i = 0
while i < (fps * duration) do
@@ -358,6 +350,18 @@ __TS__New(
end
end
)
__TS__New(
FeatureAction,
"print parent data",
testParent,
function(____, f)
if f.parent then
print(
(("parent: " .. f.parent.name) .. "\nid: ") .. tostring(f.parent.id)
)
end
end
)
return ____exports
end,
}

View File

@@ -1,4 +1,4 @@
type AnyFeature = FeatureParent|FeatureAction|FeatureToggle|FeatureNum;
type AnyFeature = FeatureParent|FeatureAction|FeatureToggle|FeatureNum|FeatureNumToggle;
export class FeatureParent {
@@ -13,9 +13,9 @@ export class FeatureParent {
feat: Feat;
hidden(): boolean {
return Boolean(this.feat.hidden);
return this.feat.hidden;
}
sethidden(val: boolean) {
setHidden(val: boolean) {
this.feat.hidden = val;
}
@@ -30,7 +30,6 @@ export class FeatureParent {
this.parent.addChild(this);
}
print(this.type());
this.feat = menu.add_feature(name, this.type(), this.parentid, () => this.select());
this.id = this.feat.id;
}
@@ -89,7 +88,7 @@ export class FeatureToggle extends FeatureAction {
value(): boolean {
return this.feat.on;
}
setvalue(val: boolean) {
setValue(val: boolean) {
this.feat.on = val;
}
toggle() {
@@ -98,7 +97,7 @@ export class FeatureToggle extends FeatureAction {
constructor(name: string, parent?: FeatureParent|null, defaultvalue = false, handler?: (feat: AnyFeature) => void) {
super(name, parent, handler);
this.setvalue(defaultvalue);
this.setValue(defaultvalue);
}
}
@@ -110,34 +109,34 @@ export class FeatureNum extends FeatureAction {
num(): number {
return this.feat.value_i;
}
setnum(val: number) {
setNum(val: number) {
this.feat.value_i = val;
}
min(): number {
return this.feat.min_i;
}
setmin(val: number) {
setMin(val: number) {
this.feat.min_i = Math.round(val);
}
max(): number {
return this.feat.max_i;
}
setmax(val: number) {
setMax(val: number) {
this.feat.max_i = Math.round(val);
}
step(): number {
return this.feat.mod_i;
}
setstep(val: number) {
setStep(val: number) {
this.feat.mod_i = Math.round(val);
}
constructor(name: string, parent?: FeatureParent|null, defaultnum = 0, handler?: (feat: AnyFeature) => void) {
super(name, parent, handler);
this.setnum(defaultnum);
this.setNum(defaultnum);
}
}
@@ -149,7 +148,7 @@ export class FeatureNumToggle extends FeatureNum {
value(): boolean {
return this.feat.on;
}
setvalue(val: boolean) {
setValue(val: boolean) {
this.feat.on = val;
}
toggle() {
@@ -158,7 +157,7 @@ export class FeatureNumToggle extends FeatureNum {
constructor(name: string, parent?: FeatureParent|null, defaultnum = 0, defaultvalue = false, handler?: (feat: AnyFeature) => void) {
super(name, parent, defaultnum, handler);
this.setvalue(defaultvalue);
this.setValue(defaultvalue);
}
}

View File

@@ -1,14 +1,11 @@
const fps = 60,
duration = 5 //seconds
import { FeatureAction, FeatureParent } from './classes/Feature';
import { FeatureAction, FeatureParent } from './classes/Feature'
let testParent = new FeatureParent('class');
let testParent = new FeatureParent('test')
new FeatureAction('testClass', testParent, (f) => {
if (f.parent)
print(`parent: ${f.parent.name}\nid: ${f.parent.id}`)
new FeatureAction('display box', testParent, f => {
for (let i = 0; i < fps * duration; i++) {
@@ -18,3 +15,10 @@ new FeatureAction('testClass', testParent, (f) => {
}
})
new FeatureAction('print parent data', testParent, f => {
if (f.parent)
print(`parent: ${f.parent.name}\nid: ${f.parent.id}`)
})