View unanswered posts | View active topics It is currently Thu Aug 22, 2019 9:16 pm



Reply to topic  [ 10 posts ] 
 Creating terrain using lua 
Author Message
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post Creating terrain using lua
I'm currently working on a mod that will allow the player to save the game and load it later to continue playing it, here is how it works: it saves the actors, objects, particles...etc and the terrain pixel per pixel into a file. It works fine, it only takes a few seconds and is very reliable, now the problem I have is reconstructing the map one pixel at a time. Is there a way to construct terrain in an efficient way using lua? The only solution I see right now is defining a pixel for each material in ini, then spawn these through lua and settle them, but it would be extremely laggy and unreliable.

Image


Attachments:
save.png
save.png [ 9.63 KiB | Viewed 1450 times ]
Fri Sep 16, 2011 1:20 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Creating terrain using lua
Assuming you've got a background file defined for the scene (which has to cover every pixel of terrain you place, otherwise it'll become scrap and be useless) then you could try settling MOSRotatings.

Just spawn in a probably 24px square MOSR that is set to settle immediately. That should work, from what I remember from working on the Constructor, but it may not. I can't think of anything that would be any better than a per-pixel addition process, except maybe carving out a mostly-dirt map.


Fri Sep 16, 2011 7:07 pm
Profile
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post Re: Creating terrain using lua
Thanks, I tried the one pixel at a time method and if well optimized it isn't that laggy, but now I have another problem: I can't settle MOPixels properly: even with ToSettle = true they still refuse to settle in mid air(they just do when they touch already existing terrain), Why is that? Is there a way to counter it?


Sat Sep 17, 2011 11:15 am
Profile
User avatar

Joined: Mon Apr 13, 2009 12:27 pm
Posts: 813
Location: Yogyakarta, Indonesia. A slice o' paradise.
Reply with quote
Post Re: Creating terrain using lua
Mehman wrote:
Thanks, I tried the one pixel at a time method and if well optimized it isn't that laggy, but now I have another problem: I can't settle MOPixels properly: even with ToSettle = true they still refuse to settle in mid air(they just do when they touch already existing terrain), Why is that? Is there a way to counter it?


1-pixel thick line as floor. After filling the surface area, 'delete' parts of it for caves.


Sat Sep 17, 2011 1:14 pm
Profile YIM WWW
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post Re: Creating terrain using lua
Isn't there a way to force a particle to settle?

Edit: Nevermind, found a way.


Sat Sep 17, 2011 2:32 pm
Profile
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post Re: Creating terrain using lua
New problem: How do I prevent settled terrain from being too easily destroyed, as in if you destroy one pixel it will destroy a line of 25 pixels above it?


Sun Sep 18, 2011 3:50 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Creating terrain using lua
Terrain needs to have a Background defined behind it. In Scenes, that's handled by the MAT file. In the case of bunkermodules, whatever is in the BG file will add itself to the scene's overall Background mask.

There's absolutely no way around the problem. It's an issue with IsScrap, which is auto-set by the engine in order to keep dropship debris and etc from piling up too heavily.


Sun Sep 18, 2011 6:32 pm
Profile
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post Re: Creating terrain using lua
Then can I create bunker modules using lua?
In the wiki the description of SceneMan:AddSceneObject() states:
Quote:
Takes any scene object and adds it to the scene in the appropriate way. If it's a TerrainObject, then it gets applied to the terrain, if it's an MO, it gets added to the correct type group in MovableMan.


which implies there is a way to create and/or modify TerrainObjects with lua, how do I do that?


Sun Sep 18, 2011 6:47 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Creating terrain using lua
I think that, unfortunately, AddTerrainObject is still an engine-only function. I've never found a way to get it to work, and I did some fairly extensive experimentation, as did TLB. This was the main problem I had with my Constructor mod.

Really the only way around it for your application, that is, reloading a saved scene, would be to make the entire background of the scene a flat BG in the actual Scene .bmp files. I can't think of any other reliable way to do it, because there's really no way to force bunker module construction at any point. Unfortunately.


Sun Sep 18, 2011 6:50 pm
Profile
User avatar

Joined: Tue Nov 17, 2009 7:38 pm
Posts: 909
Location: France
Reply with quote
Post Re: Creating terrain using lua
Then I guess I'll just have to make the script write a .BMP of the terrain, and use it as a MAT file for the loaded scene.


Sun Sep 18, 2011 7:25 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.021s | 15 Queries | GZIP : Off ]