Modifying an emitter

Started by iwishforpie2, November 19, 2014, 03:18:16 PM

Previous topic - Next topic

iwishforpie2

What command would be that? I can't seem to find it on the wiki
What's a pie? I'm not a pie. I'm a pi.

Aeran01


iwishforpie2

Spawn an emitter with attributes.
What's a pie? I'm not a pie. I'm a pi.

iwishforpie2

#3
Here's my current code i'm messing with, i'm just not sure how to make it modify an emitter when it spawns.


# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
CurrentCoords GetTerrain 4 lt if 1
CreateUnit("EMITTER" CurrentCoords)
delay 999999
endif
What's a pie? I'm not a pie. I'm a pi.

Aeran01

Quote from: iwishforpie2 on November 19, 2014, 03:27:45 PM
Here's my current code i'm messing with, i'm just not sure how to make it modify an emitter when it spawns.

# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
CurrentCoords GetTerrain 4 lt if 1
   CreateUnit("EMITTER" CurrentCoords)
   delay 999999
endif

I think is easier to make a CRPLCore with no image and with an if when you reach certain conditions in your case i think it's time the core changes the image to a Emitter with your specifications tell me exactly what you want and I'll see if i can do the script

iwishforpie2

Quote from: Aeran01 on November 19, 2014, 03:33:33 PM
Quote from: iwishforpie2 on November 19, 2014, 03:27:45 PM
Here's my current code i'm messing with, i'm just not sure how to make it modify an emitter when it spawns.

# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
CurrentCoords GetTerrain 4 lt if 1
   CreateUnit("EMITTER" CurrentCoords)
   delay 999999
endif

I think is easier to make a CRPLCore with no image and with an if when you reach certain conditions in your case i think it's time the core changes the image to a Emitter with your specifications tell me exactly what you want and I'll see if i can do the script

I've figured out how to. Thanks for acknowledging and trying to help. It makes me feel more confident about myself, knowing the community is there.

Final script:


# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
CurrentCoords GetTerrain 4 lt if 1
CreateUnit("EMITTER" CurrentCoords) ->child
SetScriptVar(<-child 0 "productionAmt" 35)
delay 999999
endif
What's a pie? I'm not a pie. I'm a pi.

Aeran01


J

You used 'delay 999999' in your script. If you wanted to delay the next execution of the script by 999999 frames, you put them in reverse order (should be '9999 Delay' or 'Delay 9999' then), but if you only want to execute a script once, it is better to use a 'once'-block. This way the emitter won't respawn if the player turtles for too long.
I've cleaned up the code a bit:

# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
once
CurrentCoords GetTerrain 4 lt if
CreateUnit("EMITTER" CurrentCoords) ->child
SetScriptVar(<-child 0 "productionAmt" 35000000)
SetScriptVar(<-child 0 "productionInterval" 15)
endif
endonce

iwishforpie2

I've made it destroy itself so it doesn't sit there.
What's a pie? I'm not a pie. I'm a pi.

kwinse

Quote from: J on November 19, 2014, 04:39:29 PM
Spoiler

# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
once
CurrentCoords GetTerrain 4 lt if
CreateUnit("EMITTER" CurrentCoords) ->child
SetScriptVar(<-child 0 "productionAmt" 35000000)
SetScriptVar(<-child 0 "productionInterval" 15)
endif
endonce
[close]
That will only run the terrain check once. If you want it to create the emitter once and not on the first time the script executes, you need to put the once block in the if block.

Destroying itself is better though if the core serves no other purpose.