7Soul's Recent Forum Activity

  • EDIT: I think I found a way to do this... ignore this post for now

    Ok I got around this by passing all the variables as a single string separated by commas into the function. Then in the JS script I do a split() and this is working just fine

    The JS script looks like this:

    function Compare(a,attacker,target) {
    	var stat = {armor:0, crit:1, critDmg:2, dmg:3, mhp:4, hp:5, shotcount:6};
    	
    	var aArmor = attacker.split(",")[stat.armor];
    	var aCrit = attacker.split(",")[stat.crit];
    	var aCritDmg = attacker.split(",")[stat.critDmg];
    	var aDmg = attacker.split(",")[stat.dmg];
    	var aMHp = attacker.split(",")[stat.mhp];
    	var aHp = attacker.split(",")[stat.hp];
    	var aShotCount = attacker.split(",")[stat.shotcount];
    	
    	var tArmor = target.split(",")[stat.armor];
    	var tCrit = target.split(",")[stat.crit];
    	var tCritDmg = target.split(",")[stat.critDmg];
    	var tDmg = target.split(",")[stat.dmg];
    	var tMHp = target.split(",")[stat.mhp];
    	var tHp = target.split(",")[stat.hp];
    	var tShotCount = target.split(",")[stat.shotcount];
    
    	return eval(a);
    }[/code:o1ddw9dm]
    
    
    

    create js variables in your script, set their values to Construct variables values (use aliases) and then operate with those js variables.

    That's what I thought I had to do, but I don't think I understand how to do that properly

    I don't think I can send you the file because it's a huge mess, but what I'm trying to do is very simple.

    In my game there are many items, and they can have conditions to activate (like based on a random chance, or when the enemy has a certain % hp, or based on the enemy armor, etc) and I want to write this condition in an external file, as a string, so I don't need to add an event for each and every item to do the comparison.

    In this engine, both enemies and the player are in the same family, and they use a dictionary to store their stats. Every time someone attacks someone else, a "calculate damage" function is run, and it sets local variables to do all the calculations regarding the attacker and the target

    So if I have an item that increases the damage only if the target's health is below 50%, i'd add a condition later in this function that would compare if tHP is lower than 50%. But I plan on having around 80 items, so that's a lot of hard-coded conditions

    So I made it so all the items have their conditions written somewhere else, in a text file. So the condition would read "tHp < 0.5" and I'd use the JS plugin to eval that expression. But like I said, I can't pass the variable as a parameter because the expression could be anything.

    So if I got this right, I could Alias the variables right after I set them (in the image above) and then the JS would be able to use the variable, right?

  • Amazing plugin! I ran into a little problem I was hoping you could help me with:

    I'm trying to use this script to eval a string. This string could contain any number of global variables and even call functions

    A test string, called var1 is this: "shotCount % 3 == 0"

    The event is JS Call Function "Compare" with parameter 0 being var1

    The .js file has this:

    function Compare(a) {
    	return eval(a);
    }[/code:3ij8w5km]
    
    But it doesn't work, it says "shotCount is not defined" in the log. If I change var1 to something like "2+2" it evals correctly.
    I don't want to pass the global variable because I need this to be flexible and allow multiples and any variable. Do I need to somehow put the variables into the scope of the JS plugin?
  • This is the intended behavior

  • Wouldn't having 20+ instance variables in 50+ instances constantly changing affect performance? This method made it more compact to design weapon stats too, but oh well ~

    Absolutely not at all

  • Vector Y is simply the vertical speed. When the player jumps, the game is setting the Vector Y to the value of "Jump Height" * -1 (you can see that if you run debug mode and look at the player's Platformer values

    )

    So you can easily do a "Set Vector Y to (a negative value)" and it works just like a jump with whatever strength you want

  • Just saying if you talk more about your project people will show more interest

  • Ta usando Physics no objeto? Então usa o evento "On start of layout > (escolhe qualquer objeto com Physics)Set gravity", isso afeta todos os objetos que usam Physics

    Se vc salvar um .capx fica mais facil de ver qual é o problema

  • Cool. For what? Show us what you got

  • This bug has been around for a while (not closing). NW.js staff are probably fixing this already

    Nothing you can do about multiple processes, it's just how it works and there's no problem with it. If the user forces one to close, all of them will close as well

    When you export your game, whatever you name the executable (like game.exe) will be the name of the process. You can change this after exporting

  • This might be possible with one of the effects, like Multiply or Overlay. It's the same stuff Photoshop uses, so this list can be handy: http://www.myphotocentral.com/wp-conten ... -modes.jpg

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You should use the search function of the forums, I'm sure this has been posted dozens of times

  • Also change the gravity and maximum fall speed (the spider falls too fast, it's hard to control)

7Soul's avatar

7Soul

Member since 15 Dec, 2010

Twitter
7Soul has 2 followers

Connect with 7Soul

Trophy Case

  • 13-Year Club
  • Entrepreneur Sold something in the asset store
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • Email Verified

Progress

17/44
How to earn trophies