valerypopoff's Recent Forum Activity

  • valerypopoff

    Hi thanks for your plugin.

    Your plugin not working well if I add the NEWjs plugin. I want to export my application for windows. This seems to disrupt the JavaScript function call

    What's a "NEWjs plugin"?

  • Yeah I have notified valerypopoff about this already.

    I don't know what he's going to do, but he'll have to deprecate the action, and replace it with a new one.

    But essentially, after June, the plugin will just start to fail loading and the project that use it will fail to open.

    It's done: construct.net/en/make-games/addons/1/javascript

  • what'S a variadic condition or action ?

    It's a condition or action where you can add parameters with "+" button like when you call a function in Function plugin

  • valerypopoff - any thoughts on the future of this plugin and the vardic issue in C3? The plugin is so useful (thank you), but we hear chatter about vardic support being removed in C3, etc.

    [SDK] Addon 'ValerypopoffJSPlugin' ACE 'compare-exec-return-with-parameters' uses "variadic" parameter which is not supported in the SDK. Only use supported parameter types in your addons. Please refer to the SDK documentation for supported types.

    Hey! Well, I saw it coming. We discussed the issue with Ashley once and he made it clear that they're gonna outlaw the use of variadic params in conditions and maybe even in actions. When it finally happens, this is a problem to all my plugins, not only for Javascript Plugin.

    If they only kill variadic parameters in conditions, I'll remove the "Compare value" condition and instead of a direct comparison with a condition you'll have to get the value with the expression first (System->Set value TEMP to JS.Value(...)) and then compare it (System->Compare two values).

    If they kill variadic params in actions as well, then instead of just calling an action

    JS.CallFunction with params (1,2,3,4,5)
    

    you'll have to do

    JS.FlushParams
    JS.AddParameter (1)
    JS.AddParameter (2)
    JS.AddParameter (3)
    JS.AddParameter (4)
    JS.AddParameter (5)
    JS.CallFunction
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I guessed it. Yeah...i take it as it is, and i am thankfull. Cheers. But i will ask you again some questions ;-)

    Any questions about the plugin, sure!

  • Spax

    Okaaaaay. I can't (or want to) help you with learning JavaScript or Construct SDK anymore than I already did, so I'll go with "thanks, cheers".

  • Hey, this is a really great plugin !

    Thanks!

    1.) Can i command directly a "Sprite" inside C2, named "sprite_test" , by my outside "test.js"-file ? If yes, what is the command for it ? I didn´t found any info about it.

    Since every sprite or any other game object exists in the runtime (which is a javascript object), you can access it from js script. I have no idea how to do that and I wouldn't recommend it. You're not supposed to do that, so you'll probably break it if you try to do that. But. You can totally call Construct Functions from js and it's totally legit:

    function CallConstructFunc(func_name, args_array)
    {
    	args_array = (args_array === undefined) ? [] : args_array;
    	
    	if( typeof c2_callFunction != "undefined" )
    	{
    		return c2_callFunction(func_name, args_array);
    	}
    
    	if( typeof c3_callFunction != "undefined" )
    	{
    		return c3_callFunction(func_name, args_array);
    	}
    }
    

    2.) Does an external *.js have an impact to the whole performance of the game ?? I was just thinking about the communication of variables from extern JS to C2 and vise versa, that it could slow down the information flow.

    As stated in the JS Plugin documentation, plugin's ACEs are a little bit slower than native Construct Event Sheets instructions. A little bit. This is all due to the ACEs calls that take time. The js code itself is executed as fast as it can be on your device. The JS Plugin already uses caching that saves a lot of time on ACEs calls.

    And last but not least: it wasn´t easy to get info about API / commands for the extern JS / and intern C2 commands. All i found was in this thread here. Therefore i would recommend to the devs, to make a kind of API link onto their website (with a search function & examples)

    What API? There's a documentation here: valerypopoff.ru/construct/js-plugin What else do you want it to cover?

  • From what I understand, it's easy to access the runtime object from the global scope with:

    — window["c3runtime"] in C2.5

    — window["c3_runtimeInterface"]._GetLocalRuntime() in C3

    And if I get it right, it's only made so the engine itself could call functions like

    — window["cr_getSnapshot"]

    — window["cr_sizeCanvas"]

    — window["cr_setSuspended"]

    from within global functions and event listeners where the runtime object can't be accessed otherwise.

    I have a problem with it because when the runtime object is exposed to the global scope, it's impossible to impede shenanigans with the game data (from the javascript console, for example).

    Are you planning on doing something with it?

    Ashley

  • Toddler Thanks!

  • valerypopoff, do you think there is a way to say for example, create a class on the *.js side and then make every instance of a sprite have an instance of that class ?

    Think of it as polymorphism, your "extends" so to speak.

    I don't think that you actually meant polymorphism. Polymorphism means something else.

    I don't know what you mean by "make instance of a sprite HAVE an instance of js class". You certainly can if you just imagine that this is the case. Create two instances of a sprite. Create two instances of a js class. Done. They HAVE each other. Do whatever you want with them.

    I'd recommend you to think of a game object (not a class) as of a collection of two things:

    — a model that actually stores data, has methods that operate on its data, and virtually represents a game object

    — a view that visually represents a game object for a person who's looking at the screen

    If you're using javascript and classes and objects, a model is a js-object. A view is a sprite or a collection of sprites.

    If you have a good architecture, a game object has only one model and one view. When the model changes, the view should be updated (or update itself). In this sense, a view and a model should be somehow virtually connected so the view could update itself according to a certain model. A view should somehow address the model to get its data.

    If we're talking about game objects that have only one instance in the game, like Player, you just make the Player's view address the Player's model by remembering that the model is stored in the variable named "player". And that's it. There's no point of storing this name anywhere on the Construct side, because you'll eventually have to do JS.Call "player.update" and it's easier than doing JS.Call PlayerSprite.object_variable_name & ".update".

    But if we're talking about game objects that exist in plural, like enemies, then you're probably creating the js-objects and sprite instances dynamically. Then it makes sense to store js-objects in the array or something and then give every sprite the instance variable, like, "index" and set it to it's js-object's index in the array so you can later do:

    Enemy - on collision with - Bullet: JS.Call "Enemies_arr[" & Enemy.index & "].get_hit"

    Ooooor if you have to do this often and you came up with the handy js-wrapper:

    Enemy - on collision with - Bullet: JS.Call "EnemyManager.get_hit"(Enemy.index)

    If you're really interested in creating an elegant architecture using javascript, read this: en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

    And for the love of god read the manual: readymag.com/valerypopoff/valerypopoff-js-plugin I specifically illustrated there the very thing that you're asking about.

  • hugone I'd suggest you ask around in the Construct Discord community. People discuss stuff like that all day long there: discord.gg/HnuhDR

  • valerypopoff

    To access Javascript Variable:

    JS.Value("global_variable")

    JS.JSCodeValue("global_variable")

    Both does the same thing, so...why ?

    They work differently.

    JSCodeValue just evals the string you pass to it. So it can be any valid javascript you can think of. Using eval is not a great idea. Also eval is slow. So do it at your own risk.

    Value doesn't use eval and parses the js-expression that you pass to it. Js-expression can contain:

    • alias
    • global var-variables (not let and not const)
    • global functions
    • ["brackets"], [0]
    • .dots

    Js-expression can't contain:

    • function calls
    • operators other than brackets and a dot, like +, – and stuff
    • window object

    Using "Value" is preferable. It's super quick and it's safe.

    I'd suggest you read the manual. It's all there: valerypopoff.ru/construct/js-plugin

valerypopoff's avatar

valerypopoff

Early Adopter

Member since 7 Aug, 2016

Twitter
valerypopoff has 34 followers

Connect with valerypopoff

Trophy Case

  • 8-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

10/44
How to earn trophies