Spawn Object/Container/Function issues

  • SOLVED, thanks!

    So I somehow broke something when changing some functions last night and now everything I worked on is borked :(

    I have this code - a set of functions which create an instance of a Sprite object, Monster, which is in a container with an instance of StatMods, in its own dictionary object.

    Function "spawn" randomizes StatMods and sets some instance variables in Monster based on parameter 0.

    It then calls function "statinit" when applies the former values to the latter.

    This all worked wonderfully initially! I made an event sheet that inherited this one and made a button that called "spawn" with param0 as "Muddikorg", and it worked just fine.

    Then last night I must have changed something that ruined it. All I remember adding is this:

    (calling spritegen is at the end of statinit.)

    I looked at the c3 updates to see if anything there could have done this but I don't believe so.

    This is a huge downer for me so any help is appreciated!

  • Rather than using "Pick last created", it would be safer to have spawn() pass in the UID of the created object, and then "pick by UID" inside the function (and subsequent functions). Then you are guaranteed to have the right object.

    You don't show what else is in spritegen() but the previous chose() means it's 50/50 if the Breed=Weinerkorg.

  • Rather than using "Pick last created", it would be safer to have spawn() pass in the UID of the created object, and then "pick by UID" inside the function (and subsequent functions). Then you are guaranteed to have the right object.

    You don't show what else is in spritegen() but the previous chose() means it's 50/50 if the Breed=Weinerkorg.

    Would that be done by setting the return value to Monster.UID and pick by UID using that return value?

    and yeah, I considered that (I made a placeholder sprite and it's only a Weinerkorg) figured it wouldn't have broken the functions in the way I'm currently trying to fix. I changed it regardless.

  • Yes, that's what I meant. If it's still not working, either post the project, or you can add Browser.Log actions to log what's going on in the console. Log each function call and the params going in. You should be able to follow where the code is going.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes, that's what I meant. If it's still not working, either post the project, or you can add Browser.Log actions to log what's going on in the console. Log each function call and the params going in. You should be able to follow where the code is going.

    Logging it to the console did the trick, thank you! Turns out while trying to overhaul movement, one of the behaviors I changed caused an error with the monster object. Now it spawns everything including the placeholder image just fine. :)

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