brent_hamel's Recent Forum Activity

  • Apologies if this is a stupid question, but I've been unable to find a solution for this for about 6 hours now...

    How can I set the Class and Id properties of form control objects, like buttons, with JS when I first create a new instance of one?

  • I'm also running into an issue regarding eventListeners in conjunction with the Mouse and Button objects... I've successfully got a toggle button working, that animates based on CSS styling... however, I'm unsure how to add properties like :hover, and :active through setCssStyle(), as I also want a button that only remains down while the mouse button is down.

    I've got my "click" event listener on my button, and my mousedown/mouseup on the runtime, however it seems that click overrides the others, and the others only fire when the mouse cursor is not over a button, is there a way around this?

    Ultiamtely, the desired behaviour is that its clicked, animates being pressed, stays in the down position regardless of mouse cursor location, and then releases when the mouse button is released.

    I had thought it would make sense just to have a string that constantly reports the state of the mouse button, but that seems difficult to achieve here...

  • Fair point!

    https://shorturl.at/rweV2

    So the goal with this test project, was to have the generated noise move from the main window to a popup window, when clicked, then have the popup close when its clicked. Unfortunately, I've only managed to have the popup close when the main window is clicked a second time. I also want to detect when the main window is closed, so it can close the popup at the same time. Eventually this would evolve into saving the coords of the popup so the next time the project is run, it'll open the popup in the same place, etc.

  • For context, I'm trying to open and close secondary windows as undockable UI elements of an app I'm working on, that can be moved outside the main window, moved to secondary monitors, etc, that will be auto closed if the main window is closed.

    (I'm also looking for a way to remove the titlebars from the main window and secondary windows as well, given that this is intended as a desktop app first, and web app second)

  • Hmm interesting... I was unable to get event listeners like "beforeunload" and "click" to work... I'm sure I'm trying to do them wrong, as this is a JS learning journey for me 100%. My entire knowledge base prior to my current project is Construct Classic, Construct 2, Construct 3 (event sheets only for all) and then 6502 Assembly. So there's definitely a curve lol...

    That said, an example cap for non C3 specific event listeners would be much appreciated by me and maybe others.

  • Just a quick question...

    I haven't been able to make work, or find any reference in the scripting section of the manual to eventListener "beforeunload"

    I'm looking to use it as I'm working on something that needs to do some things before actually closing the app, but triggered BY closing it.

    What's the best approach inside C3's JS implementation?

    Thanks in advance!

  • This is absolutely the answer I needed. I never once thought to put the js file in the project files folder... I just had it as a standalone file in the scripts folders. Awesome... I feel like I'm THIS close to have a working NES soundchip, at least in terms of the instruments and playback capability (it doesn't read roms or nsfs...yet)

    Ultimately, this combined with the WebMIDI plugin (which is awesome and I would LOVE to see become an official plugin) will alllow users to make their own NES music

  • Does C3 allow AudioWorklets in scripting? And if so, how can I implement them, as currently I'm trying to register a simple noise generator, but get a "registerProcessor" is undefiuned error.

    registerProcessor( "Noise", class extends AudioWorkletProcessor {
    	constructor(){ 
    		super();
    	}
    	process( inputs, outputs ) {
    		const output = outputs[0][0];
    		for ( let i = 0; i < out.length; i++ ) {
    			output[ i ] = ( Math.random() * 2 ) - 1;
    		}
    		return true;
    	}
    });
    

    I'm doing this because using the existing audioBufferNode is too limited in terms of updating in realtime, and the built in oscillators are not great...

    Ultimately the goal is to replicate the NES's APU, which consists of:

    - 2 PulseWave Channels (needs to facilitate 12.5%, 25%, 50%, and 75% (25% inverted) duty cycles)

    - Triangle Channel (a real NES has a malformed and stepped triangle, rather than a smooth triangle, so a custom waveform is needed here)

    - Noise Channel (the NES could generate 16 preset pitches of noise across 2 "modes" of noise, as well as a long form noise generation)

    - DPCM Channel (this handled all the sample playback as heard in games like "Double Dribble" and "Lifeforce"

    Ultimately my goal is to create something that can playback NES audio, as well as allow the user to eventually create their own. So accuracy to the real sound quality is important.

  • So I've been taking a little time to look at Regex in combination with BBCode, and that's proving successful.. mostly... I can get it to work properly about 50% of the time. So there's clearly something I'm missing.

    Example 1:

    hlColor = "red"

    string = "$hexValue"

    regexReplace( Self.Text, "\$\S+", "gi", "[color=" & hlColor & "]$&[/color]" )

    // \$ = find "$", \S+ = include all non-white spaces until reaching a white space

    // "gi" = "g"lobal: fins all matches, "i"nsensitive: ignore upper/lowercase

    Expected Result: "$hexValue" // appears coloured "red"

    Received Result: "$hexValue" // appears coloured "red"

    Example 2:

    hlColor = "red"

    string = "123"

    regexReplace( Self.Text, "\d", "g", "[color=" & hlColor & "]$&[/color]" )

    // \d = find any decimal digit

    Expected Result: "123" // appears coloured "red"

    Received Result: "123" // appears coloured "red"

    So these work as expected, however...

    Example 3:

    hlColor = "red"

    string = "Label:"

    regexReplace( Self.text, "\w+\b:", "gi", "[color=" & hlColor & "]$&[/color]" )

    // \w+ = find entire word, \: = that ends with ":"

    Expected Result: "Label:" // appears coloured "red"

    Received Result: "[color=red]Label:" // BBCode is escaped and printed, uncoloured

    Example 4:

    hlColor = "red"

    string = "%10011001"

    regexReplace( Self.text, "\%\S+", "g", "[color=" & hlColor & "]$&[/color]" )

    // \% = find "%", \S+ = include all non-white spaces until reaching a whitespace

    Expected Result: "%10011001" // appears coloured "red"

    Received Result: "[color=red]%10011001" // BBCode is escaped and printed, uncoloured

    So obviously these do not work, but I can't figure out why. All I can think is that there's a sneaky "\" being added somewhere that is causing the first half of the BBCode to escape and be treated as plain text. Unless I'm missing something...

    In terms of match selection, everything seems to be working properly. I've also double checked the selections here https://www.regexpal.com/

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This works perfectly!! Now I just need to find the best way to parse the text for each type of token I want to highlight.

    So far I'm looking at:

    - Directives (preceded by ".")

    - Labels (followed by ":" when set, but not when referenced)

    - Numbers: (preceded by "#" for a literal value, else its an address)

    - Binary (preceded by "%")

    - Decimal (no prefix or suffix)

    - Hex (preceded by "$")

    - Opcodes (56 unqiue 3 letter tokens)

    - Illegal Opcodes (20 unique 3 letter tokens + one 4 letter token)

    - Comments (preceded by ";" and continues for rest of the line)

  • Also, this seems like it'd be a useful Keyboard Object Property. Just to have a little checkbox somewhere to toggle "TAB Default Behaviour" or something.

  • Ok... this is sick. Can we be friends? lol

brent_hamel's avatar

brent_hamel

Member since 31 Dec, 2009

None one is following brent_hamel yet!

Trophy Case

  • 14-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

18/44
How to earn trophies