Calling 2 variables in one expression

0 favourites
  • 9 posts
From the Asset Store
Color Variable
$4.50 USD
10% off
Easily store, modify, read and manipulate colors with Color Variables!
  • hello,

    in my game developing i needed some help today. I want to call an instance variable : char.currentweapon

    then say, bullet set speed > (gun & char.currentweapon).bltpower

    how is it possible to do this

    (hope you understand the problem.)

    thanks

  • System > Compare Two Values >

    You can put what to compare in the values.

    I use this all the time:

    Variable 1

    select >

    Variable 2

    Returns true/false

  • Oh,

    but i am sorry DUTOIT

    that > sign was misleading. Sorry

  • :SYSTEM

    =COMPARE TWO VALUES

    Put what ever variables you want to compare in value 1 and value 2. Choose greater than, less than, equals etc what ever you want to use

    And it will return true or false.

  • ash1221

    I'm sorry, your example isn't clear. Please describe what you want to achieve without using pseudo code. In your example I'm unable to tell if & should represent a logical AND or the building of a string. Also, what is the content of 'currentweapon', a number, a text? What do you want to differentiate using it? Etc.

    Better describe a scenario, so that we can better follow your thoughts.

  • sorry tulamide

    i had a lot of trouble with this problem but then i had a think about it and i found it would be easier to use events instead of variables.What i was trying to do was this:

    take three sprites: s1 , s2 , player

    (the first 2 have different variables with same names)

    so if the value of player's variable (currentWeapon)

    then we would get the variable of .."s" & currentWeapon .. , which would give us either s1 or s2.

    since s1 and s2 have different variables with same names

    i would do :: s1 or s2 (which would be determined by the earlier code) then pick the variable of the S's (e.g. s(1/2).power)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think I get what you're meaning, but typically this type of functionality would require the use of a function pointer in a low level language, or a dynamic runtime compilation i.e. codeblock or macro. I don't think there's anyway to build a variable name dynamically at runtime within C2.

  • Well, actually there is at least a way to reduce the amount of events needed. By using a function. Example:

    + function | on "get_power"
       + function | parameter 0 = 1 -> function | set return value to s1.power
       + function | parameter 0 = 2 -> function | set return value to s2.power
       + function | parameter 0 = 3 -> function | set return value to s3.power
       etc.
    
    + ... -> bullet | set speed to function.call("get_power", char.currentweapon)
  • Oops, completely miss understood the question. The > threw me off.

    tulamide, I spy with my little eye something beginning with "P" Answer: PRO, spot the pro <img src="smileys/smiley4.gif" border="0" align="middle" />

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