City Tycoon Devlog

I have not posted on here in a while. I sort of forgot… :no_mouth: Although I’m going to now catch you up on everything I’ve done, and maybe give you some code to learn from!

First off, I have created separate zones around the game that are over different places that a player may own. This enables me to not let them open the build menu when their 50 miles away from their plot! To accomplish this I found this very helpful module by @ForeverHD, the creator of many helpful open source projects. To accomplish this I simply used this snippet:

local Zone = require(game.ReplicatedStorage.Modules.ZoneModule)
local zone = Zone.new(workspace.Tycoons.bostnmTycoon.CarDealership.Zone)

zone.playerEntered:Connect(function(player)
	player.Values.PlayerBuildingLocation.Value = "CarDealership"
end)

zone.playerExited:Connect(function(player)
	player.Values.PlayerBuildingLocation.Value = "House"
end)

This of course is just a test I used, as its not near efficient!

After I changed the value I had the building system check their value before enabling building!

While there is not much to say here I might as well just state that I have been squashing many bugs throughout this time period! For example I fixed a detrimental bug that doesn’t load any previews for models about to be built. I’m not going to say anymore because the rest are just behind the scenes!

@Beatitkid4 and @goalmwo, I’ve decided not to add any cars driving on roads. I thought it over for a while and decided that it is a little too much. While I might change my mind when the finished project comes, right now I’m not planning on adding any cars to the road. Besides player cars of course :smile:

Now for the car update :hushed:
In the 30+ days of no replies I’ve been working on hard on the entire car system. I’ve also made a huge change to the way to get cars. Previously there was a dealership in a place called central city, where everyone can access it. Well, although this could work, I wondered about making cars another thing to unlock. By this I mean it would be another place you can customize, but instead of making you any money it instead provides you a way to purchase cars! I thought this idea was amazing, but if you think not please let me know.(Give a good reason!) After making it like that I no longer had to decorate it, which checked that off my list! I then came to the car purchase system, which has some pretty big bugs but is overall working nicely. The bugs will get solved once I get around to bug fixes again. Now that I’ve told you about it its time to show! Below is a picture since I cannot get a video right now!


I’ll go ahead and break it down right here!

  • Confirm Button

    • Center Bottom
    • Clicking this gives you a value in your car inventory that will later be used to spawn cars.
  • Stats Menu

    • Left Middle
    • This menu displays all the car stats, while changing every time you change cars.
  • Main Display

    • Center Top
    • Displays name and price, with arrows to switch cars
  • Color Picker

    • Right Middle
    • Allows you to change the color of your car to your liking.

After doing that I went and made a little function to get the rating of a selected place. Below is the code I used for it!

function module.getRating(tycoon)
	
	local function getCleanliness(count)
		local cleanRating = 5
		for i=count, -1, 0 do
			print(i)
			if cleanRating - 0.25 >= 0 then
				cleanRating -= 0.25
			end
		end
		return cleanRating
	end
	
	local function getDecor(items)
		local objects = require(game.ReplicatedStorage.Modules.Dictionaries.Objects)
		local decorRating = 0
		for i, item in pairs(items) do
			if objects[item.Name] then
				local itemStats = objects[item.Name]
				if itemStats.Class == "Decor" then
					if decorRating + 0.25 <= 5 then
						decorRating += 0.25
					end
				end
			end
		end
	end
	
	local function getPopularity(people)
		local popRating = 0
		for i, person in pairs(people) do
			if person.Values.Rarity then
				local increment = person.Values.Rarity.Value / 4
				if popRating + increment <= 5 then
					popRating += increment
				else
					popRating = 5
				end
			end
		end
	end
	
	local function getService()
		
	end
	
	local function getQuality()
		
	end
	
	local cleanliness = getCleanliness(tycoon.Garbage.GarbageCount)
	local decoration = getDecor(tycoon.PlacedItems:GetChildren())
	local popularity = getPopularity(tycoon.NPCs:GetChildren())
	local service = getService()
	local quality = getQuality()
	
	local rating = (cleanliness+decoration+popularity+service+quality) / 5
	
	return rating
end

At the time of writing I have not found a way to get a value for the last two yet, but I’m getting there!

PLEASE DON’T STEAL THIS CODE
You may not copy and paste this code for your own game, instead I showed it to you for you to understand it better and learn from it if you need to.

Last but not least, a simple code system! I used a previous system I made and edited it to fit the game, although the UI is completely new! Not much to say about this as its just the generic code system. I can still give you a picture though!
Screen Shot 2022-04-02 at 4.00.47 PM

Wrapping all this up, I must ask for feedback. This can be on literally anything covered in here! From simply an idea to an entire rework, I’m willing to consider all. After all, I want this game to be enjoyed by everyone, and not just be to my liking. A major thing that I think might need feedback is the UI on these systems, if you have any feedback on those please, please, please tell me! Have a great day!

3 Likes