gwerneck's Forum Posts

  • 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

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Totally on board, man. I think it was a bad move to introduce Construct 3 with such controversial stuff instead of features, but still it's sad to see everyone reacting so poorly and being so angry instead of giving it a chance.

    That being said, I'm fearful that C3 will be tied to chrome even when offline. Hoping the offline version will be standalone.

  • I don't think it's the save/load state that's causing it... I switched mine so that, instead of saving and loading, it restarts the layout when you start recording and when you start playing, and it's still wildly inconsistent.

    Your example does play back perfectly every time. I was under the impression it was due to less room for error, but then I made the character and moving blocks faster, then artificially lowered framerate, and still got identical results. I am not sure why mine doesn't work, but I'll try and adapt your code into my game and see if it does. Thanks for your help!

  • The "trigger once" condition prevents an event from activating multiple times once its other conditions are met.

    For instance: If you have an event with the conditions "ObjectA is overlapping ObjectB" and "Trigger Once", it would trigger once when starts ObjectA overlapping with ObjectB, and then wait for them to stop overlapping to check again.

    I'm afraid there's no event to have something happen once and then never again in the game, but it should be simple to achieve by various other means.

    In your case, you could simply move the "Add 1 to mainbar_speed" to the events that set the object's level and charge the player money. This way, it'll add to the global variable at the moment you upgrade, and only then.