AllanR's Recent Forum Activity

  • charles1311

    it looks like the tanks were getting overwhelmed with commands, and might have been using the wrong tank coordinates in some places...

    the left and right directions were getting cancelled by the up/down ones.

    I changed it slightly to do all the checking under one "For each tank" event, and made it always choose to go towards the coordinate (X or Y) that it was furthest from the target location. (I also made the target location visible so I could see what it was doing).

    www.rieperts.com/games/forum/tanks.capx

    EDIT: if your game will have any obstacles on the battle field, then path finding would be a very good idea - like plinkie said...

  • if the list of objects doesn't change dynamically at run time, then you can just put all the sprites in a family and use:

    Create object FamilyName

    that will have it randomly choose one of the family members to create...

  • ok, I see what you mean... choose cannot be used with a single variable like that, so you will have to use tokenCount and tokenAt.

    set the Sp_Data.BChoice to the list of possible objects "Sp_B1,Sp_B2,Sp_B3..."

    then: create object(tokenat(SP_Data.BChoice,floor(random(tokencount(SP_Data.BChoice,","))),","))

    what that does is count how many choices there are:

    HowMany = tokencount(SP_Data.BChoice,",")

    then randomly chooses one of them:

    WhichOne = floor(random(HowMany))

    and then extracts the text of the one choosen:

    tokenat(SP_Data.BChoice,WhichOne,",")

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

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

AllanR's avatar

AllanR

Member since 21 Nov, 2013

Twitter
AllanR has 23 followers

Trophy Case

  • 11-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Popular Game One of your games has over 1,000 players
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

20/44
How to earn trophies