nimos100's Forum Posts

  • Its been awhile since I have used C2, so is a bit rusty. I normally used Intel XDK for mobile apps, but sadly that have stopped, so have tried using Phonegap instead.

    I got everything installed and can create a new project inside Phonegap like the "Hello world" tutorial and run it fine. But whenever I export a project from C2 (Export as Cordova) and try to add it to Phonegap it doesn't show up in the list. I have compared the config.xml files between my program and the hello world example and they seem very different. My program is just a project with a button that doesn't do anything.

    Does anyone know how to make Phonegap work with C2, as Im pretty sure that they should be compatible as far as I understand it. Thanks

    Ps. What the hell happened with the design of this forum? its a complete mess of colors, its very confusing and looks terrible :D

  • Problem Description

    Get the following error whenever I destroy a video, is this a bug? It seems to happen in Chrome and NW.js. Is there a way to fix this, its very frustrating to be honest.

    https://www.dropbox.com/s/xcq77pof5mdyg6g/Bug.jpg?dl=0

    Attach a Capx

    https://www.dropbox.com/s/202knig3apn7szs/Video_bug.capx?dl=0

    Description of Capx

    It destroys a video on start of layout.

    Steps to Reproduce Bug

    • Run capx
    • The error appear after you click the background.

    Observed Result

    A javascript error appear.

    Expected Result

    That the video were destroyed

    Affected Browsers

    • Chrome: (YES)
    • NW.js: (Yes)
    • Internet Explorer: (NO)

    Operating System and Service Pack

    Windows 7

    Construct 2 Version ID

    r256

  • Hello all,

    I have a simple project to make an editor where the player can save load levels during runtime. I had previously attempted this by just saving the tilemap json data, which the player could copy/paste (as a string) to save and load.

    can find here - https://lootbndt.itch.io/crt-level-editor

    Im not technical at all, so a lot of the background stuff that happens goes over my head.

    The ideal solution would have the editor provide a file on save, then having the ability to load the level using the file during runtime.

    Any ideas/direction to something similar would be great. Big inspirations are 'bisty' and the 'fantasy consoles', very cool!

    gifs for fun!

    Making a save functionality is somewhat difficult to explain as it involve a lot of things and there might be different ways to do it, I think. i made a save/load functionality a long time ago for a program, so I might not remember exactly how I did it. But from what i do remember you can use NWjs to do it. Unfortunately it is not as straight forward as it might sound.

    But basically it goes like this:

    1. Make the file with NWjs

    2. When the file is created you can write/append to it using NWjs, so you write all the information for each object you need to store, to the file.

    3. To load the data from the file you can use the AJAX functionality combined with the tokenats system commands in C2 which allow you to extract specific data from the file, which you can then apply to objects.

    To go into a lot of details would make this a very long post. So I would suggest reading these in the manual and make some small tests in a separate program just trying to save and load data. Its not as difficult as it might sound, its simply that it can seem a bit confusing a first.

    NWjs (To create and write to files)

    https://www.scirra.com/manual/162/nwjs

    AJAX (To load files)

    https://www.scirra.com/manual/107/ajax

    Tokennat

    tokenat(src, index, separator)

    Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

    tokencount(src, separator)

    Count how many tokens occur in src using separator. For example, tokencount("apples|oranges|bananas", "|") returns 3.

    These are extracted from here: https://www.scirra.com/manual/126/system-expressions

  • >

    > Im not sure what you mean with resetting top level for trigger once conditions and how disable and enable groups is good here, compared to for instance making correct conditions? I won't argue to much against this, because im not sure what you mean.

    >

    As I understand it, if you have something like:

    GroupA
    >>Trigger once | do action
    >>Condition X | do another action
    [/code:pyujkxvs]
    
    Each time the group is reactivated the "Trigger once" action would fire.  This saves you having to set up a bunch of variables or other conditions to reset the Trigger.
    

    Im still not sure what the example is illustrating, meaning if I understand your code correct. You have one group, and in it you have two events. A "Trigger once" which do some action and then another event that tests for "Condition X" and if thats the case it does another action. But are these connected to each other? Meaning is Condition X suppose to be a sub event of "Trigger once"?

    But regardless I fail to see what exactly the enabling or disabling of the group is suppose to bring to the table here. I very rarely use trigger once my self except when doing something with sounds. So why you would make use of trigger once like in the example you made seems strange, not saying that there ain't a use for it, but I genuinely don't understand when you would make something like in the example.

    To me it seems like a sort of weird custom made function controlled by disabling and enabling a group. Could you give an example of a practical use for such an event, because I get the impression from what you wrote "As I understand it, if you have something like:" that you are not really yourself convinced what this is suppose to be used for, but do you recall the example or where you got it from, would be interested in seeing an actually example of this?

  • nimos100

    Whilst in rafaelsorgato 's particular case you're right that groups are the cause of the problem (if the group is disabled then necessarily you can't trigger any events within that group), it's misleading to say that you shouldn't be using groups in any circumstance. There are many valid reasons for doing so, most importantly because no checks are made against events in deactivated groups, which can lead to significant performance boosts, especially if those checks are on large numbers of objects/instances. Also deactivating and reactivating groups is a convenient way to reset top level "trigger once" conditions.

    I honestly don't think its misleading and think there is reason to be careful here and not confuse people new to C2. Obviously you can use groups and you can disable and enable them as you please and used correctly this will cause no problems. But disable and enable groups should never be used as problem solving, that is basically my main point.

    In regards to performance boost, im really not convinced that it is worth starting to do this, as I don't think the performance boost would be worth it, if at all possible to measure. The only valid argument I can think of, why you would disable groups to get a performance boost, is an argument to solve poor organization of conditions in events.

    An example of this can be illustrated with overlapping:

    Assume we have 1 enemy and 1 other object.

    1. Poor condition organization
    
    Enemy is overlapping <Something>
    Enemy is Alive = true
    ---------------------------------------------------
    
    2. Good condition organization
    
    Enemy is Alive = true
    Enemy is overlapping <Something>
    [/code:2qd868of]
    
    Assuming we are in a state of the game where we don't need to check for collisions, then looking at example 1, it could be argued that disabling this group would improve performance, because it would generate 60 collision checks and having a lot of objects would obviously create a lot of collision checks for no reason. However since C2 read conditions from top to bottom, simply making sure that your conditions are optimized correctly would solve the problem and a check vs true / false is done very very fast and would cause C2 to stop doing any collision checks after checking the first condition. So simply switching the conditions around would optimize the code.
    
    Obviously if your only condition is an overlapping check, sure disabling the group could improve performance if the number of objects are huge.
    
    But i think starting to see groups as a completely valid solution to solve a large amount of issues is simply not a good way to start thinking about programming in C2, because the moment you run into problems like performance, instead of thinking about how to optimize your code, you start relying on a "lazy" approach or what to say. And then you have these posts where people complain about poor performance in C2, but they might have done nothing to optimize their work. And I bet a lot of people are not aware or even concerned about that organizing their conditions correctly will also affect performance.
    
    So getting new users used to seeing the use of disabling groups as a good way to optimize code, just seems wrong to me as its not a good way to think about programming, compared to actually knowing the effect of what you are doing and how you choose to organize you code will affect performance and how you in general approach problems when they occur.
    
    Im not sure what you mean with resetting top level for trigger once conditions and how disable and enable groups is good here, compared to for instance making correct conditions? I won't argue to much against this, because im not sure what you mean.

    This is simply a guess, but maybe its related to what is talked about in this post, which seems to have something to do with windows 10 and C2 being slow due to some update that Microsoft made from what i understand?

    //Keep in mind its simply a guess it might be something completely different.

  • nimos100

    sorry nimos, but it is impossible, groups exist precisely because there are conditions that without groups it is not possible to do something, so I need something capable of making a group work on 2 objects independently

    Im sorry but that is simply not correct. Groups only functionality is that they can be enabled or disabled during runtime. But there are no difference in doing this compared to making events that wont run if certain conditions are not met. If you read the manual about groups the only example highlighted where disable and enable groups could be useful is for pausing a game, which I could see it being useful for, even though I would personally still prefer to pause the game some other way.

    Your example with the frogs based on your description is not a situation that can only be solved by disabling and enabling groups and honestly I don't think you can actually solve it doing it like that. But obviously if that's what you want to try, to make it work, you should go for it obviously. I only give you this feedback, because I think you are going off track, trying to solve your problem like this as it is really not a good practice. Seeing groups as a way to solve problems is just not a good way to approach programming I think. The issue you are facing is very common, just as if an Enemy is within range of a player then it should be able to shoot, but one there isn't shouldn't. And again you wouldn't or shouldn't solve such issue by starting to enable or disabling groups. The reason your program doesn't work is one of the two things if not both that I highlighted in the first reply. You get that fixed and your program will work for all frogs, whether they are trapped or not.

  • I think you would be better off not using disable/enable groups to make things work. Its not really a good way to program in general compared to making your things work for objects based on correct conditions, the functionality in the group should work so it only happen to a frog if its trapped.

    A group is simply a virtual container so to speak for organizing and combining functionality in a more logic way or at least it should only be used as such.

    So instead what you should do is to check whether a frog is trapped or not, in the case it is, it shouldn't be able to walk.

    This can be done simply by using a boolean variable like "Is Frog trapped" = "True or False" and check for it as one of the conditions in the walk functionality. If you disable a group all functionality in that group will be lost for all objects, besides that you might end up with a lot of new problems if you suddenly enable the group and it then starts to affect all the frogs it shouldn't.

    In cases like these, where you make an event that should only trigger one object under a certain circumstance and it triggers two or more and you are unsure why, there are pretty much only two possible causes for that.

    1. Your picking is wrong, meaning you haven't made the correct conditions for the event.

    2. One or more variables for an object is not correctly set. In your program it could be that for instance, a frog "is Frog trapped" variable is not set to "True" when it collide with a trap.

    I would suggest you read this:

    How events works - https://www.scirra.com/manual/75/how-events-work

    Functions - https://www.scirra.com/manual/149/function

  • Did some testing and it does seem to be working the way it were made. However I would still do it as its suggested in the manual using the "On path found". I might suspect that its the line of sight then, have you tried to disable that and see if all zombies move correctly? And if they do, try to disable every thing in the condition except the Every dt*2 and see if it works?

  • Have to agree with dop2000 that the code is wrong, I suspect you might have tweaked it?

    But anyway the issue in regards to the path finding is almost certainly in event 14, you don't use path finding like that. The reason is that path finding for objects are actually done separably outside your main program as far as I know. So your program actually keeps executing code while the path finding is done in the background.

    Therefore you have several Trigger conditions called "On path found" and "On failed to find path" which will trigger when either a path have been found or it failed to find one.

    Which should make you wonder why the "move along path" action is placed in event 14, since the path might actually not have been found yet.

    So what you need to do is add an "On path found" and move the "Move along path" action to here instead.

    But as dop2000 mentioned the 15-16 events are incorrect as well, but shouldn't prevent the path finding from working.

  • I have 1 object and they will respawn every minute, but whenever another aparace buga because the events of one happens in the other, example: a ship only shoots when its line is pointing the player, but when it has 2 ships it only shoots when the two lines are in the player

    Hmmm.... your program is very confusing

    But from what I can see its a picking issue lacking a for each, but there are so many checks for the same things in your code, that you could probably fix it, simply but correcting all the "Linha is overlapping" events. but I don't really think you will get a lot out of it, due to how you have structured your program in general, I think you would do yourself a favor, if you started from scratch and get the structure of the program designed in a more logic way where you can work with it.

    Because looking at it now, I can say with 100% certainty that you will run into similar problems sooner than later, I don't say this to annoy you, but to help you avoid spending a lot of time on something that you will loose control over very fast as you expand your program, so I hope you don't misunderstand what im saying, its meant in a friendly way.

    To help you get started, here are some ideas that I think would help you.

    1. Use telling group names and comments.

    Having groups named C, C2, C3... Group 1, Group 2 etc. is never going to work, it might work the moment you work in that particular group, but the moment your program begin to grow, you will loose control. Always add comments of what the event is suppose to do, even if it seems very simple.

    Like:

    //Enemy will attack player if they move to pickup crate

    Even though the code for something like that might be very simple, just having the description written down will help you the next time you have to look through your code and to quickly get a overview of what is suppose to happen in a given event. If you don't use comments you will loose control of your project at some point, its 100% certain.

    2. Structure event where they make sense

    Having several "On start of layout" varies places throughout the code will make things very confusing compared to making it the first event on each event sheet and only add one. It will not benefit you having several of these.

    Add event sheets for specific tasks or objects.

    As an example, you have a Player and you have some enemies, but also you have some events to control the game, like "On start of layout". So instead of mixing all these together, like Player functionality with Enemy functionality, you make an Event sheet called Player and one called Enemy and one called Game, since the Game event sheet controls the overall game, you include the Player and Enemy event sheets into that.

    It will help you a lot when it comes to finding stuff later, so if you need to make some corrections to the player, you know that its most likely to be found in the Player event sheet.

    3. Use functions and avoid repeating functionality

    Using functions will really make things easier, both to program but also when it comes to testing and bug fixing, because you can specifically test a function input and output very easy.

    If you use a lot of "X is overlapping Y" with varies conditions for the same thing, like if the purplebeam is overlapping player, you will end up with a huge amount of events for no reason. You can think about it like, you have to find common conditions in order to reduce complexity.

    So if this is one event:
    
    Purplebeam is overlapping Player
    X = 0
    
    And this is another
    
    Purplebeam is overlapping Player
    X = 1
    
    Then Purplebeam is overlapping Player is a common condition for both events so you can combine them into.
    
    Purplebeam is overlapping Player
            X = 0
            or
            X = 1
    [/code:1dkforij]
    
    This will help you reduce the amount of events, which again will make things a lot easier for you.
    
    [b]4. Get a good understanding of picking[/b]
    Understanding how picking work is essential if you want to do anything in C2. So really spend time getting to understand this is crucial in my opinion, by far the most mistakes people make when they are new to C2 is wrong picking from what i have seen and think everyone when they started have made their fair share of mistakes here . 
    
    The best way to understand picking is to see it as a way to reduce potential objects of interests.
    
    For instant:
    
    Object is a car
    Car must be red
    Car is not broken
    
    Each of these steps reduce the number of potential cars that we are interested in, so always start as wide as possible and keep reducing until you are satisfied. 
    
    The reason I write this is because when looking at you code you seem to get it backwards a lot of the time. 
    
    Example:
    [code:1dkforij]
    For each Sprite
    Sprite.Physics X velocity > 200
    [/code:1dkforij]
    There are situations where this way of using a For each is beneficial, but for the most part this is the wrong way to do it. Because what you are interested in, is picking all Sprite.Physics X velocity > 200 and when you have found them, you want to do something with them.
    
    So the code should be:
    [code:1dkforij]
    Sprite.Physics X velocity > 200
    For each Sprite
    [/code:1dkforij]
    
    Anyway hope you see what I mean, because its just to help you and to save you some time and frustrations. It is really worth spending time on these issues compared to just programming like crazy only to having to dump it all due to loosing control. Even when you get a hang of it and really think you have a good structure etc, it will be the biggest issue and main reason for dumping a program I think.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • From your description it sounds most likely as if you have done wrong with the variables and not something with C2, since you say that it works fine when you break the application and have to set some variables first. But its very difficult to help troubleshoot without any screenshot of code, error message etc.

    But what you could do, is start by disable stuff one at the time to see in which event the error occur.

  • 1. There is a path finding condition that let you check if an object have a path or not, you can use this for newly spawned objects. So if they don't have a path they should find one.

    2. Not 100% sure I understand what you mean by this. But if I do, you can use a timer or a Every X second, that will increase the budget, Each time this happens you add a check to see if the the budget is high enough and if it is you spawn an AI and subtract a value from the budget.

    3. After one of the AI's kill another AI, you add a functionality in either "On destroyed" or whatever place you destroy AI's and then you pick the winning AI and make a action here for finding a new path. Alternatively you use a variable for triggering the finding a again path.

    4. You make a condition that any AI with a Range weapon, check every tick or every 0.2 second using Distance (X1,Y1,X2,Y2) Where X1,Y1 is the AI with the range weapon, and X2,Y2 is most likely the closest enemy AI.

  • There shouldn't be made any collision checks unless you use On collision or Is overlapping another object... in your code as far as I know.

    But there is an action that lets you disable / enable collision

  • Your question is a pretty complex one to answer, because there are numerous ways to implement AI and in general its not easy to make. So I doubt you will get any "this is how you do it" solutions.

    But a way to get you started, you can think about it like this. This is just an example based on what you write you would like in the game and how I would approach it.

    You could give each AI a personality, which is basically just a lot of stats that will govern how they tend to react. Since i don't really know what your game is about, but understand that it have something to do with buying resources and land. You could give them some stats called Trading and Expanding for instance, where an AI with high Trading might prefer buying resources over land. Since you don't want to risk the AI keep trading forever. You would have to take currently owned resources into consideration as well. So you could check versus these as well and make it so an AI with a high Trading stat, prefer having a bigger stockpile than one that prefer buying land. However if the prices of resources changes these have to be taken into account as well, as it would be poor AI if they just buy resources regardless of price and need. So what you could do is to add a "Max buying price" to each AI and as their stockpile gets lower and start to need a certain resource they will also be willing to pay more for it, and then you could add their current amount of money into it as well as it might not be good for an AI to spend all their money on resources.

    So you can keep expanding on this depending on how complex you want the AI to be, for instant they could take player actions into account or the players current resources and buy up those that the player seem to need to simply push them and so forth.

    But again there is not really a simple solution, but what you will most likely end of with in the end is some sort of state machine that is used differently by each AI depending on their stats, preferences, needs and whatever you think is important.