-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Syntax and logic fixes #8
Conversation
local customSpawnsForMap = cfcRandomSpawn.config.CUSTOM_SPAWNS[game.GetMap()] | ||
local mapHasCustomSpawns = customSpawnsForMap ~= nil | ||
|
||
hook.Remove( "PlayerSpawn", "CFC_PlayerSpawning" ) | ||
|
||
if mapHasCustomSpawns then | ||
cfcRandomSpawn.spawnPointRankings = cfcRandomSpawn.spawnPointRankings or {} | ||
if not mapHasCustomSpawns then return end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short-circuit Instead of blanketing the entire file in a condition
-- This is operating on a model of spawn points and players as electrons putting a force on each other | ||
-- The best spawn point is the spawn point under the smallest sum of forces then. This is why we use physics terms here | ||
local distSqr = 900 --(30^2) | ||
local randMin, randMax = 1, 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract these houdini bois
if not (ply && IsValid( ply )) then return end | ||
if ply.LinkedSpawnPoint then return end | ||
function cfcRandomSpawn.handlePlayerSpawn( ply ) | ||
if not ( ply && IsValid( ply ) ) then return end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When CFCLib is official, this will be CFCLib.isValidPlayer( ply )
lua/cfc_random_spawn/sh_config.lua
Outdated
{ "spawn" = Vector( 425.38064575195, 1636.2911376953, 64.968605041504 ), "pvp" = true }, | ||
{ "spawn" = Vector( -974.1875, 130.53991699219, 128.03125 ), "pvp" = true }, | ||
{ "spawn" = Vector( -1357.5144042969, 1473.0662841797, 128.03125 ), "pvp" = true }, | ||
{ "spawn" = Vector( -1000.3621826172, 1044.5682373047, 464.03125 ) "pvp" = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious to know if this much precision is necessary...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"too much precision"
said no one ever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay frick you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good.
Let's change these keys and then give it a test and we'll merge it
lua/cfc_random_spawn/sh_config.lua
Outdated
Vector( -1357.5144042969, 1473.0662841797, 128.03125 ), | ||
Vector( -1000.3621826172, 1044.5682373047, 464.03125 ) | ||
|
||
{ "spawn" = Vector( 1104.6744384766, 131.18112182617, 64.03125 ), "pvp" = true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like these keys. Could we do:
{ "spawn_pos" = Vector( ), "isPvpSpawn" = true }
Something like that.
Mostly this helps the other file read better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, pending testing.
`[ERROR] addons/cfc_random_spawn/lua/cfc_random_spawn/sh_config.lua:7: '}' expected near '='
|
Haha, @justinmuskopf got LUA TABLE SYNTAX wrong, what a NERD |
|
||
return measurablePlayers | ||
local function getMeasurablePlayers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do something stupid here, and maintain a cache of alive players and only invalidate it when a player dies or spawns - that way it'd be slightly more efficient
lua/cfc_random_spawn/sh_config.lua
Outdated
Vector( -1357.5144042969, 1473.0662841797, 128.03125 ), | ||
Vector( -1000.3621826172, 1044.5682373047, 464.03125 ) | ||
|
||
{ "spawn_pos" = Vector( 1104.6744384766, 131.18112182617, 64.03125 ), "isPvpSpawn" = true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on @TechnichalDoge 's report, we may have to do this a different way. Something like this maybe:
local bluehills = {}
table.insert( bluehills, { "spawn_pos" = Vec(), "isPvpSpawn" = true } )
table.insert( bluehills, etc.)
cfcRandomSpawn.config.CUSTOM_SPAWNS["gm_bluehills_test3"] = bluehills
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plally reminded us that we're just as stupid as lua is. proper syntax is like such:
{ ["spawn_pos"] = Vector(), ["isPvpSpawn"] = true }
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-Authored-By: Brandon Sturgeon <[email protected]>
retest this please |
retest this please |
Resolves Issue #7