brent_hamel's Forum Posts

  • 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!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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/

  • 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

  • I'm not sure I understand what how a "TAB" character in the SpriteFont with a custom width would work... It's also the pressing of the Tab key that's the issue... I can already send the ascii byte code for Tab to the binaryData, and when it gets retrieved as Text, it works properly, the issue is that I can't seem to use the Tab key to send that byte data... it works fine if I wire it to a different key

  • I'm definitely using SpriteFonts as opposed to regular text objects. So I do know the dedicated character widths (monospaced fonts are king!)

    I suppose that given that I know the structure of the different types of "lines" that can exist in 6502 code, perhaps attacking at on a line-by-line basic might be best.

    Lines can contain: directives, opcodes, constant labels, address labels, variables, addresses in their various modes, etc, and comments of course. But proper formatting is required for the assembler to work properly, so I can always enforce that directly and have a much more predictable set of possibilities in terms of what each line might look like.

    I'll be implementing an actual blinking cursor at some point as well, plus text highlighting, copy/pasting, etc... So trying to solve the visualizationof these sooner than later I think is key.

    What would be nice, is if there was a way to return an XY position of a token within the spritefont's display box, and then send it over to a tilemap, as masking with a tilemap is something I've done in the past and can work quite well, assuming you know where the character location to mask is.

  • Part of the goal if this editor is to be able to save and load external files that will work and behave correctly inside of other editors as well. Primarily Notepad++.