Jump to content

Particle Emitter defined in a Map, how to access in Lua Script?


Gonan
 Share

Recommended Posts

I have created an erupting volcano map, by adding a particle emitter to the caldera (volcano's crater), in the editor, with Realtime Render option ticked, it displays the blobs of lava flying out all around the volcano.

 

When I try to run it from script, in debug or run, the map loads but the emitter does not display. I thought maybe its been Reset and I need to get it to Play().

 

I can not find how to reference the objects which show in the Scene tab in the map editor, from Lua script.

 

I don't want to create the emitter, and set its values, within the script.

 

In App.lua i've set up the map to load

 

--Load a map

local mapfile = system:GetProperty("map","Maps/Erruption.map")

If Map:Load(mapfile,1)==false then return false end

 

// play ParticleEmitter2 which is the last item added on the Scene tab in the map editor.

ParticleEmitter2.Play()

// gives Error attempt to index global 'PaticleEmitter2' (a nil value)

 

return true

end

 

How should I reference that emitter contained in the loaded map using lua code?

 

Ive tried, prefixing the line with self.map., self.world.map. , self.context.map. self.world: and lots of other combos to no avail.

Link to comment
Share on other sites

I have created an erupting volcano map, by adding a particle emitter to the caldera (volcano's crater), in the editor, with Realtime Render option ticked, it displays the blobs of lava flying out all around the volcano.

 

When I try to run it from script, in debug or run, the map loads but the emitter does not display.

 

That seems strange as I can add an emitter to a scene, load the scene via script, and it works just fine. The only problem I have had is with using sprite sheets with an emitter that is part of a prefab. If the sprite sheet emitter was part of a prefab, it would just show the entire sheet instead of individual tiles. Are you using the beta?

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Thanks Rick and macklebee, I am new to Lua, but experienced with C++.

 

No luck with the FindEntity function.

 

I am now trying the Map:Load with the script option, to see if I can access the ParticleEmitter2

 

I am using steam leadwerks 3.2, not using the beta. Should I switch to the beta?

Link to comment
Share on other sites

I found the problem with the emitter not displaying in game. This was when I ticked the Shape hint, on the physics tab the emitter no longer displayed in game, but was ok in the editor, but if I unticked it, it was ok in both.

 

that sounds like a bug to me - or at least maybe the editor needs to remove certain properties based on the type of object?

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...