problem with a script for a score
3 posts • Page 1 of 1
problem with a script for a score
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?
(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
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:
Until you do that, I can't figure out how to solve your problem.
- 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
- Ken3344
- Posts: 53
- Joined: Mon Sep 05, 2016 8:44 pm
Re: problem with a script for a score
now i found a way to solve this, my self.
It works now.
It works now.
- Drachenbauer
- Posts: 18
- Joined: Thu Jun 20, 2019 5:29 pm
3 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests