AllanR's Forum Posts

  • works for me...

    with a normal create object, the object is automatically picked after it is created.

    with the create by name, your eventsheet wont know in advance which object got created, so you would have to put them in a family and use pick last created. The instance variable would have to be on the family (obviously).

    https://www.rieperts.com/games/forum/createbyname.c3p

    EDIT: you can't set an instance variable before the object exists... (that may have been part of the problem).

  • the choose command doesn't see the contents of the variable as a list to choose from. it only sees the single text value.

    so you will probably have to do something like:

    set tempVariable to choose("Sp_B1","Sp_B2","Sp_B3","Sp_B4","Sp_B5","Sp_B6","Sp_B7")

    create object by name tempVariable

    then set the instance variable to tempVariable

  • Wulfy

    well, there were a lot of bases to cover to make sure everything works consistently and is fairly intuitive. I didn't use any arrays... although I do really like arrays and use them all the time. Using an array makes doing save games easier, and helps when changing from level to level, but sure make code harder to read! I like the way you used the InventoryManager sprite. I also do that a lot - usually when I have multiple groups of items that each need their own group variables. (although I didn't end up using that here either).

    https://www.rieperts.com/games/forum/inventory.capx

  • Wulfy

    just saw plinkie beat me to it while I was typing but I had just uploaded my take on it so I will put in my 2 cents :) - it seems slightly over complicated to me... (I am not convinced you need the arrays and I think it could be simplified in a few ways)

    anyway, there is a second problem with event 6 - it moves the grounditem out of the chestslot, but then all the conditions for event 7 are true, so it puts it right back into the chestslot. (with a left click)

    make the first action of event 6 say "Wait 0 Seconds"

    that delays the actions until the end of the current tick - which will happen after event 7 has been checked.

    the other problem was a lot more subtle... there were a couple issues: it was looking for an empty slot before you were checking for 3 parameters, so it has already added it to a slot. And you were passing in invSlot.SlotID instead of Slot.SlotID, and if the slot was empty, after calling the AddToInv function, all the conditions for event 41 were now true, so it tried to add it again, but the handAmount was now 0...

    https://www.rieperts.com/games/forum/newproject.capx

  • AlbertHall

    I recreated your code and it works fine for me. There must be something else going on in your code that makes those conditions true (and thus the wip)

    what happens when you touch the Exit_Text? do you move it or hide it?

  • aryd

    in general, if you don't specify "For Each" C3 will treat objects as a group (so, in your case they all get the same random number because the actions are only executed once). With the For Each, the actions are run individually for each object and they all get a different random number.

    so, performance is better without the for each, but if your game logic requires individual control then for each is the way to go.

    it gets even more confusing when you add "self" to the mix. You can have something like:

    every tick, Killer.X = self.X + 5

    That doesn't require "for each", but each one will have 5 added to their individual X coordinate.

    However, Killer.X = self.X + Random(5) would require "for each" if you wanted them to each get a different random number.

    But once you understand how events work and how picking applies actions to objects you can do amazing things!

  • farmersfable

    there are many ways to do it - if the data isn't likely to change after you export your game, then you can copy and paste the data into a text variable and use tokencount and tokenat to break it apart and put in the array.

    you could also add a text file to the project and load that, or you can use AJAX to request the data from a database, or other external source at runtime.

    I made a quick sample of the first option...

    https://www.rieperts.com/games/forum/loadarray.capx

  • aryd

    under event 3, add a subevent that says: For Each Killer

    then put the random, and else lines as subevents under that.

  • You do not have permission to view this post

  • candyman201

    if you don't want the player to be able to see past solid walls, it get slightly trickier.

    see this thread from a few weeks ago for more suggestions:

    https://www.construct.net/en/forum/construct-2/how-do-i-18/field-view-walls-143211?kws=lightmaskwalls

  • RobertoFreemano

    C2 also has Local Storage... don't use web storage, browsers are not supporting that anymore.

    you could also use the Save/Load under the system object which simplifies the process a little.

  • luckyrawatlucky

    the one advanced random demo I looked at said that it produces values between 0 and 1.

    so to get a number between 0 and 25, multiply the value by 25.

    to get a number between 5 and 15, multiply by 10 and add 5

    for 1 to 10, multiply by 9 and add 1.

    in general, multiply the value by (upper limit - lower limit) and add the lower limit.

  • RedBlackSpade

    WOW! the art is fantastic! You have obviously put a lot of work into this. I like the the old cartoon style, but with more vibrant colors.

  • I haven't tried what you are doing, but my guess is that the array download wont work from a website like that. You should try the Browser object, and then "Invoke download of string", and give it the array AsJSON...

  • I don't think he understood what you meant... it is one gun sprite with three frames, and then I think he has three instances - each showing a different frame. but I could be wrong...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads