0 Favourites

Array action to Textbox [SOLVED!]

  • Hi all,

    I've been trying to solve an little stumbling block i've had with my combat log and i'm hoping someone can provide some advice on how to overcome this.

    To give you an idea of what i'm trying to achieve, here's some wonderfully pre-alpha shots and the events.

    Firstly upon loading, the textbox asks you to hit Spawn to spawn a random mob. Once you click this it then tells you what mob you've spawned:

    For this particular part you then press basicAttack(testAttack). This takes the mob health i've pushed from a static mob array to a temporary mob array tempMob.At(0), and then I subtract a random number from your characters min and max attack stat array "- round(random(aCharH.At(4),aCharH.At(5)))"

    This is fine and dandy and does what it's supposed to. However I would like it display the value of - round(random(aCharH.At(4),aCharH.At(5))) and not the health remaining at tempMob.At(0). So instead of "mob is at x health":

    I'd like it to say "You attack mob for x damage" or something similar. My main objective here is to get that X damage done. I've played around with a global variable to try and get the x damage done so I can easily display it, then have it subtracted from the mobs health, but I don't seem to be able to get the math nailed down.

    Has anyone done something similar before? If so how did you overcome it? I feel like it's staring at me in the face and i'm too blind to see it!

    Thanks for looking

  • How about:

    Make a holding variable to store player attack damage for the round, let's call it roundAttack.

    On click "test attack": set roundAttack to round(random(aCharH.At(4),aCharH.At(5))), set array value to itself minus roundAttack, call function (paramater is: "You attack mob for " & roundAttack & " damage!" & newline & "Mob health is now " & tempMob.At(0) )

    Function call works the same as it did before.

    That's off the top of my head so might not work :p

  • Hi Mike,

    Thanks for that, I think might just work! I was running on empty last night and couldn't wrap my head around it!

    I'll let you know how I get on tonight.

    Cheers

  • I think mikehive is correct, and as mentioned "holding variable" should likely be a local variable.

    Event 23, create a blank subevent that will contain the action setting the variable's value, modifying the array and displaying the value, so this way your local variable can sit between the top event 23 and the newly created blank sub-event.

  • I think mikehive is correct, and as mentioned "holding variable" should likely be a local variable.

    Event 23, create a blank subevent that will contain the action setting the variable's value, modifying the array and displaying the value, so this way your local variable can sit between the top event 23 and the newly created blank sub-event.

    Cheers Kyatric, makes so much more sense when it's not 1am and struggling to keep an eye open!

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Cheers boys

  • Our pleasure

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)