S plugin_set_x(index)

This forum is currently in read-only mode.
  • Hi there,

    anyone know how to set or get the index of an array from the s-plugin?

    With a normal array it's easy: Set value at x

    But how to do that with the S-plugin?

  • Just add the index after the array, you are interested in, e.g

    {"Opponent", "Ant", 4, "Inventory", 2}

    selects the third item in the inventory from the fifth ant (s is zero-based).

    Have a look at this thread:

    and go through the tutorials, it will present you with the core of 's'

  • I tried: allways-> Text: Set text to S.n({"warpX,0"})

    And it crashed :/

    I have the s plugin, the array warpX(from Toralords .cap)

    The array records my "x" positions.

    I want to jump to any x position I want.

    For example, I want to to jump to the x position where I was on the first second.

  • see the difference between what I wrote and what you wrote?

    1) {"Opponent", "Ant", 4, "Inventory", 2}

    2) {"warpX,0"}

    It is important to set the double quotes right. Just correct 2) to:

    {"warpX", 0}

    and it will work. Never set the index within the array name, but as a seperate field after the array name as a comma seperated entry. (it is explained in the tutotials from lucid in the thread link above, too )

  • Won't work like that :/

    http://dl.dropbox.com/u/26932498/Braid% ... 099.96.cap

    Here is the .cap. scroll a bit down and you see the text2.

    I really tried many variations..

  • It seems that you took my words literally. My bad. I wanted to stress the problem and left out what was already right. So, here the complex answer:

    1) To access a number array in 's', you use s.n({"name of your array"})

    2) To access an index in an array, you set the index after the array name: {"name of your array", 2}

    3) Both combined results in: s.n({"name of your array", 2})

    And in your example, it is:

    s.n({"warpX", 0})[/code:dqcd3bn8]
    
    Really, you should first go through the tutorials from the link above. 's' isn't the easiest to use plugin
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, I know why I thought it didn't worked.

    S.n({"warpX",5}) would give me allway the 5th variable.

    So if I read S.n({"warpX",5}), and at this second I was on x = 191

    then the value in the text has to be allways 191? But after 5 steps it changes to my

    currently x position :S.

    WIth the normal array object, when I set the Index to 5, I allways will get the same value.

  • Okay, a last question

    For the normal array object:

    In my selfmade .cap, where I record my x position, I created my array.

    I've set the index to global('Step'). And "Step" will increase at any movement

    the player makes. So the array record at the 6th step that I make, the 6th

    x position. I made "on key is down "T", the global('Step') is allways 5!

    And at every second when I press T and,my text will give me allways (for example) 52. Because on my 5th move I was on x=52. I could easy change my .cap to replay or rewind any move.

    I only have to say: global('Step') begin at 0 and +1 for every step or just -1 at the index you are right now.

    Sorry for that long text...

    Now with the S-plugin

    if I look at the currently "index", with allways -> text set to -> S.n({"warpX",5})

    I not getting allways the position I made on the 5th step. I get an updated

    value, that shows the currently x position and changes if I move.

    edit: tulamide, I saw you are from germany, I could sent you a pm in german.

    Maybe you understand then better what I mean, because my english isn't the best.

  • If you set the index to 5 in Construct's array you will get the content of the 5th cell of the array. This is not neccessarily the same value! For example:

    +Always

    -> Array: Set index 2 to Array(2) + 1

    -> Text: Set text to Array(2)

    Will show you an increasing number, it's a different value on every tick. That's because we change the content of that cell on every tick.

    The way s is used here is different to what you already know of an array. But first an important point: If you select s.n({"warpX",5}) you will get the 6th variable, not the 5th. That's because s is zero-based, s.n({"warpX",0}) is the first element, s.n({"warpX",1}) is the second element, etc.

    The arrays of s are dynamic arrays. You can add, delete and insert to an array of s at any time to any position. You don't need to take care about resizing, this is done automatically by s. The trick in that Braid-cap is that on every tick a new array cell is inserted before the first one and all others are shifted to the right. So after this insertion, the value that used to be s.n({"warpX",0}) is now located at s.n({"warpX",1}), and s.n({"warpX",0}) is a new cell with a new value. That's not changing the values, just relocating them. That's because they are dynamic, opposed to the rather static arrays of Construct.

    I hope it explained it a bit

    p.s. sure, if you still have problems with the logic, just pm me, I'm glad to answer in german

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