Need help with quick spawning
8 posts • Page 1 of 1
Need help with quick spawning
Hello. I'm making a gun that I'm doing a muzzle flash efect on. I need to spawn a box with the muzzle flash texture.
I need this box to rise it's color value from color(3) = 0 to color(3) = 1 and then back to color(3) = 0. And when it's lower than color(3) <= 0.0 it will delete itself.
I've heard of dynamic variables but I could really get it to work. Perhaps if I got it explained for this problem I might understand. Please share your expirience to a lesser knowing being
Thank you
I need this box to rise it's color value from color(3) = 0 to color(3) = 1 and then back to color(3) = 0. And when it's lower than color(3) <= 0.0 it will delete itself.
I've heard of dynamic variables but I could really get it to work. Perhaps if I got it explained for this problem I might understand. Please share your expirience to a lesser knowing being
Thank you
-

Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Need help with quick spawning
For a spawned geom with dynamic variable you need to use "geval".
To use type: "geval(*spawning code(including dynamic variables) as string*)"
So if you spawn a circle with dynamic HSVA color you can use:
To use type: "geval(*spawning code(including dynamic variables) as string*)"
So if you spawn a circle with dynamic HSVA color you can use:
- Code: Select all
geval("Scene.addCircle({color := {[sim.time, 1, 1, 1]})")
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
-

Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: Need help with quick spawning
I'll try that. haven't used geval before 
-

Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Need help with quick spawning
Well I can't spawn it. Here's the code:
This is my error message:
- Code: Select all
(e)=>{
geval("Scene.addBox({
color := {[sim.time, 1.0, 1.0, 1.0]};
drawBorder := true;
textureMatrix := [0.1388889, 0.0, 0.2777863, 0.0, 0.1736111, 0.5442616, 0.0, 0.0, 1.0];
texture := "Muzzle_Flash_Side.png";
collideSet := 0;
zDepth := +inf;
geomID := 10233453;
pos := e.pos;
angle := 0.0;
size := [6.26, 1.75]
})")
}
This is my error message:
- Code: Select all
-- Warning: Caught exception: Line 2: Newline in string literal, Source\script\Parser.cpp:174: class SharedPtr<class script::CodeBlock> script::Parser::Parse(const util::String &,class SharedPtr<class script::Reflected>)
Tokenizer error: Line 2: Newline in string literal
-

Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Need help with quick spawning
When you want to use " in a text string you have to add the escape character \ before it.
- Code: Select all
(e)=>{
geval("Scene.addBox({
color := {[sim.time, 1.0, 1.0, 1.0]};
drawBorder := true;
textureMatrix := [0.1388889, 0.0, 0.2777863, 0.0,
0.1736111, 0.5442616, 0.0, 0.0, 1.0];
texture := \"Muzzle_Flash_Side.png\";
collideSet := 0;
zDepth := +inf;
geomID := 10233453;
pos := e.pos;
angle := 0.0;
size := [6.26, 1.75]
})")
}
- REMqb
- Posts: 15
- Joined: Wed Dec 30, 2009 7:51 pm
- Location: France
Re: Need help with quick spawning
How can I deal with newlines? I can't spawn unless I remove every newline and I don't want a scrambled text :S
-

Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Need help with quick spawning
As far as I know this isn't possible, you just need to get used to it...
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
-

Matten - Posts: 435
- Joined: Mon Apr 05, 2010 2:03 pm
- Location: The Netherlands
Re: Need help with quick spawning
Another way:
No need to use geval
.
- Code: Select all
(e)=>{
o = Scene.addBox({
drawBorder := true;
textureMatrix := [0.1388889, 0.0, 0.2777863, 0.0, 0.1736111, 0.5442616, 0.0, 0.0, 1.0];
texture := "Muzzle_Flash_Side.png";
collideSet := 0;
zDepth := +inf;
geomID := 10233453;
pos := e.pos;
angle := 0.0;
size := [6.26, 1.75]
});
o.color = {[sim.time, 1.0, 1.0, 1.0]};
}
No need to use geval
- REMqb
- Posts: 15
- Joined: Wed Dec 30, 2009 7:51 pm
- Location: France
8 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests




