Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix slider.wickobj #371

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix slider.wickobj #371

wants to merge 2 commits into from

Conversation

twarped
Copy link

@twarped twarped commented Mar 1, 2023

changed the knob Default Script

this._bounds = 130;
this.parentClip.value = 0;
this._dragging = false;

to

this._bounds = 130;
this.parentClip.value = (this.x + this._bounds) / this._bounds / 2;
this._dragging = false;

this initially sets the value variable to the location the knob starts at to a number between 0 and 1.

changed the knob Update Script

if(!isMouseDown()) {
    this._dragging = false;
}

if(this._dragging) {
    this.x = mouseX - this.parentClip.x;
    if(this.x < -this._bounds) {
        this.x = -this._bounds;
    }
    if(this.x > this._bounds) {
        this.x = this._bounds;
    }
    this.value = (this.x + this._bounds) / this._bounds * 2;
}

to

if(!isMouseDown()) {
    this._dragging = false;
}

if(this._dragging) {
    this.x = mouseX - this.parentClip.x;
    if(this.x < -this._bounds) {
        this.x = -this._bounds;
    }
    if(this.x > this._bounds) {
        this.x = this._bounds;
    }
    this.parentClip.value = (this.x + this._bounds) / this._bounds / 2;
}

this lets the actual slider have a value variable, this also makes the return a number between 0 and 1

changed the slider's Default script

stop();

onEvent('update', function () {
  this.value; //returns a value between 0 and 1
});

this just makes the slider code much more intuitive so that people who don't know much about coding will have an easier time getting their slider to work.

twarped added 2 commits March 1, 2023 11:21
Update Script:
`if(!isMouseDown()) {
    this._dragging = false;
}

if(this._dragging) {
    this.x = mouseX - this.parentClip.x;
    if(this.x < -this._bounds) {
        this.x = -this._bounds;
    }
    if(this.x > this._bounds) {
        this.x = this._bounds;
    }
    this.value = (this.x + this._bounds) / this._bounds * 2;
}`
to:
`if(!isMouseDown()) {
    this._dragging = false;
}

if(this._dragging) {
    this.x = mouseX - this.parentClip.x;
    if(this.x < -this._bounds) {
        this.x = -this._bounds;
    }
    if(this.x > this._bounds) {
        this.x = this._bounds;
    }
    this.parentClip.value = (this.x + this._bounds) / this._bounds / 2;
}`

----------

Default Script:

`this._bounds = 130;
this.parentClip.value = 0;
this._dragging = false;`
to:
`this._bounds = 130;
this.parentClip.value = (this.x + this._bounds) / this._bounds / 2;
this._dragging = false;`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant