problem with a script for a score

If you have problems installing or running Algodoo, have found a bug or need in-game help - this is it!

problem with a script for a score

Postby Drachenbauer » Fri Jul 05, 2019 6:45 pm

I have this in "on collision" in the script-menu:

(e)=>{
{
e.other.texture == "Minion_pig_240.png"
} ? {
scene.my.red = scene.my.red + 5000
} : {
{
e.other.texture == "CorporalPig.png"
} ? {
scene.my.red = scene.my.red + 10000
} : {
{
e.other.texture == "KingPig.png"
} ? {
scene.my.red = scene.my.red + 20000
}
}
}
}

it should detect, if the other object of the collision has got one of theese three pig-textures and if je, add a matching score-value to the score of the bird, who holds this script.

But the score stays "0" (i display it on a rectangle, that should be my score-panel for this bird).

{condition}?{do_this_if_its_true}:{else_do_this}

the script should be three if-blocks like this, each one in the else-section of another, because there are three types of pigs around in my simulation, wich should make different score-values.
I see in this sample from a wiki, that all three parts are in curly brackets.
So i did this too.

In the script-menu, it turned into this:
(e)=>{
{
e.other.texture == "Minion_pig_240.png"
} ? {
scene.my.red = scene.my.red + 5000
} : {
{
e.other.texture == "CorporalPig.png"
} ? {
scene.my.red = scene.my.red + 10000
} : {
{
e.other.texture == "KingPig.png"
}(?)({
scene.my.red = scene.my.red + 20000
})
}
}
}

it adds round brackets around "?" and the to do part of the third if-block.

And if i try to add an empty else-part to the third if-block, the code will be replaced with "[BAD]" and the game crashes.

Why this script does not do, what i want and what is the right way to cause three diffent actions with three different conditions?

The birds are set to "killer" and "immortal", the pigs not.
Does that mean, the pigs disappear too fast for my script to check their textures?
Drachenbauer
 
Posts: 18
Joined: Thu Jun 20, 2019 5:29 pm

Re: problem with a script for a score

Postby Ken3344 » Mon Jul 22, 2019 8:05 pm

Your scripts are too confusing for me to trouble shoot. I'd appreciate it if you copy and pasted the script from Algodoo. Like this:
Code: Select all
(e)=>{
    e.other._marble ? {
        e.other.postStep = (e)=>{
            pos = _pos
        }
    } : {}
}

Until you do that, I can't figure out how to solve your problem.
Hello my name is Kenlimepie. I'm an Algodoo Enthusiast, and Marble Racer. I run a Youtube channel which is about Algodoo Marble Racing, but I am not afraid to design new ideas in this program. https://www.youtube.com/c/kenlimepie
User avatar
Ken3344
 
Posts: 53
Joined: Mon Sep 05, 2016 8:44 pm

Re: problem with a script for a score

Postby Drachenbauer » Thu Jul 25, 2019 9:33 pm

now i found a way to solve this, my self.

It works now.
Drachenbauer
 
Posts: 18
Joined: Thu Jun 20, 2019 5:29 pm


Return to Help / Bug reports

Who is online

Users browsing this forum: No registered users and 2 guests