How do I change a variable per copy?

2 favourites
From the Asset Store
Per Pixel Destruction like in "Worms" (perfect performance, no third party plugins)
  • simplified version: construct.net/en/forum/construct-3/how-do-i-8/change-stringvariable-per-169309

    They both show up in the dialogue as TEST2. Is there a way to fix this, and have each individual "openable" have their own item/variable?

    This is probably super simple, if there's a tutorial that could help, or if you can help yourself, please respond!

    PROJECT FILE:

    drive.google.com/file/d/1sKAPxkhu0CFTRCH5zrkLjsvVAOb-KjI_/view

  • Cannot open the file as there is some kind of add on. My guess is the issue is picking, you need to pick the correct trashcan with conditions then the actions will choose that instance.

  • Cannot open the file as there is some kind of add on. My guess is the issue is picking, you need to pick the correct trashcan with conditions then the actions will choose that instance.

    Could you expand on this please? I'm relatively new to construct.

  • Please remove that wind effect from the project and reshare or share a screenshot of the events used.

  • Please remove that wind effect from the project and reshare or share a screenshot of the events used.

    drive.google.com/file/d/1sKAPxkhu0CFTRCH5zrkLjsvVAOb-KjI_/view

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • And where are we looking? It's quite a big project with lots of stuff

  • Most of the programming is in eGameRoom, eGlobal & eFunctions. Check eGlobalPlayerVariables if you need variables. The objects you interact with are labled as "openable" and "StaticNPCs", If you need anymore info, let me know.

  • Nah that doesn't help I need to know where I'm looking in the game to test whatever the problem is. Better if you set up a room to test in that demonstrates the problem.

  • Nah that doesn't help I need to know where I'm looking in the game to test whatever the problem is. Better if you set up a room to test in that demonstrates the problem.

    Does a room like this work?

    (main_test_room4)

    Proj Link:

    drive.google.com/file/d/1sKAPxkhu0CFTRCH5zrkLjsvVAOb-KjI_/view

  • Well it doesn't look like a beginner's project. What am I doing and where's the problem?

  • I'm a beginner to construct specifically, not game making. But, I can try to figure this problem out myself. The issue is that the dialogue doesn't replace the text with the proper variable.

    There's two trashcan, both in the same NPC/Dialogue family. They're referenced as an object called "openable". The programming itself works fine. The only issue is that the variable called "itemname" doesn't change based on the ID of the trashcan you're interacting with.

  • I used variable to reference all of these, but itemname and interactname are both strings. Sorry if that was confusing.

  • Well it looks like there is a formatdialogue function that replaces INTERACTNAME with openables.interactname but the function doesn't have anything to pick what you interacted with. Somewhere down the line you lost the ID of the NPC. So it will always choose the one instance. Between functions the picked instances get lost, you have to send the ID through each time as a parameter.

  • I am going to go on limb here and try to help.

    It's a little bit hard to follow what is going on, but I think what is happening is that the function NPCInteraction2 is not doing what you expect.

    Inside of it you are checking for an NPCID property of the NPCINTERACT family but the check is not against the instance of the family that was picked when the function was called. I will check with Ashley why is that, I have a feeling that is the expected behaviour, but I will ask him to be sure.

    So what ends up happening is that all that state for showing a dialogue is being set on the wrong instance.

    To get around that, I passed the UID of the picked instance in the call to NPCInteraction2 and inside of it I added an extra condition to Pick by comparison in addition to the NPCID condition. That way you can be sure that state is set in the correct instance.

    Something similar then happens in the call to FormatDialogue, so to get around that I added a few arguments.

    In the calls to DialogueLine, FormatDialogue and PickAnswer I pass in an additional argument with the IID of NPCINTERACT family. I did that so that I would be able to use that value in FormatDialogue to use the expressions NPCINTERACT(IID).itemname and NPCINTERACT(IID).interactname and ensure the function is using the correct instance values every time.

    NOTE that UID and IID are different things.

    All of this is quite hard to explain, but I think I covered everything.

  • I checked with Ashley about this and it is the intended behaviour.

    When a function is called, picked instances are reset in the body of the function. If you need to rely on picking inside of a function you need to pass the UID of the instance you want as an argument, and inside of it use it to pick the instance you need.

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