How do I determine the problem with my event sheet?

Just started using Construct 2? Post your questions here

Post » Tue Sep 26, 2017 3:23 pm

https://www.dropbox.com/s/8ki9vqkzjnv4eym/MURDER%20CASTLE%20GAME.capx?dl=0

I'm having trouble with Line 67 of my events sheet.

When the player overlaps a green area called "Paywall", they are supposed to trigger an event where they are asked to pay for something. If they don't have enough money, text is supposed to pop up saying "You can't afford that."

If you look at my capx and move the player to the left, you'll see the green Paywall. Overlap it and it will ask for money. By default the player doesn't have any money.

Press 'P' to try to pay. This is where the problem is, because nothing happens... no text pops up.

Press 'O' to cheat and give the player a dollar. When you try to pay this time, everything works, despite the fact that this "Can pay" event sits below the "Can't pay" rules on the event sheet.

Why doesn't "You can't afford that" pop up like it's meant to? How can I fix it?

As a side question... is there a search feature for the events sheet? I'm trying to find where I established using Keyboard Press 'P' to pay, and I'm just not finding it!

Thanks for your help!
B
8
S
2
G
1
Posts: 89
Reputation: 1,230

Post » Tue Sep 26, 2017 3:58 pm

The problem is event 13 keeps firing, since the player is always overlapping the Paywall. You'll need to keep track of when that message has been shown, or switch to On collision for the text message display.
ImageImageImage
B
71
S
22
G
249
Posts: 3,763
Reputation: 138,577

Post » Tue Sep 26, 2017 4:23 pm

@blackhornet

Okay, I think I see it. You mean event 14, right?
I'd like to have it remain as "overlapping" because I need to make sure that the ability to pay only occurs in that area (If I put a shop counter there, I don't want the player to be able to pay from across the room).
However, I'm not sure the best way to keep track of the message. Do you have any suggestions? What would you do?
B
8
S
2
G
1
Posts: 89
Reputation: 1,230

Post » Tue Sep 26, 2017 6:37 pm

Trigger the initial message once only when you overlap, like this https://www.dropbox.com/s/nkr9pgnq9fvqh ... .capx?dl=0
B
47
S
17
G
82
Posts: 2,231
Reputation: 48,609

Post » Tue Sep 26, 2017 9:59 pm

@plinkie

Thank you so much. What you've done is so very helpful. It works now!
B
8
S
2
G
1
Posts: 89
Reputation: 1,230

Post » Tue Sep 26, 2017 10:20 pm

@plinkie

Along the same lines, I've got a problem with Event 80.

https://www.dropbox.com/s/ywz5507fcmdk07v/MURDER%20CASTLE%20GAME.capx?dl=0

I've got some pick-up items on the floor. When the player collides with them, the pop-up is supposed to say "You got (whatever the item is)."

I've set the instance variables for the name of each item, but whichever item I collide with, the pop-up always says "You got a scented note." There is only one scented note. The other items are a handkerchief and some money. Why isn't the system reading the instance variables of each specific item? Would "Trigger Once" work here too?
B
8
S
2
G
1
Posts: 89
Reputation: 1,230

Post » Tue Sep 26, 2017 10:56 pm

If you move the Set text to event 50 you'll see it is working. You should only really have that set text event in a function if you're passing the item name through it, which I would prefer to do. On the YouGotItem function call event, add a parameter 'collectibles.itemname'. Then on the text event inside the function instead of collectibles.itemname use function.param(0). This sends the name of the item you are overlapping through the function so it can be used correctly. The reason it's broken is because you call the function but then collectibles.itemname does not relate to anything or the item that was overlapped, so it picks the collectible with lowest UID which is the scented note.
B
47
S
17
G
82
Posts: 2,231
Reputation: 48,609

Post » Wed Sep 27, 2017 11:17 am

@plinkie
That's terrific! I moved everything to event 50 like you said. Thanks very much!
B
8
S
2
G
1
Posts: 89
Reputation: 1,230

Post » Wed Sep 27, 2017 7:44 pm

Well I was saying that the function was the problem and if you move it out of the function then it works, but you can still use one if you pass the item data through it correctly. They are powerful if you want to send through a bunch of data for an action that you will be doing over and over such as collecting an item. Since you're using a family for the items it should be efficient enough without the function though.
B
47
S
17
G
82
Posts: 2,231
Reputation: 48,609


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests