Jump to content

Script to create roads?


SteveV
 Share

Recommended Posts

I put this request in a while ago but i seem to have lost it.

 

I'm still trying to work out if it's possible to programmatically add a road in the editor. I want to create a road several kilometres long with many nodes, and it would be great if I could start by scripting the placement of, for example, 20 nodes in a circle on the terrain.

 

Any ideas anybody? I made an attempt earlier to replicate entities, but they never got saved. Maybe there is something I can do to register the entities/nodes in the saved world file?

All the best,

Steve Vink

Link to comment
Share on other sites

This is how I tried to replicate my objects:

 

lwclone.jpg

 

1. Create an entity (oildrum)

2. Add the CloneObject entity (just a cube to which I can attach a script)

3. Name the object to clone and the number of clones in the CloneObject parameters

4. Apply, and allow the script to clone away.

 

The script that is triggered follows:

 

	function object:CloneMe()

	SourceObject = object.model:GetKey("ObjectName")
	found = 0
	count = 0

	for k,v in pairs(objecttable) do
                       if SourceObject == GetEntityKey(v.model, "name") then
			found = 1
			tempModel = v.model
		end
	end


	if found == 1 then
		for i = 1, object.model:GetKey("ObjectCount") do
			newObj=tempModel:Copy()
			newObj:Move(3,0)
		end
	else
		Notify("Failed to find object " .. SourceObject,1)
	end


end

end

 

As you can see in the screenshot the extra oildrum is not "registered" in the list of scene entities. The other problem I have is that the copy works, but trying to move the copy fails - object not found. This could be a simple logic error, or related to the entity not existing in the system.

All the best,

Steve Vink

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...