Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add voxels' weapons #9

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Add voxels' weapons #9

wants to merge 2 commits into from

Conversation

caillef
Copy link
Contributor

@caillef caillef commented Aug 7, 2023

No description provided.

@caillef caillef self-assigned this Aug 7, 2023
@caillef caillef marked this pull request as draft August 7, 2023 07:39
aduermael
aduermael previously approved these changes Aug 16, 2023
Copy link
Collaborator

@aduermael aduermael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Corentin Cailleaud added 2 commits November 13, 2023 10:12
…ganization.

# Aider chat conversation:

USER: what are the top 3 easy fix for this code?

ASSISTANT: 1. Code Commenting and Documentation: The code lacks proper commenting and documentation. This makes it hard for other developers to understand the code. Adding comments to explain complex sections of code and documenting the functions, their parameters, and return types can greatly improve the readability and maintainability of the code.

2. Code Organization: The code could be better organized. For instance, all the function definitions are scattered throughout the code. It would be better to group related functions together or even separate them into different files based on their functionality.

3. Use of Magic Numbers: The code contains magic numbers, i.e., raw numbers that appear directly in the source code without any explanation of what they represent. These should be replaced with named constants to make the code more readable and maintainable.

Please note that these are general suggestions. To provide more specific suggestions, I would need more context or specific issues you're facing with the code.

USER: Do the code organization and magic number stuff

ASSISTANT: To improve the code organization and replace magic numbers with named constants, we can make the following changes:

1. Group related functions together.
2. Replace magic numbers with named constants.

Here are the changes:

```lua
caillef/retromotorclub.lua
<<<<<<< SEARCH
local _DEBUG = false -- start with a single player
local _SOUND = false -- enable sound

gameStates = {
	Waiting = 0,
	Starting = 1,
	Running = 2,
	End = 3
}

local TRAIL_COLORS = { 31, 7, 136, 94, 52, 181, 160, 55 }
local MAP_SIZE = 100
speed = 90

local FORWARD,RIGHT,BACKWARD,LEFT = 0,1,2,3
=======
-- Named constants
local DEBUG_MODE = false -- start with a single player
local SOUND_MODE = false -- enable sound

-- Game states
local GAME_STATES = {
	WAITING = 0,
	STARTING = 1,
	RUNNING = 2,
	END = 3
}

-- Trail colors
local TRAIL_COLORS = { 31, 7, 136, 94, 52, 181, 160, 55 }

-- Map size
local MAP_SIZE = 100

-- Speed
local SPEED = 90

-- Directions
local DIRECTIONS = {
	FORWARD = 0,
	RIGHT = 1,
	BACKWARD = 2,
	LEFT = 3
}
>>>>>>> REPLACE
```

```lua
caillef/retromotorclub.lua
<<<<<<< SEARCH
Client.OnStart = function()
	require("uikit.lua")
	if not ui then
		ui = require("uikit")
	end

	spawnPlayer = function(p)
		if not p.init then initPlayer(p) end
		resetTrailsOfPlayer(p)
		p.hasPlayed = true
		p.isDead = false
		p.spec = false
		p.avatar.IsHidden = false
		activateGhost(p, 1)
		-- p.avatar:ClearTextBubble()

		-- Set position
		local pos
		if p.ID % 4 == 0 or (p.ID - 1) % 4 == 0 then
			pos = Number3((((p.ID % 8) - 1) % 4 == 0 and -1 or 1) * (p.ID % 8 < 4 and 0.6 or 0.8), 0, 0) * MAP_SIZE / 2
		else
			pos = Number3(0, 0, (((p.ID % 8) - 3) % 4 == 0 and -1 or 1) * (p.ID % 8 < 4 and 0.6 or 0.8)) * MAP_SIZE / 2
		end
		pos = Number3(pos.X, 0.5, pos.Z) * Map.LossyScale
		setPlayerPosition(p, pos)

		-- Set direction
		local dir = FORWARD
		local id = p.ID % 8
		if id == 0 or id == 5 then dir = FORWARD end
		if id == 1 or id == 4 then dir = BACKWARD end
		if id == 2 or id == 7 then dir = LEFT end
		if id == 3 or id == 6 then dir = RIGHT end
		rotatePlayerAndSpawnTrail(p,dir)

		if not p == Player then
			-- p.avatar:TextBubble(p.Username,-1,0,Color.White,Color(0,0,0,0))
		end

		if cameraOrbit then
			cameraOrbit:AddChild(Camera)
			Camera.LocalPosition = Number3(0,30,-30)
			Camera.LocalRotation = cameraLocalRotation
		end
	end
=======
-- Client functions
Client.OnStart = function()
	require("uikit.lua")
	if not ui then
		ui = require("uikit")
	end

	-- Spawn player function
	spawnPlayer = function(p)
		if not p.init then initPlayer(p) end
		resetTrailsOfPlayer(p)
		p.hasPlayed = true
		p.isDead = false
		p.spec = false
		p.avatar.IsHidden = false
		activateGhost(p, 1)

		-- Set position
		local pos
		if p.ID % 4 == 0 or (p.ID - 1) % 4 == 0 then
			pos = Number3((((p.ID % 8) - 1) % 4 == 0 and -1 or 1) * (p.ID % 8 < 4 and 0.6 or 0.8), 0, 0) * MAP_SIZE / 2
		else
			pos = Number3(0, 0, (((p.ID % 8) - 3) % 4 == 0 and -1 or 1) * (p.ID % 8 < 4 and 0.6 or 0.8)) * MAP_SIZE / 2
		end
		pos = Number3(pos.X, 0.5, pos.Z) * Map.LossyScale
		setPlayerPosition(p, pos)

		-- Set direction
		local dir = DIRECTIONS.FORWARD
		local id = p.ID % 8
		if id == 0 or id == 5 then dir = DIRECTIONS.FORWARD end
		if id == 1 or id == 4 then dir = DIRECTIONS.BACKWARD end
		if id == 2 or id == 7 then dir = DIRECTIONS.LEFT end
		if id == 3 or id == 6 then dir = DIRECTIONS.RIGHT end
		rotatePlayerAndSpawnTrail(p,dir)

		if not p == Player then
			-- p.avatar:TextBubble(p.Username,-1,0,Color.White,Color(0,0,0,0))
		end

		if cameraOrbit then
			cameraOrbit:AddChild(Camera)
			Camera.LocalPosition = Number3(0,30,-30)
			Camera.LocalRotation = cameraLocalRotation
		end
	end
>>>>>>> REPLACE
```

Please note that these changes are just examples. You may need to adjust them based on your specific needs and coding style.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants