Scripts / How can i do this.? is it possible?

Author
Message
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 7th Dec 2019 12:48
Ok let say i have a street setup like this

But i want the houses to change every time the player enter the map.
lets say i name the houses house1 , house2 , house3 and so on.
how can i randomly spawn the houses in the yards at the correct place in the yard
So every time the player enters the map the street setup of houses will look different.

Thanks for any help.

Pcs
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11

Attachments

Login to view attachments
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 7th Dec 2019 13:34 Edited at: 7th Dec 2019 14:05
are the houses made from 1 object and do they all have the same origin point?
if yes you can put the location data (or a dummy object) and swap between them

like


for the house you can do something like this to automate the process (assuming you place each of the houses in 1 of the desired locations)


note that to support more than 4 houses you need to increase the 'for' loops i.e. for h = 1,# <- this value

might be some errors as i wrote it here
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 7th Dec 2019 14:51
smallg yes the houses are all made from one object but i am not sure about the origin point.
So do i need both the scrips to work ?
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Dec 2019 17:35
Quote: "So do i need both the scrips to work ?"

yep, they're more pseudo code than working scripts as i hoped you may have some lua knowledge already but you would need 1 object to run place_houses.lua and then houses.lua is assigned to the houses themselves (and the houses placed in 1 of the desired locations)

(also would be a good idea to swap the 'for' loops to an 'in pairs' loop)

if i get chance i'll write them up properly for you tomorrow if you still need help with it
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 9th Dec 2019 12:17
here you go, a working version - you would need 1 object to run place_houses.lua and then houses.lua is assigned to the houses themselves (and the houses placed in 1 of the desired locations)
p.s. i have left a testing mode on which will shuffle the houses when you press E in game, just set testing = 0 to disable it
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 9th Dec 2019 22:48
thank you smallg,
I will test asap.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 10th Dec 2019 00:14
@ PCS
I think you should also control the last position, to avoid repeating positions in the next map test.

If someone wants to try this script, they must create a text file with the notepad, write the number "0" (without quotes) and save as "random_pos.txt" in the Files folder.

I suggest that the buildings be similar in size, otherwise you will have to make adjustments to the script and the thing gets complicated.

Although in this case it helps a lot that the script is for your game, since you know your houses, you know their sizes, properties and so on, so you can adjust the script to fit your needs.











hth
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

Attachments

Login to view attachments
PM

Login to post a reply

Server time is: 2024-04-24 19:17:37
Your offset time is: 2024-04-24 19:17:37