Discuss Scratch

epicbattler3
Scratcher
55 posts

() of () for clones workaround

Alright, so here's the code i have:

<<touching [Enemy1 v] ?> and <([cloneType v] of [Enemy1 v]) = [Hitbox]>>

This detects if the sprite is touching a clone of Enemy1, but only if it's a “Hitbox” clone

cloneType is a private variable tied to a clone, so
([... v] of [... v])
won't work for it.

Is there any way, lists or anything involved, to access a private variable from a clone? Finding a workaround for this would help immensely.

░▄▀▄▀▀▀▀▄▀▄░░░░░░░░░
░█░░░░░░░░▀▄░░░░░░▄░
█░░▀░░▀░░░░░▀▄▄░░█░█
█░▄░█▀░▄░░░░░░░▀▀░░█
█░░▀▀▀▀░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░█
░█░░▄▄░░▄▄▄▄░░▄▄░░█░
░█░▄▀█░▄▀░░█░▄▀█░▄▀░
░░▀░░░▀░░░░░▀░░░▀░░░
Just_Iakov
Scratcher
100+ posts

() of () for clones workaround


I think there might be a good and effective script, however I can suggest a pretty simple method.

Instead of making the player sprite on touch detecting what hitbox, or what variable the enemy has, make it that the enemy does it. The enemy can return this information to the player sprite, and from there, the player can work their way around.


This is what I suppose you want to achieve:

Script for the player:
if <<touching [dummy] ?> and <some script to detect dummy's private variable>> then
action
end

However, why don't you make the enemy do the same thing? If the enemy is touching the player, it can return pretty much any of its private variable inputs. So what we are doing here is making the enemy sprite the main reader, not the player.

This method is only effective for one player and multiple enemies, it's not recommended to be used when there are multiple players, and multiple enemies.

I hope this helps you out.

Last edited by Just_Iakov (Sept. 29, 2021 06:39:14)

epicbattler3
Scratcher
55 posts

() of () for clones workaround

Ah, there is a reason I specified bullet. The code I put was from a bullet, and not the player itself

The issue I'm having involves several things:

-The bullet cloning itself (not an issue)
-The bullet coming into contact with enemy1 (not an issue)
-The bullet being destroyed upon hitting the hitbox of enemy1 (issue)

The bullet never gets destroyed, so it passes through the enemy, which I do not want to happen

░▄▀▄▀▀▀▀▄▀▄░░░░░░░░░
░█░░░░░░░░▀▄░░░░░░▄░
█░░▀░░▀░░░░░▀▄▄░░█░█
█░▄░█▀░▄░░░░░░░▀▀░░█
█░░▀▀▀▀░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░█
░█░░▄▄░░▄▄▄▄░░▄▄░░█░
░█░▄▀█░▄▀░░█░▄▀█░▄▀░
░░▀░░░▀░░░░░▀░░░▀░░░
Just_Iakov
Scratcher
100+ posts

() of () for clones workaround

epicbattler3 wrote:

Ah, there is a reason I specified bullet. The code I put was from a bullet, and not the player itself

The issue I'm having involves several things:

-The bullet cloning itself (not an issue)
-The bullet coming into contact with enemy1 (not an issue)
-The bullet being destroyed upon hitting the hitbox of enemy1 (issue)

The bullet never gets destroyed, so it passes through the enemy, which I do not want to happen

I see, but could you by any chance share or provide a link to the project? Thank you.

Last edited by Just_Iakov (Sept. 29, 2021 06:53:19)

epicbattler3
Scratcher
55 posts

() of () for clones workaround

could you by any chance share or provide a link to the project?

the project is unshared, and i have no intention on sharing it currently

░▄▀▄▀▀▀▀▄▀▄░░░░░░░░░
░█░░░░░░░░▀▄░░░░░░▄░
█░░▀░░▀░░░░░▀▄▄░░█░█
█░▄░█▀░▄░░░░░░░▀▀░░█
█░░▀▀▀▀░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░█
░█░░▄▄░░▄▄▄▄░░▄▄░░█░
░█░▄▀█░▄▀░░█░▄▀█░▄▀░
░░▀░░░▀░░░░░▀░░░▀░░░
Just_Iakov
Scratcher
100+ posts

() of () for clones workaround

epicbattler3 wrote:

could you by any chance share or provide a link to the project?

the project is unshared, and i have no intention on sharing it currently

That's fine.

So what you want to make is a bullet to be destroyed whenever it comes in contact with an enemy with a custom hitbox?


—-Edited—-
I've created a “cheating” method.

Link: https://turbowarp.org/576604057 (space to shoot and mouse to navigate) any sprites that says true would block the bullet.

Instead of using lists, cloneIDs, etc, whenever the sprite is touched by bullet, it read wether it's a hitbox or not, if it is, it quickly switches to red sprite hitbox, and if the bullet is touching the sprite and red color, it deletes itself.

I don't think there is a very effective method to directly scan the clone private variables/costumes.

This isn't the most effective method, but it works.

I hope this helps.

Last edited by Just_Iakov (Sept. 29, 2021 08:38:25)

epicbattler3
Scratcher
55 posts

() of () for clones workaround

I was hoping it wouldn't come to the touching color blocks, but it seems tight enough that it should work
Thanks a whole bunch!

EDIT: I tried it out in-project, and it doesn't work. I have the hitbox sprite at 100% ghost, changing it to 0% doesnt work either for some odd reason

EDIT2: my code is as follows -

when I start as a clone
play sound (pick random (5) to (7))
show
go to [back v] layer
move (30) steps
repeat until <<touching [edge v] ?> or <<<touching [Dummy's Hitbox (irrelevant) v] ?> or <<<touching color [#6115ED] ?> or <>>>>>>
move (10) steps
end
if <touching [edge v] ?> then
delete this clone
else
set [hitY v] to (y position)
set [hitX v] to (x position)
create clone of [explosion v]
delete this clone
end

(the hity and hitx and explosion are purely for particle effects, removing them has no effect)


EDIT3: I've come to the conclusion this won't work, as I have an overlay over the screen that blocks out the colors and 3 separate clones per enemy (pupil , body, hitbox) 2 of which will be over the hitbox at all times

Last edited by epicbattler3 (Sept. 29, 2021 18:10:38)


░▄▀▄▀▀▀▀▄▀▄░░░░░░░░░
░█░░░░░░░░▀▄░░░░░░▄░
█░░▀░░▀░░░░░▀▄▄░░█░█
█░▄░█▀░▄░░░░░░░▀▀░░█
█░░▀▀▀▀░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░█
░█░░▄▄░░▄▄▄▄░░▄▄░░█░
░█░▄▀█░▄▀░░█░▄▀█░▄▀░
░░▀░░░▀░░░░░▀░░░▀░░░

Powered by DjangoBB