• 3D
  • Roach signalling: how does it work, please..?

Good evening...

Here's the issue. I've been trying to get signals working, after having read the tutorials, watched several videos and looked through not a few demos. I'm more confused now than when I knew nothing, and have spent a couple of long evenings trying out the notions gleaned from my 'studies', to no avail. Once again (and maybe not for the last time :-( ...) I'd appreciate a nod in the right direction. I've attached a 'zip' file with a complete, albeit cut-down, version of what I've been using as a test Project. Here's what happens... In an enclosed space, I've a menagerie of Roaches, wandering around randomly, watched by a Player, who, despite being able to do so, takes no part in the proceedings except to get bitten whenever bumped into by a Roach. All is not lost, though, as there's a Fireball careering around the enclosure, again randomly; at every contact with a Roach, the creature stops, with a 'Hop', and is no more. Up to this point, all is well. I have a routine (a function...) in the Fireball script, ready and waiting to be triggered at every Roach Hit. This will enable the Fireball to cease its mayhem once all eight Roaches have been snuffed. I wanted to have signals passing to enable the Fireball to know how many Roaches have been hit, and thought that signals would be the answer. I've removed all the nonsense I've been trying in this endeavour, to have a clean slate without pollution from my ignorance. Is there a kind soul willing to help, with clear, concise steps, to get these signals in place..? I don't really need the work done for me, to receive a working version of my test piece, without any understanding, so that I may do this for myself (I will have further needs, for point-scoring etc, so should be able to understand the process, not simply count the squashed bugs, satisfying as that may be...) Apologies for the length of the post; thanks in advance for any advance of my meagre knowledge. If more information is needed, I'm, of course happy to oblige; meanwhile...

Have a splendid day (and Bonnes FĂȘtes in the very near future...)

Douglas

Hmm... Can't seem to be able to attach the file, so I've popped it into my Google Drive; it can be picked up from here (it's not huge; 165 Mb...)

Signal Master.zip ...

5 days later

I'm not wholly convinced that signals are what you really want here.

Your Roach on_hit() already has a reference to the colliding Fireball. You can call some sort of increment kill count on the fireball object right there and be done with it.

Your roach has already told the engine "hey, when something collides with me, let me know 'here', and please include what did the colliding". Having the roach, in turn, signal the fireball feels weird to me. What would one do if there were more than one fireball? Beyond seek a soothing lotion.

Now if, for example, you had some sort of real-estate (say, maybe, a Motel), that you wanted to inform that a roach has died, there's where your dead roach could usefully use a signal. But it would be the roach emitting the signal, for which the Hotel is watching.

In your particular example, the signal has already happened.

As an aside, the urge to make "debugging" jokes here is not insignificant.

@Ommi said: I'm not wholly convinced that signals are what you really want here...

Thanks for your pertinent comments; there's wisdom in there. You are doubtless right that, in the case I've presented, there are other, maybe more suitable methods, but, for the moment, for me, optimum is not my primary objective. I'm learning, and struggling often enough with some basic notions, and this is one example. OK, if, in this instance it's not the best solution, how can I make it work just the same, as, sure as eggs, there'll come a day when I will need to use Signals (although I doubt that Motels will be involved in the Dungeon I'm creating...). I had a hard time finding out how to get Global Variables of a sort to work, despite labouring through much information. Signals are the same; easy enough once one knows, but I find much of this to be akin to the old 'Open this locked box with the key that's inside'. Everyone that knows, knows, but those that don't, don't, and I'm one of those. Humour my fantasy, suspend your disbelief, indulge me, and see if I can realise, by my own experience, why there are better ways, having succeeded in using the wrong method. Daft..? Maybe, but I still don't know how to pass information using signals. Thanks in advance, with apologies for being a stubborn old duffer with short-circuited neurones. To continue the 'debugging' idiom, I'm finding some of this to be the beggar of a struggle, for seemingly simple things. Old age, maybe, isn't helping. Meanwhile...

Onward and Upward..!

Douglas

Signals are nothing more than classic function callbacks. There's nothing mysterious about them at all :)