gwerneck's Recent Forum Activity

  • Actually, your code is lying to you! You asked it to say "Not found" if the find result is different from -1. However, a find result different from -1 means it did find something. It only returns -1 if a result wasn't found.

    In your case, find should return 8, since the FF0000 string starts, I believe, in the eighth character. If all you need is to know whether the bbcode exists in the code or not, it doesn't exist if find returns -1, and does if it returns anything else whatsoever.

    Good luck :)

  • I believe you're running into another version of the same problem I describe here:

    construct.net/en/forum/construct-3/scripting-51/declaring-objects-script-160208

    To put it simply, each script block has its own namespace, so the 'MyStreaming' variable isn't exactly destroyed - it simply cannot be accessed outside the block where it was created.

    The solution is to declare your stream in a way that's globally accessible. I don't know much javascript, so the way I've started to do it is by creating things by the window object, which is probably a dumb way to go about it, but works for me.

    What you'd do in your example is instead of declaring your stream using 'var myStreaming =', declare it like 'window.myStreaming =' - the window object will be accessible from your other block, and thus 'window.myStreaming.stop()' should hopefully work. Good luck!

  • I have found the solution!

    Apparently, the reason why you can't access things created on other blocks is because each block is a javascript function internally - so anything you declare normally is available only within the function's (or block's) namespace.

    There is a simple workaround, though - instead of declaring variables, functions etc. the normal way, you can set them by the window object -

    window.myVar = 'mystring' 
    // as opposed to: 
    var myVar = 'mystring'.
    

    Applying the same concept to the ffmpeg object worked seamlessly, and to 'copy' a function you use in the block into the window object you can simply encapsulate it like this:

    window.myFunc = function(param) { return actualFunction(param) }
    

    Then, later on, you can access the stuff you put in the window object in any script block like this:

    window.myFunc(param); // runs the actualFunction() as defined in the other script block, forwarding the parameter and returning whatever that function returns.
    alert(window.myVar); // alerts 'myString', as defined in the other script block 
    

    Not super elegant, hehe, but gets the job done!

  • So I'm trying to run ffmpegwasm in a construct project for something, but I really don't know what I'm doing so much. I've managed to include it as a 'main script', and initialize it in a script block:

    const { createFFmpeg, fetchFile } = FFmpeg;
    const ffmpeg = createFFmpeg({ log: true });
    

    Then I got it to work by setting up a few variables, and running the following code:

    ffmpeg.FS('writeFile', "video.mp4", await fetchFile(localVars.VideoURL));
     await ffmpeg.run(...parametersArray);
    	 runtime.callFunction("ffmpegComplete", result)
    
    

    This all works wonderfully, as long as it initializes and runs in the same scripting block. But that means every time I want to run ffmpeg, I need to initialize again!

    If I initialize at the start of the layout and then call it later, it says 'ffmpeg is not defined' - seems it doesn't have access to any functions, variables and other stuff that's created on another block.

    I've been reading up on it and I imagine the solution involves imports and exports, which I haven't been able to figure out how to use yet (I know very little javascript). Am I in the right path? Is there a simpler way for me to run that first bit of code so that the 'ffmpeg' object (as well as declared functions, variables etc.) is accessible to other blocks of javascript in my event sheet?

    Thanks in advance!

  • EDIT: I just read the bug report requirements and conformed my post to the standards. Sorry about that!

    Oddly enough, I'm sure I didn't delete the template - there wasn't any when I started the post.

    Problem Description

    Lately our intro screen started mysteriously crashing our devs' computers. We eventually tried downgrading NWJS and figured it only happens on the latest two versions, 0.30 and 0.31.

    Attach a Capx

    Here's the capx: drive.google.com/file/d/1v2CdCfp_SDK6zNkhmpPsRApRJhHfmfbn/view

    Description of Capx

    All there is in the capx is a webm video and an event to play it.

    Tutorial

    Just run the layout on this minimal capx (or presumably any other webm/any other video) and you'll see what I'm talking about. It happens 100% of the time, whether its exported or not. It seems to consume more and more memory until the video stops playing adequately, and eventually crashes.

    Expected Result

    No crash, obviously.

    Affected Browsers

    NWjs 0.29 or later

    Operating System and Service Pack

    Multiple Systems including windows 7, 8 and 10.

    Construct 2 Version ID

    r259

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hmm, now that you mention it, I think you're right. This idea occurred to me after reading this post

    I still think I could benefit from locking game logic at lower fps and interpolating the graphics, but that's probably not the way to do it, yeah...

  • Yes, I know all about deltatime. However, using dt in game logic results in small inconsistencies which are a problem in my case.

    It'd be best for me to have the game logic run at a lower fps and render elements smoothly using interpolation and deltatime, as modern games tend to do - hence my question. Does anybody know how if it's possible?

  • I've been looking to make my game logic run at 30 fps, to make movement deterministic and consistent even if the framerate fluctuates.

    I can achieve that by easily moving objects with custom events, by making stuff like this:

    | tickcount%2 = 0 | set x to self.x+10 |

    (This object would move 10 pixels to the right whenever tick count is divisible by two - so every other tick)

    It would be really nice, however, if I could have the default behaviors do that - such as the platformer, sine, and custom movement ones. Is it easy to make a change to the behaviors so they update every other tick? How would I go about doing that?

  • Holy moly batman, yes, definitely! I've always wanted to make a 2.5d game but have no idea how it works. Would never guess Construct could do it, either! I'd be very interested in a capx, even if not clean (or a build if you're not willing to send the capx yet)

    Thanks!

  • Ah, I see. Thanks again!

  • Thanks Thndr! It helps to be able to put a name to the feature.

    Ashley Thanks for the response! I tested a game of mine that's online, using the most recent Chrome Beta on Android, and wasn't prompted with the little "Add to Home Screen" pop-up. Is there something I can do at the moment to test that feature on my games? Or will it be an option in one of the next C2/C3 builds?

  • I have noticed that C3, a HTML5 application, can be turned into something resembling a mobile or PC app in a single click when loaded in Chrome's most recent beta. I found that very neat.

    Does that mean we can expect that feature for our games once chrome updates? Does anyone know where we can read more about this functionality?

    Thanks!

gwerneck's avatar

gwerneck

Member since 3 Feb, 2015

None one is following gwerneck yet!

Trophy Case

  • 9-Year Club
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

12/44
How to earn trophies