#development

1 messages · Page 185 of 1

wheat mesa
#

inline is a suggestion to the compiler

radiant kraken
#

inline inlines your code to whoever calls it

#

it's good for one-liner functions

#

that serves as an alias to call another function

sharp geyser
#

so if they were to call push_back normally it'd just inline the insert code into the file they called it in?

radiant kraken
#

mhm

sharp geyser
wheat mesa
#

It tells the compiler "hey, whoever is calling this function, instead of calling it, what you're really doing is insert(length, element), so just call that instead"

#

The compiler can choose to ignore you whenever it wants though

#

Inline is good for returning private variables that you want to have get-only access

sharp geyser
#

Okay so I need to

  1. Resize the vector to be able to take in a new element
  2. Insert said element
wheat mesa
#
class A {
private:
  int m_Member;
public
  // Caller doesn't have direct access to m_Member, so encapsulation is preserved
  // But no precious stack space is wasted by doing a function call
  inline int GetMember() const { return m_Member; }
}
radiant kraken
#

you can also add constexpr

#

to that code

wheat mesa
#

no you cannot

radiant kraken
#

yes you can

wheat mesa
#

m_Member is still memory allocated, the compiler cannot guess what it is ahead of time

#

let me test

radiant kraken
#

no, i'm referring to the function

#

not the property

wheat mesa
#

I know

radiant kraken
#
pub const fn get_thing(&self) -> Thing {
  self.thing
}
``` is legal in Rust so
wheat mesa
#

oh wait you can

#

why

#

that's weird

radiant kraken
#

why not

sharp geyser
#

grr see this is why I am not motivated, I am trying to think of how to approach this push_back method but I don't even know where to start

radiant kraken
sharp geyser
#

My first thought is to resize the array so it can take in a new element, which seems to be correct

#

but idk how to resize it by, initially I thought to take the current length and plus 1 it

radiant kraken
#

theoretically you can, though i recommend ```cpp
while (length < capacity) {
length *= 2;
}

wheat mesa
#

doubling the capacity of the array is generally an acceptable solution

sharp geyser
#

I already have a resize_to_fit function

wheat mesa
#

Can cause problems with large amounts of elements but for your case that's not a problem at all

sharp geyser
#

might as well use that

wheat mesa
#

Don't

sharp geyser
#

Why?

radiant kraken
#

wait if length is zero then set it to 1

wheat mesa
#

Because ideally you should only have a resize() function

#

The resize_to_fit function was made specifically for your previous insert method

#

Which is flawed because you shouldn't ever be "resizing to fit some index"

sharp geyser
#

Well wouldn't I essentially do the same thing?

#

I need to change the capacity and make a new array and move the elements to that array

wheat mesa
#

It's the same concept but you should get rid of that function altogether because you should not be resizing to an index like that

sharp geyser
#

oh well yea

#

i'd do it based off the length and capacity no?

wheat mesa
#

The capacity should be controlled/changed ONLY when you run out of space in your array; every element should be contiguous

#

Yes

#

Length and capacity only

radiant kraken
#

capacity: size of the array in memory
length: the amount of populated members in said array

sharp geyser
#

Okay so when should I technically call this new method?

radiant kraken
#

capacity must always be equal or greater than length

wheat mesa
sharp geyser
#

Should I check to see if the array can take in a new member and if not then call it?

sharp geyser
#

So could I still use the skeleton of my resize_to_fit method but just remove its reliance on an index?

#

or would it be different code?

#

to me it seems it'd be roughly the same

#

but instead just make it check on length and capcity instead of capacity and index

wheat mesa
#

Roughly the same yes

#

Try to think about what it does though

#

If you double your capacity, you have to allocate a new block of memory. Then, you have to copy those elements over to the new allocated block of memory. Then you must delete the old memory, and set your array pointer to the new block of memory

sharp geyser
#

yea

wheat mesa
#

You can copy elements with a traditional for loop, or you can copy over elements with memcpy

sharp geyser
#

yea

wheat mesa
#

They work fundamentally the same and I'm sure the compiler would end up optimizing them to be the same exact code

sharp geyser
#
  void resize() {
    int newCapacity = capacity;
    while (newCapacity <= length) {
      newCapacity *= 2;
    }

    T* temp = new T[newCapacity];

    memcpy(temp, array, sizeof(T) * capacity);
    capacity = newCapacity;
    delete[] array;
    array = temp;
  }

this is what I currently have

#

is this remotely correct?

wheat mesa
#

Yes that's perfect

sharp geyser
#

then say I wanted to use it i'd do

#
void push_back(T element) {
  if(length >= capacity) {
    resize();
  }

  // Rest of code here
}
wheat mesa
#

Yup

#

Also just a quick note on the differences between delete and delete[]

#

delete is used for when the pointer only points to one object in memory

#

delete[] is used for when the pointer points to the first object in an array of objects that need to be deleted

sharp geyser
wheat mesa
#

The allocator tracks this data in the underlying implementation, but just make sure you use the right type of delete operator, otherwise you may cause a memory leak

sharp geyser
#

first object in an array of objects?

wheat mesa
#

Yes

sharp geyser
#

Not quite sure I follow

wheat mesa
#

If you allocate with new only, you must use delete, if you allocate with new Something[Size], you must use delete[]

sharp geyser
#

Well yea I follow that

#

I am not quite sure I follow your explanation

#

How is array in this case in an array of other objects?

wheat mesa
#

When you do ```cpp
int* a = new int[5];

#

a is just the memory address of the first integer in this array

radiant kraken
#

a is basically the memory address to the entire array

wheat mesa
#

Yes and no

radiant kraken
#

it just defaults to the first element

wheat mesa
#

a points to the first element

#

But the elements are laid out continuously in memory

#

| first | second | third | fourth | fifth
^^ a points here

radiant kraken
#

*a; // element 0
*(a + sizeof(int)); // element 1
*(a + (2 * sizeof(int)); // element 2
*(a + (3 * sizeof(int)); // element 3

wheat mesa
#

Then when you do a[1] what it's really doing is
| first | second | third | fourth | fifth
^^ next element

#

Array indexing is just pointer arithmetic behind the scenes

radiant kraken
#

or
a[0]; // element 0
a[1]; // element 1
a[2]; // element 2
a[3]; // element 3

#

same thing

wheat mesa
#

The compiler hides it from you because it's slightly counterintuitive and annoying to write

radiant kraken
#

pointer arithmetic ftw tho topggSunglasses

#

rust unsafe enjoyer

#

like seriously all of my Rust projects have a github issue saying that i used too much unsafe onesieKEKW @wheat mesa

wheat mesa
#

Ideally you should be avoiding unsafe altogether

#

I don’t get what you’d be using it for unless you’re doing something inherently unsafe like embedded dev or smth

sharp geyser
#

I mean I understand how it works

#

but your wording confused me

#

delete[] is used for when the pointer points to the first object in an array of objects that need to be deleted
this wording confuses me because to me it sounds like you are saying array is in an array in memory and its the first element

radiant kraken
radiant kraken
#

i also add SAFETY commands alongside unsafe calls tho

wheat mesa
#

It points to the first element

sharp geyser
#

okay but technically its not deleting just the first element no?

radiant kraken
#

nope

wheat mesa
#

You’re correct

radiant kraken
#

it deletes the entire array

sharp geyser
#

its deleting everything at that address which is the entire array

wheat mesa
#

It deletes all of them

#

No

sharp geyser
#

ok

wheat mesa
#

The address is not the entire array

sharp geyser
#

null said it was

radiant kraken
#

IT IS

#

if you dereference it or if you call pointer[0], you get the first element

wheat mesa
#

When you use delete[] it tells the allocator that the pointer you’re deleting points to an array, and it does the necessary work to delete it

sharp geyser
#

okay so basically it is pointing to an array just not the entire array

wheat mesa
#

Yes

sharp geyser
#

but delete[] knows to not just delete the first element but rather delete everything in the array the first element is in

wheat mesa
#

The allocator knows how much memory that the pointer owns and so when you call delete[] it releases that memory

radiant kraken
#

yes thats for the operating system to know

sharp geyser
#

I am understanding now

#

Hey I think I got it!

#
  void push_back(T element) { 
      if (length >= capacity) resize();
      array[length] = element;
      length++;
  }
wheat mesa
#

There ya go

sharp geyser
#

anything I could be missing?

wheat mesa
#

Not sure what that negative number is there though

sharp geyser
#

me neither

wheat mesa
#

Make sure your length starts with 0

sharp geyser
#

aha

#

that was the issue

#

I set it to 1

#

How would I grab a reference to a value in an array so I can delete it then return it? Cause if I just delete the value then the variable containing the value would be empty as well no?

radiant kraken
#

try this```cpp
if (index >= length) throw le_error();

T value = pointer[index];
std::memcpy(&pointer[index], &pointer[index + 1], (length - index + 1) * sizeof(T));
length--;

return value;

sharp geyser
#

Well you see I am not doing this based off an index

#

I am just removing the last element

#

but I thought it'd be nice to get what that last element was

radiant kraken
#

oh right

#

try this```cpp
if (length == 0) throw le_error();

T value = pointer[length - 1];
length--;

return value;

sharp geyser
#

wait what

#

that works?

radiant kraken
#

yuhh

sharp geyser
#

decreasing the length of the array destroys the last element?

radiant kraken
#

no

#

it doesnt decrease the size of the array in memory

#

it just marks the array as having less members

#

and it works

sharp geyser
#

Thats so weird

#

So its still technically the same size in memory

#

cool

radiant kraken
#

i guess you can decrease the array size but thats just adding another overhead

sharp geyser
#

no need

#

the array can stay the same size not like it really matters

radiant kraken
#

*the capacity stays the same

sharp geyser
#

yea

#

I know what you meant

#

dw

#

Doesn't matter if the capacity is the same or not tbh

#

I wonder why it removes the element tho thinkEGG

#

I mean I guess it kind of has to so that way it doesn't break

#

but like

radiant kraken
#

thats the point of pop_back()

sharp geyser
#

well yes null I know

#

I am wondering why decreasing the length just removes the last element.

radiant kraken
#

it doesnt

#

it only marks it

sharp geyser
radiant kraken
#

you can technically decrease the size with another new and delete[]

#

but it's adding unnecessary overhead imo

sharp geyser
#

Okay so like, I know its capacity stays the same null, but its length is no longer the same

radiant kraken
#

yes

sharp geyser
#

I think you are confusing what I am saying

radiant kraken
#

yes i am

#

im tired

#

lol i always confuse what you say and you always confuse what waffle says

sharp geyser
#

What I was saying was doing length-- removes the last element from the array but I know now its capacity still stays the same

radiant kraken
#

yes, it just decrements the length int

sharp geyser
#

I was wondering why doing such will cause c++ to remove the last element, though I have a theory its because now its length is less so it has to do something so that its in compliance to what the length should be, which is remove the last element

radiant kraken
#

nooooo

sharp geyser
radiant kraken
#

C++ doesn't do anything here

#

you just make it appear so

sharp geyser
#

okay well its still confusing

#

cause all I am doing is decrementing the length

#

so I don't see how that causes this behavior

radiant kraken
#

well your Vector methods depend on the length property

#

so it affects all of your methods

sharp geyser
#
C:\Dev\cpp-classes\Vector.h(45): error C2561: 'Vector<int>::pop_back': function must return a value
  C:\Dev\cpp-classes\Vector.h(44): note: see declaration of 'Vector<int>::pop_back'
  C:\Dev\cpp-classes\Vector.h(44): note: while compiling class template member function 'T Vector<T>::pop_back(void)'
          with
          [
              T=int
          ]
  C:\Dev\cpp-classes\main.cpp(12): note: see the first reference to 'Vector<int>::pop_back' in 'main'
  C:\Dev\cpp-classes\main.cpp(6): note: see reference to class template instantiation 'Vector<int>' being compiled
  ninja: build stopped: subcommand failed.

wtf is happening

#
  T pop_back() {
      if (length == 0) return;
      T back = array[length - 1];
      length--;
      return back;
  }

I am clearly returning something

pale vessel
#

what about the first line?

radiant kraken
#

me when throw

sharp geyser
#

me when I’m too tired to care anymore trollface

timber hatch
#

anyone who is familiar with react or nextjs, i'm building my first react/next.js project and i'm encountering a weird bug.

i am trying to markdown and format timestamps.

while on initial input it works.

if you follow these steps you get undefined for non relative timestamps:

  • enter a relative and non relative timestamp
  • wait for relative to update
  • tab out of and back into the page
  • the non relative timestamp becomed invalid.

My code: https://pastebin.com/Yf2hBe0S

anyone who could help me solve it and educate me as to what was wrong would be greatly appreciated :)

timber hatch
digital swan
#

how can i stop the middle text (a tag) going over into the text on the right?

#

overflow-ellipsis does nothing 😔 i hate css man

pale vessel
#

try gap-1 or so for the flex container

surreal sage
#

🫠

#

how do i like

#

make it cope

#

leave me alone

digital swan
#

line-clamp cuts off the word but doesnt add an ellipsis

sharp geyser
#

@wheat mesa can you explain something for me? Null was too tired last night to explain properly

wheat mesa
#

gimme 15-20 mins then I can

copper cradle
#

oh my god

#

it's not removing the element, the length is just decreasing

sharp geyser
#

Can you explain to me how this works?

  T pop_back() {
      if (length == 0) return;
      T back = array[length - 1];
      length--;
      return back;
  }

It's behaviour is that it does indeed seem to remove the last element in the array, but I am still not sure I am understanding what null said because I don't get how its happening when im just decrementing the length. Now I know its capacity stays the same but its length is no longer the same in memeory right?

wheat mesa
#

The memory layout doesn’t change

#

You’re just essentially marking the data as free space you can overwrite

copper cradle
#

yes

wheat mesa
#

That T is still in memory unless you write over it or you deallocate the array

sharp geyser
#

Okay so I am basically freeing that spot in memory which releases it?

copper cradle
#

no?

wheat mesa
#

no

#

The memory is still there

#

You're just managing the state differently

copper cradle
#

wait, imma just bring up my paint

wheat mesa
#

You're just saying "Okay so I still have this capacity, I'm just going to say there's only 4 elements instead of 5 elements in there now"

#

You're not deallocating anything

#

You're just essentially "marking" the space as unused so that when you call push_back again, something will overwrite at that spot

sharp geyser
#

hm

#

I think I get it now

copper cradle
#

@sharp geyser see, the element is still there, the len is just 3 now

wheat mesa
#

If you actually deallocated that T then the person getting the value from pop_back would get an invalid pointer

#

although actually you're copying here so that wouldn't happen

sharp geyser
#

So essentially there is still technically 5 items, its just one is an empty spot that still exists in memory, it just can be overwritten?

copper cradle
#

if you add something to the end of the vector array list whatever you call them these days, it'll just replace whatever was at the black circle

wheat mesa
#

it contains the value of T

#

until you overwrite it

copper cradle
#

let's say that accesing it now will be undefined behaviour

wheat mesa
#

It's like how when you delete something on a physical hard drive, it often isn't ACTUALLY deleted, just the space it took up is marked as "free" and can be overwritten

sharp geyser
#

hm

#

Okay so, I get that its marked as free, but there is no physical value there right?

copper cradle
#

there is something there

wheat mesa
#

the value is there

sharp geyser
#

Like say I set 3 to be at the back, then I pop it off, im not going to see 3 anymore

copper cradle
#

3 is still going to be there

wheat mesa
#

That's true but the 3 might still be in the memory

#

It actually will be in the memory if you haven't done anything else to it with your current implementation

copper cradle
#

it's going to stay there because that memory is allocated to the vector, and if you don't do anything to it then it's going to stay there

wheat mesa
#

When you print it, it only goes up to length elements though

solemn latch
#

👀 what lang are we talking about?

wheat mesa
#

That's why you don't see it

#

C++

sharp geyser
#

Ahhhh

#

Gotcha

#

So it still exists, but since my methods rely on the length it wont print it

copper cradle
#

don't access out of bounds data ^^

wheat mesa
#

Change your method to print to capacity and see what happens

sharp geyser
#

If I was to try and print beyond the length id still see it I assume

wheat mesa
#

You'll probably get whatever you last popped and then a bunch of garbage data past that

copper cradle
#

yeah, and then you'll get either a lot of garbage or an immediate segfault

sharp geyser
#

I need to rebuy clion

#

this visual studio shit is pissing me off

copper cradle
#

just use vim

sharp geyser
#

NOPE

copper cradle
#

if you're writing c++

sharp geyser
#

not using vim, I tried that and I hated it

wheat mesa
#

nvim is pretty nice it's just a big learning curve and I'm too lazy

copper cradle
#

fair enough

#

then you'll never get this

sharp geyser
#

Neovim requires a license?

wheat mesa
#

no lol

copper cradle
#

no

sharp geyser
green kestrel
#

I don't want to use neovim

sharp geyser
#

ye so it looks so annoying

#

ima just buy clion :D

green kestrel
#

it's too much work to type commands into my text editor, I just want single keypressses that do stuff.

#

I used vim for years

#

but using it for larger projects is just painful. and yeah people who say "but there are plugins for this and that"...

wheat mesa
#

Just show school ID

green kestrel
#

I don't want to spend weeks tracking down plugins and tinkering with my editor

sharp geyser
#

I dont have one

#

Waffle you do know Im not in school

green kestrel
#

my editor is a tool I want to work out of the box,.not a toy

sharp geyser
wheat mesa
#

If you still have your high school one you can just photoshop the year

sharp geyser
#

lmao

#

I don't think I do

wheat mesa
#

They won’t question a thing

sharp geyser
#

I got rid of a lot of my hs stuff

wheat mesa
#

Or if you have your transcript

#

Photoshop the year

green kestrel
#

clion is ass. just saying. phpstorm though now that's nice

#

clion has weird ideas about vcpkg workflow

sharp geyser
#

Clion is good to me shrug

wheat mesa
#

CLion is awesome

wheat mesa
#

Duh

green kestrel
#

agreed tbh

#

vscode remote dev to a Linux box.

sharp geyser
#

I might dual boot linux sometime

wheat mesa
#

CMake is so much easier to work with on Linux

sharp geyser
#

I wonder if I can just put linux on a spare ssd that I have and be able to boot from that

copper cradle
#

CMake is ass

green kestrel
#

iirc clion still tries to use vcpkg on Linux,.yeah it works there.... sorta. but why use it when libs are in apt or whatever?

copper cradle
#

why couldn't you?

sharp geyser
#

cause idk anything about boot loaders

#

I didn't know if it all had to be on the same drive

copper cradle
#

that has nothing to do with boot loaders tho

sharp geyser
#

listen weeb you severely underestimate how stupid I am when it comes to operating systems.

green kestrel
sharp geyser
#

I know how to build a pc, I know how to use one

#

but idk a damn thing about the os itself or how it works

green kestrel
#

are you one of these pure make masochists?

wheat mesa
#

If C++ had a centralized dependency manager then everything would be a billion times easier

green kestrel
#

enjoy lol, make is portable as an anvil

wheat mesa
#

You can’t just make one

sharp geyser
wheat mesa
#

The language has been out for like 40 years

green kestrel
#

mainly because of the ton of non standard gnu make extensions

wheat mesa
#

vcpkg was Microsoft’s attempt at solving it, even that sucks compared to something like cargo

green kestrel
copper cradle
#

yeah that's a no no

green kestrel
#

at least c++ doesn't have npm.

wheat mesa
#

The internet wasn’t a huge thing like it is now when C++ was first released, I don’t think many people thought about the notion of a “package manager”

green kestrel
#

npm is like a lighter on a fireman's uniform.

sharp geyser
#

pnpm is amazing /s

green kestrel
#

can't argue havent tried it

wheat mesa
#

The npm ecosystem is disgusting

#

Bloated as fuck

sharp geyser
#

its not

wheat mesa
#

js developers use 3 million deps for every tiny project

sharp geyser
#

pnpm sucks as well

green kestrel
#

npm ecosystem in one word: is_even.

sharp geyser
#

is_true

green kestrel
#

is_number

wheat mesa
#

The dependencies take up more space than the projects themselves take 99.99999% of the time

sharp geyser
#

is_odd

wheat mesa
#

is-odd is a funny one because it depends on is-even

green kestrel
#

is_odd. depends on is_number and is_even KEKW

copper cradle
#

ok pnpm just manages a global node_modules instead of having one per project, that actually sounds nice, although it just symlinks packages to the local node_modules

sharp geyser
#

waffle wish me luck ima try and dual boot

#

:D

copper cradle
#

honestly js itself was a mistake, and node made it worse

#

glhf misty

sharp geyser
#

Any articles or videos you guys recommend?

wheat mesa
#

js was literally created in a week, that's pretty impressive

sharp geyser
#

I dont wanna fuck my shit up

wheat mesa
green kestrel
#

I'm still surprised sun never sued them for trademark infringement when they renamed it to JavaScript from livescript

sharp geyser
#

why not

wheat mesa
#

just use vs for right now

#

you're going to lose motivation by worrying more about your environment than your actual projects

green kestrel
#

JavaScript ruined any reputation java had left

#

by false association

wheat mesa
#

they're not even related!

green kestrel
#

I know! lol

sharp geyser
#

ima just use vs code

wheat mesa
#

dear god no

#

not on windows

#

just use visual studio

copper cradle
#

I told you

wheat mesa
#

don't overcomplicate it

green kestrel
#

the people that named it knew too they were just riding on it's coat tails

wheat mesa
#

misty you're not even to the point that you need dependencies yet

#

you shouldn't be worrying about your IDE like that

green kestrel
#

what are you making in c++?

ionic schooner
sharp geyser
#

but I hate visual studio!!!!!

wheat mesa
#

he's making some data structures for practice

sharp geyser
#

I can't even uncomment shit thats commented

#

I have to manually go through and remove the //

wheat mesa
#

maybe I'm a zoomer but I just like VS and CLion because you don't have to set a billion things up, it's plug and play

green kestrel
#

it is powerful if you spend tons of time playing with it's configs

copper cradle
sharp geyser
#

that should be a thing by default

green kestrel
#

there are those who produce stuff and those that just play with settings all day

wheat mesa
sharp geyser
#

Also I have no fucking clue on how to access the settings menu

wheat mesa
#

I probably have one or two "flagship" projects that I've actually finished

green kestrel
#

when I go in vim I have about 10 or so things I do, including regex search and replace, delete to line, jump to line... not much else tbh

copper cradle
#

then there's those that produce stuff and on their free time tinker with the tools they love

wheat mesa
#

One being a java game engine, the other being a basic treewalk interpreter in rust

frigid leaf
#

exports.run = async (client, message, args) => {
if(!message.member.hasPermission('message.guild.ownerID')) {
return message.channel.send('❌ You need to own the server to load the backup in this server.');
} anyone know how I can make this code make it so only the author that created the backup can use the command?

green kestrel
#

ah yes rust what level are you

wheat mesa
#

Right now I'm working on a proper opengl engine with C++ though, it's revived my love for low level

copper cradle
#

I ain't reading that without one

sharp geyser
frigid leaf
#

mkay

exports.run = async (client, message, args) => {
    if(!message.member.hasPermission('message.guild.ownerID')) {
        return message.channel.send(':x: You need to own the server to load the backup in this server.');
    }```
green kestrel
wheat mesa
#

I wasted so much time playing video games when I was like 12-15/16

#

could've been a programming god

sharp geyser
#

I wasted so much time on gaming I never focused much on programming

green kestrel
#

I purposely bring out that emoji when people talk rust tbh, because it winds people up more than norust

copper cradle
#

when creating the backup, store the id of the person that created it in a database, and then when restoring the backup check if the id of the person running the command matches that of the person that created the backup, idk if that's what you're looking for, honestly that's what I got from your question lol @frigid leaf

wheat mesa
#

tbf though it was probably worth the memories made in the process

sharp geyser
#

I found out how to comment and uncomment things

#

why its CTRL + K + C I have no idea

frigid leaf
green kestrel
wheat mesa
#

last 3 are valid

#

first one is not :c

green kestrel
#

I don't have a nocpp, anyone got one?

copper cradle
frigid leaf
green kestrel
green kestrel
copper cradle
wheat mesa
#

I'm gonna have to learn coroutines for a game engine aren't I

#

either way I'm sure it'll be an interesting process

green kestrel
#

not likely

wheat mesa
#

next up on the list is figuring out texturing batching with layers

green kestrel
#

most game engines are stuck in 2001 with shitty entity component systems that are too much OOP

wheat mesa
#

oh

green kestrel
#

coroutines are c++20

wheat mesa
#

I was going to make an ECS

green kestrel
#

dpp has them

#

but we are forward thinking

wheat mesa
#

entity component systems are super powerful as long as you actually think about the data and not the structure of classes

green kestrel
#

ECS is standard way to do game engines but don't be tempted to OOP everything, that's like using only the hammer in your toolbox, c++ has many tools

wheat mesa
#

Rust definitely helps with orienting your brain to think about it data-wise

green kestrel
#

yeah think data

wheat mesa
#

composition over inheritance

green kestrel
#

ECS is supposed to be data driven not OOP

#

indeed

wheat mesa
#

vtables are performance killers

green kestrel
#

no

#

not in themselves

wheat mesa
#

vtable lookups are performance killers*

#

lots of inheritance -> lots of vtable lookups

green kestrel
#

with a good block allocator it's ok, and you won't notice the difference in performance unless you're calculating rocket trajectories for spacex

#

a good block allocator will keep related stuff nearer to each other so good for cache

wheat mesa
#

Yeah cache locality helps a lot

#

Inheritance being very bad for it because everything lives everywhere

green kestrel
#

also, use vectors where you can and std::array

wheat mesa
#

I planned to use pretty much all std::array

green kestrel
#

not unordered map or map, and never std::list

wheat mesa
#

alongside std::bitset

green kestrel
#

if speed is what you want

wheat mesa
#

yeah

green kestrel
#

it's easy to turn array or vector into a simple hash table

wheat mesa
#

linkedlist bad for caching and random access, map and unordered map incurring a cost for random access as well

sharp geyser
#

So for my clear method I simply set the internal array to a new array of type T, and set the length back to 0, is this fine?

green kestrel
#

unordered map is O(1) for access, access is fast but it murders cache

#

also unordered map doesn't free when items are removed,.it just grows forever

wheat mesa
green kestrel
#

MORE BUCKETS!

#

it's not a noticeable cost

wheat mesa
green kestrel
#

insertion costs 1000x more as it has allocations

wheat mesa
#

But that's not on you to figure out

#

That's for the caller to manage

sharp geyser
#

Oh okay

#

I was about to say panicc

green kestrel
#

dpp uses tons of unordered maps

#

but dpp priority is memory use not speed

wheat mesa
#

Your vector is just responsible for managing the chunk of memory that the T* array points to

green kestrel
#

and we "rehash" them periodically, like a GC step, we allocate a completely new unordered map and copy the contained items to the new one then delete the old one

#

this keeps it's rampant memory usage in check

wheat mesa
#

that's actually quite a neat trick

green kestrel
#

at the expense of some CPU cycles and a lock

wheat mesa
#

is dpp multithreaded?

green kestrel
#

yes

wheat mesa
#

dayum

green kestrel
#

and thread safe

wheat mesa
#

I barely touch threading with a 10 foot pole in Java, much less C++

green kestrel
#

it's hairy

#

but c++17 adds shared mutex

#

shared mutex is awesome

wheat mesa
#

Java makes it relatively easy for doing things like not locking a UI thread by usage of thread pools, but making data structures thread safe and such is a different story

#

It's bittersweet that my time with Java has come to a temporary end

green kestrel
#

you can lock a shared mutex as a reader or writer.

a reader can claim the lock so long as there are no writers

a writer can only claim the lock if there are no other readers or writers

wheat mesa
#

Yeah mutexes are nice

#

Java has had them for a while

sharp geyser
#

Wth is begin() and end()

green kestrel
#

makes things like monitoring a queue really nice

green kestrel
#

or methods?

wheat mesa
#

begin() is a pointer to right before the first element of a container, end() is a pointer to after the last element of a container

sharp geyser
#

like vector has vector::begin

wheat mesa
#

they're iterators

green kestrel
#

begin is pointer TO first element

wheat mesa
#

oh is it?

#

thought it was right before

green kestrel
#

end is pointer to AFTER the last (not valid)

wheat mesa
#

thought you had to increment before dereferencing

sharp geyser
#

Is it worth trying to implement begin and end in my vector class

wheat mesa
#

Since I see the for (auto it = s.begin(); it != s.end(); ++it) pattern a lot

wheat mesa
#

iterators can be a little tricky to think about

green kestrel
#

btw if you want to iterate a container don't use iterators

old way:

for (auto iter= container.begin(); iter != container.end(); ++container)

new way:

for (const auto & item : container)

❤️

#

new way is far nicer

#

and never EVER remove an item from a container you're iterating without taking special steps to avoid UB

#

idk if that's an issue in rust too

wheat mesa
#

I think it's usually just a bad idea to be modifying a container you're iterating over in the first place

#

Regardless of language

#

Unless you really know what you're doing

green kestrel
#

you can modify the things your container has in it

#

but adding or removing from it while iterating is recipe for pain

wheat mesa
#

Yeah but modifying the size of the container in any way is a bad idea

#

Yeah

green kestrel
#

adding is usually "non fatal" bug, it will iterate at least one item twice

#

removing is source of horrible heap or stack corruptions

wheat mesa
#

Java treats this as a complete catastrophe and throws if you attempt to do this whilst iterating within a foreach

#

ConcurrentModificationException

green kestrel
#

neither are wise but the first can go unnoticed in code for years

#

lol, that's not a bad idea

wheat mesa
#

iirc the reason is because the iterators are invalidated after you add or remove since the GC can shuffle memory around how it deems fit

green kestrel
#

in dpp you'll see this pattern a lot:

lock mutex
copy container
unlock mutex
long looped thing on copy of container
delete copy

wheat mesa
#

You can still do it in a traditional for loop but not while using iterators

green kestrel
#

copying the container being tons faster than iteration to do "x"

#

and when you lock some mutex you want it locked as least time as possible

wheat mesa
#

I'd imagine copying is pretty cheap in contiguous memory since memcpy is super cheap

green kestrel
#

yup

#

so things like processing lists of http requests

#

processing a queue can take literal minutes

#

if it's big or you're near rate lokitn

#

but copying the queue vector takes microseconds

wheat mesa
#

man I love low level

#

so much to think about and the more you know the faster your code gets

green kestrel
#

you should contribute to dpp lol I did everything from scratch

wheat mesa
#

modern C++ scares me

green kestrel
#

custom websocket client and http client

#

the socket stuff dives deep into C

#

lots of pointers and raw buffers

#

could have used libuv but where's the fun in that and I hate dependencies

wheat mesa
#

I'm trying to modernize my C++ knowledge by writing my engine with "Modern" c++

#

aka using more than "throw this pointer around, who cares"

#

maybe a unique_ptr or shared_ptr in there somewhere and a little bit of optional when I start writing the ECS

green kestrel
#

one hint id give is if you feel you're typing too much boiler plate you're probably doing it a bad way

#

and if you find yourself typing long type names over and over remember auto and "using"

wheat mesa
#

most of the boilerplate I'm writing is just trying to modularize opengl stuff

green kestrel
#

people who complain c++ is too verbose are usually trying to emulate java

wheat mesa
#

I wrote a lot of different classes (this is my first time using opengl) following videos from TheCherno's opengl series, just to realize that I can stuff all of it into a renderer class and it would be better anyways

green kestrel
#

if you want an example of how not to write c++ look at libmysqlclient++ (the official mysql c++ lib).. it's a horrific mess that tries to emulate jdbc

frigid leaf
#

anyone know any API that is useful for my discord bot, I want it to fetch automatic lyrics while the song plays

#

but like I want to stay on the cheap side or even like free side X)

wheat mesa
#

For example here's part of my renderer constructor lmao ```cpp
m_QuadBuffer = new Vertex[s_MaxVertexCount];
m_QuadBufferPointer = m_QuadBuffer;

// VertexBuffer
glGenBuffers(1, &m_VertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
glBufferData(GL_ARRAY_BUFFER, s_MaxVertexCount * sizeof(Vertex), nullptr, GL_DYNAMIC_DRAW);

// VertexArray
glGenVertexArrays(1, &m_VertexArray);
glBindVertexArray(m_VertexArray);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glEnableVertexAttribArray(3);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 10 * sizeof(float), (const void *) 0);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 10 * sizeof(float), (const void *) (3 * sizeof(float)));
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 10 * sizeof(float), (const void *) (7 * sizeof(float)));
glVertexAttribPointer(3, 1, GL_FLOAT, GL_FALSE, 10 * sizeof(float), (const void *) (9 * sizeof(float)));
#

I could replace the VertexArray stuff with a nice little layout manager, but then I remembered that it's pointless because this engine is specifically for me

green kestrel
#

what are the vertexes for

wheat mesa
#

And I do not plan on needing more than a position, color, uv, and layer

green kestrel
#

shouldn't that be from a model file or something?

wheat mesa
#

I'm making a 2d engine

#

No need

green kestrel
#

ah is it your display plane?

wheat mesa
#

Everything will be rendered as a rectangle

#

And this is just for telling the GPU how the data looks in vram

green kestrel
#

id be tempted to display just one quad with a texture on it and update the texture lol

wheat mesa
#

position 0 is 3 floats that represent position, 1 is 4 floats that represent color, etc

green kestrel
#

but last time I did 2d, I did software rendering

wheat mesa
#

I wrote a textureatlas class that manages stuffing multiple textures into one and just sampling from different parts of it

#

(thanks to stb_rect_pack for doing the hard work)

#

The next thing on my todo list is to make it so I can access multiple texture units instead of just one

#

that way I can reduce draw calls even more

#

those images are programmatically packed into the black rectangle

eternal osprey
#

hey guys, i finally made some time to put my api online. So as stated before i have an api running on my vps and my own site on my other hosting platform. I currently do fetch requests to the api and eventually also redirect customers back to the site etc. How would i possibly connect my api to my site?

#

Like setting a subdomain

#

such that i can fetch my api using domain/subdomain.com

#

my site is also running on https

#

so i recently tried using fetch to my express api which would not work as https -> http was not allowed by cors

green kestrel
wheat mesa
#

yea

green kestrel
#

point subdomain at it via dns

#

and use certbot and letsencrypt to get free ssl

#

after that you could use cloudflare to obscure the real IP

eternal osprey
#

i see obvs https has a 443 port.

eternal osprey
green kestrel
#

yes

eternal osprey
#

in the dns records of my site

#

i see

green kestrel
#

just untick the orange cloud thingy

#

in cloudflare

eternal osprey
#

idk it's handled by my hosting

#

i can't even access cloudfare i think

#

i can only add dns records manually but that's about it

copper cradle
#

what did I miss here

sharp geyser
#

@wheat mesa pinging you cause I know you know how to help but if anyone reads this and can help please do so

so for my insert method I can think of a problem i'd have to face.

What if they are trying to put something at an index that already has a value. My initial thought was to just shift everything after that index down one and then add in the element at that index but idk how i'd do that unless this could work

void insert(int index, T element){
  if(index >= length) return;
  if(array[index]){
    // If there is already something there
    for(int i = 0; i < index - 1; i++){
      // will likely need to change what i or my comparison is but I can't think right now lol
      array[i] = array[i + 1] // this seems wrong as well but again my brain no think properly
    }
    array[index] = element
  }
  length++;
}

There might be some other problems but im not too sure rn of any others i'd face.

wheat mesa
#

Or maybe I misinterpreted and that’s exactly what you meant

sharp geyser
#

well

#

I want to shift everything after the index down one

#

so that way the element can take over that index

#

this is in case they are wanting to insert something at an index that is already taken

sharp geyser
#

but all my testing gives me some odd behavior where negative numbers take over the spots

#

or it just fills most of the indexes with the last element

#

Here was my next thought but it doesn't produce an appropriate result:

  void insert(int index, T element) {
      if (index >= capacity) resize();

      if (index >= length) {
          length = index + 1;
      } else {
      length++;
      }

      for (int i = length - 1; i > index; --i) {
      array[i] = array[i - 1];
      }


      for (int i = 0; i < length; i++) {
      std::cout << "Here is the elements after inserting: "
                << "\n" << array[i] << std::endl;
      }

  }
#

I thought using the length of the array for i and then seeing if i is greater than the index would work. I was thinking of starting backwards and shifting the elements down until it reaches the index like that

drowsy jewel
quartz kindle
#

that would delete the existing contents of i+1

drowsy jewel
#

Woops

#

My bad

#

Wait no

drowsy jewel
#

Well basically you would be shifting elements to the right, I'm sleepy so I think my brain isn't functioning correctly. Once you shift the elements, place the element you want in the index then increment length

crystal wigeon
#

are there any game devs here?

#

or someone with good knowledge with rpgs

sharp geyser
#

What question do you have, I might be able to help

crystal wigeon
#

I have a discord rpg game

#

But it’s currently failing cause it’s not good enough

#

Need some game dev knowledge to fix and balance things

sharp geyser
#

Okay, what are you currently doing?

crystal wigeon
#

Would be great if you can help me out

crystal wigeon
sharp geyser
#

Ofc

crystal wigeon
#

Some of them are useful and some are completely useless and dead

#

not viable

sharp geyser
#

a lot of rpg games have some kind of abilities that players can have.

crystal wigeon
#

You should maybe look at izzi bot XD you’ll get an idea of what’s happening

#

So the abilities are on cards that players can collect

sharp geyser
#

Okay

#

Do you feel the abilities are too overpowered?

crystal wigeon
#

not exactly but there are some abilities that players don’t use at all

#

Cause they useless or under powered

#

is what they’re saying

#

Feedback from players

sharp geyser
#

Hm, well. You can either find a way to rework the abilities so they are good, but not game breaking, or remove them and replace them with some other ones.

#

If you haven't already i'd also attach a rarity/drop chance to them if thats how your game is styled

#

You don't want people just getting these abilities for free, they have to work for em.

crystal wigeon
#

mm that’s the thing I need help with like talking to someone to rework them it would be great to talk to game dev as they would know better

#

Yeah

#

There’s rarity and stuff

sharp geyser
#

Well, its hard to tell you much without knowing your game's plot/theme.

#

I can't make any judgements

crystal wigeon
#

Yeah, which is why I suggest taking a look at izzi bot

#

That’s my bot

sharp geyser
#

Some games have abilities that make sense for them, while other abilities don't make sense for that plot/theme

crystal wigeon
#

If you want to help out that is

#

yeah

sharp geyser
#

I can take a look

crystal wigeon
#

great,

crystal wigeon
#

ping me when you join here, i

#

i'll fill you in with the details

sharp geyser
#

Question, why does your bot require the ban and kick members perm?

crystal wigeon
#

you do have to play a bit at first tho, to understand the logic

sharp geyser
#

You dont advertise any mod commands

crystal wigeon
#

it doesnt you can remove it

sharp geyser
#

I'd recommend updating your invite link then EYES

crystal wigeon
#

but it can kick / ban people

#

just not advertised as mod bots

green kestrel
#

ever wonder if the police use onetime passwords? /j kekeke

pale vessel
sharp geyser
feral aspen
#

Main question is, how does Google consider both websites same URL?

ionic schooner
feral aspen
ionic schooner
#

Oh that’s weird asf

feral aspen
#

Oops, sorry. I just saw this (a month late to replying), it was a prototype that espouses Tolerance; since that was the theme of the competition.

feral aspen
radiant kraken
#

nice

feral aspen
#

^ You had to learn swift, do assignments, pass Apple's exam, & graduate. We did all.

neon leaf
green kestrel
#

ive just finished developing a resurrect feature for seven spells... the idea is that you can respawn near to your place of death once per hour, if you dont have a resurrect you have to wait or do what you always had to do before - start from the start

#

so ive basically added an optional non-hardcore option

#

of course premium users get to resurrect more often... 😉

#

and if you die and have no resurrect, it says this, basically "did you know premium users can res more often, if you were premium you'd be back in the land of the living rn"

#

😄

neon leaf
#

help tje ai logged into my google account

green kestrel
winged linden
#

yo question

#
            ":white_check_mark:・ufo-verification",
            {
              type: "text",
              permissionOverwrites: [
                {
                  id: interaction.guild.id,
                  allow: [
                    "VIEW_CHANNEL",
                    "SEND_MESSAGES",
                    "READ_MESSAGE_HISTORY",
                  ],
                },
                {
                  id: interaction.guild.roles.everyone,
                  deny: ["SEND_MESSAGES"],
                },
                {
                  id: client.user.id,
                  allow: ["VIEW_CHANNEL", "SEND_MESSAGES"],
                },
              ],
            }
          );
          await channel.send({
            embeds: [embed],
            components: [row],
          });

          await interaction.editReply({
            content: "Setup Complete!",
            ephemeral: true,
          });```

what does this need perms other then Manage_Channels & Embed_Links?
#

its sometimes failing for some users not sure why

winged linden
sharp geyser
# winged linden yo question

Manage roles if you want them to be able to manage channel perms. Also if you set the need to have 2FA enabled in the server to do any mod actions then type person will need 2FA enabled to manage the channel

#

It’s a discord security feature

copper cradle
#

zamn

lament rock
#

could have base gifs and then tint and manipulate and combine the images depending on conditions

low orbit
lament rock
#

webp if its an option

sharp geyser
#

so wtf is a bitset, is it just something that stores booleans as 1 bit?

wheat mesa
#

Basically it treats integers as "sets" of bits

sharp geyser
#

it can only store 1's and 0's no?

wheat mesa
#

booleans are inherently inefficient because they use 1 byte of storage (sometimes more) but only NEED 1 bit to function

#

But using bitwise operations you can stuff multiple booleans into one integer

sharp geyser
#

hm

#

So how does it take something that normally takes 1 byte, and slims it down to 1 bit

#

does it just force its bit size? (if thats even possible)

wheat mesa
#

Instead of 8 booleans with 1 byte each, you can use a 1 byte number and treat each individual bit as a boolean

#

You can make this dynamic to handle more than that though, which is essentially what a bitset does

sharp geyser
#
  std::bitset<10> myBitSet;

  myBitSet[2] = 1;
wheat mesa
#

Yes

#

binary is right to left

#

(Well, for this configuration it is)

sharp geyser
#

Ooooo

#

right

#

Is there a way I can tell how much something is taking up?

wheat mesa
#

sizeof(T)

sharp geyser
#

oh right

ionic schooner
#

C moment

sharp geyser
#

wait

#

you said a bitset stores them as 1 bit right?

wheat mesa
#

not necesarily

sharp geyser
#

hm

#

then im confused on the purpose of a bitset

wheat mesa
#

If you have multiple booleans it reduces the overall size when compared to a boolean array

#

There is no benefit if you just have one boolean

sharp geyser
#

hm

wheat mesa
#
    bool a[8];
    cout << "Size of a: " << sizeof(a) << "\n";

    std::bitset<8> set;
    cout << "Size of set: " << sizeof(set) << "\n";
#
Size of a: 8  
Size of set: 4
sharp geyser
#

hm

#

is this in bytes?

wheat mesa
#

Yes

sharp geyser
#

neat

#

Btw waffle

#

what is a good lib/framework to use to make desktop apps with c++

wheat mesa
#

Qt

#

But don't do that

#

You're going to kill your motivation

sharp geyser
#

dang I was hoping it'd be simple like electron Sadge

wheat mesa
#

not at all

sharp geyser
#

welp that squashes my project idea then

radiant kraken
#

you're not building desktop apps with html/css/js

#

@sharp geyser try GTK, GLFW, SFML, or Imgui

wheat mesa
#

I'd recommend learning more c++ first

radiant kraken
wheat mesa
#

memory management and stuff

sharp geyser
#

what do you recommend I do then

wheat mesa
#

graphics programming is very hard

sharp geyser
#

I have no idea where to start to even learn memory management

radiant kraken
#

memory management is ez

#

just new and delete

sharp geyser
#

makes sense

wheat mesa
#

with that being said, you should do projects that keep you interested in learning

#

SDL is relatively easy as a graphics framework, but just don't go into it expecting quick results

radiant kraken
radiant kraken
wheat mesa
#

it just isn't enforced

sharp geyser
radiant kraken
#

just dont go for the big frameworks first

#

start with the simpler ones

sharp geyser
#

Ima work through that list slowly. It should teach me what I want to know ;p

green kestrel
#

geeksforgeeks is an awful site

#

beware their "tutorials"

#

sometimes they're even worse than chatgpt

#

basically the article writers don't have any real experience, they just parrot what they know and there is no peer review of what they write

sharp geyser
#

Man you can't use floats in enums Sadge

sharp geyser
#

no?

radiant kraken
#

how?

sharp geyser
#

because enums in C++ can't accept floats or doubles or anything not integral

radiant kraken
#

ooooh

#

i thought you meant unions

sharp geyser
#

no

radiant kraken
#

why would you want floats in enums tho?

sharp geyser
#

I was making a grade enum and assigning values to the letter grade.

#

going based off a 4.0 grading scale with a max letter grade of A

radiant kraken
#

you can make the enum Grade { A, B, C, D, E, F } but process the floats yourself

#

like a helper function

sharp geyser
#

fair

#

also what is E

radiant kraken
#

idk

#

we dont use letter based grades here

sharp geyser
#

oh ok

#

I thought E was something for you

radiant kraken
#

only percentage-based grades

sharp geyser
radiant kraken
sharp geyser
#

Well you can still turn a percent into a letter

#

if you go based off typical grading standards that accept +/- with a max letter grade of A

95-100 A
90-94 A-
87-89 B+
83-86 B
79-82 B-
77-79 C+
73-76 C
69-72 C-
67-69 D+
63-66 D
59-62 D-
0-58 F
#

idk if these are the same everywhere

radiant kraken
#

damn

#

below 75 is a D here

#

C is 75 to 80s

sharp geyser
#

but out of all the grading systems i've seen in a lot of parts of the world this seems to be the closest to universal

#

Though I think Asia is more strict EYES

radiant kraken
#

also there's no F, D is the lowest

#

below 75 is a fail

sharp geyser
#

Yup asia strict jeez

#

I mean I get it

#

America and UK are very lax imo

#

America Especially

radiant kraken
#

and yet americans complain about their education system 😩

sharp geyser
#

you could be as dumb as a box of rocks and still get your diploma

#

I complain that it is too ez

#

I passed high school with a 2.7gpa

#

I should not of passed

radiant kraken
#

someone's lurking

sharp geyser
#

but I did

#

probably flaze

#

he always does

radiant kraken
sharp geyser
#

I didn't apply myself in high school and I suffered for it

sharp geyser
#

I've seen people with a 2.0 pass

#

I think the only requirement is to too just good enough to get the credit

#

and thats it

#

once you get all your credits you are no longer their problem

radiant kraken
#

my high school average is a near 91% (not including last semester) topggSunglasses

sharp geyser
#

they send you on your way with a diploma

#

I think my grad year though almost everyone had a 2.7 or higher

radiant kraken
#

dang

sharp geyser
#

I knew a number of kids who had a perfect 4.0

#

quite honestly I probably could of been one of those kids, I just slacked off majorly in freshman and sophmore year

#

I didn't start trying until junior year but by then my gpa already tanked

radiant kraken
sharp geyser
#

Science and History

radiant kraken
#

nice

#

I liked history but know nothing about science

#

failed almost all physics, biology, and chemistry exams

sharp geyser
#

I want to learn physics but I didnt take the chance to

wheat mesa
#

Eh you’re not missing out on much

#

Physics is cool but it’s not a necessary class to have

low orbit
#

What even is gpa

#

We don't have that in uk

#

Well England atleast

grim aspen
#

grade point average

hidden gorge
#

is every minute too fast?

deft wolf
#

It depends where this data comes from. If it's from the database/cache, it probably doesn't matter much

#

But every minute is still too fast in my opinion because no one will sit and check how many servers you have every minute. Even if you set it every 30 minutes, these values ​​would not differ much from each other

radiant kraken
#

1 minute will be potential API abuse if your bot grows larger

hidden gorge
radiant kraken
#

i mean, your bot will process and send more messages, no?

solemn latch
#

Realistically discords unlikely to care, you're unlikely to hit the global ratelimit because of this. It just means your bot in your server will have 1 less message edit per minute. Which is the only one you'll potentially hit as your bot edits other messages in the server.

To me its more of a question of why 1 minute?

Its very unlikely anyone(including you) will see much change by checking that channel. It could be hours, or a day and it wouldn't degrade the experience much(most wont notice)

slate kestrel
spark flint
#

I don’t think you need live stats like that either lol

#

Highly doubt your bot will join a new server every minute, best to update every 15/30 minutes instead

slate kestrel
#

that's true, it's not necessary. Can just fetch it with a /stats command

solemn latch
#

Real analytics are way more fun anyway ^-^

radiant kraken
#

Or you can just make a website for it

radiant kraken
slate kestrel
#

Yeah i figured so

wheat mesa
#

Sure it wouldn’t be accurate 100% of the time but it saves a lot of bandwidth overall

#

You’d only really have to fetch all of the information at once from the discord API if you have significant downtime

hidden gorge
#

It pulls from the bots cache

#

I only created it bc I got bored

deft wolf
hidden gorge
earnest phoenix
#

Hello?

#

Is anyone there

warm surge
earnest phoenix
#

Im not here to talk

warm surge
#

oh

#

what’s up

earnest phoenix
#

I need help with the dbl thing

spark flint
#

Wrong dbl

warm surge
earnest phoenix
#

Thank you guys

warm surge
#

Your welcome

pale vessel
#

u stopped playing right? u haven't logged in in almost 80 days

bitter granite
pale vessel
#

LOL

bitter granite
#

||Nevermind charater development ||

pale vessel
#

i forgot why im here ngl

#

because the usual people were here talking for some reason, so i thought im in general

bitter granite
sacred python
pale vessel
#

an Argument with the type subcommand probably works too. not sure why they have both Argument and AppCommandGroup when u could set the type for both

sacred python
past field
#

question

#

i made a command that should have notified ppl with these roles

#

but it doesn’t actually notify them in the command.. is that normal?

solemn latch
# past field

Its been awhile since I've done bot development.
But I think bots are required to enable a mention when they send a message.

Lemme look into it real quick.

#

Also, how is it going mo? ^-^ getting comfortable with dev?

solemn latch
past field
past field
past field
solemn latch
#

Intresting 👀

past field
#

it was embedded at first, but i thought that was why it wasn’t notifying anyone, so i reverted it to plain text and it still isn’t notifying those roles 😭

solemn latch
#

It doesnt feel like you've done anything wrong here. Have you done other commands that mention people and it works?

past field
#

let me try

#

it looks like it will notify users by their @mention, just not roles

#

my bot has admin/all perms toggled on

solemn latch
past field
#

ok checking it out now

#

thank you @solemn latch

solemn latch
#

npnp

past field
#

hm

#

so basically

#

i would replace ${notifyUsers} with allowedMentions

#

@solemn latch correct?

#

well the entire line of course

solemn latch
#

You shouldn't need to modify any of the message variable

You just need to edit this line await interaction.reply(message);

past field
#

ah ok i see

solemn latch
#

I've not used djs in so long, tbh I'm not entirely sure how this works.

past field
#

ok i’m going to try it

#

ok so i’m seeing that notifying tagged roles in slash commands are limited on discord

#

that might be why lol

past field
#

@solemn latch are you still awake? haha

solemn latch
#

I don't sleep ^-^

past field
#

lol ok so I have a question, and if it’s going to be too much to help with i completely understand

#

so everything that I’ve been doing to create my bot and run it has been done on my macbook pro

#

so i took the same folder, uploaded it to google drive, and downloaded it on my windows PC. I know the paths are going to be different, but I remember you helped me correct the path when I first started this project

#

would you be able to walk me through it again? i can’t remember what you had me do

#

or is it a lot more complex than that? @solemn latch

solemn latch
#

It can require modifying paths sometimes when going between windows and mac(or Linux).

#

Sadly I can't help with that tonight

past field
#

ok i gotcha, no worries! i had a feeling it was more complex than what i was thinking lol

solemn latch
#

Not something you need to worry about, but in the development world we have a program called docker.
It's the best worst thing ever, but it means when you write programs it can run on any system and act like they run on a specific OS.

Really neat for making sure whatever you're developing can be developed from any machine. Useful when working with multiple developers, or you want to be able to swap between your windows and mac machine.

past field
sharp geyser
#

if this is nodejs

past field
#

yes it’s nodejs

sharp geyser
#

path.sep will give you the operating system specific file path separator

past field
#

ok i can look into it

sharp geyser
#

If you have any questions I can also help

feral vine
sharp geyser
# past field ok i can look into it

Actually I lied, use path.join, path.sep gives you the platform specific separator, but its easier to just use join as it uses path.sep anyway.

past field
#

i am extremely new to this by the way

#

like just started learning all of this 2 days ago

sharp geyser
#
const path = path.join("whatever", "something") // /whatever/something unix or \whatever\something windows
#

All good

#

everyone starts somewhere

#

One place to never be afraid to ask for help in is top.gg

#

most of the people here are experienced and if not there are plenty of other people who are new just like you.

pale vessel
#

i've always used slash and they work just fine on both windows/linux

past field
#

well

pale vessel
#

i wonder where it wouldn't work

sharp geyser
#

they typically do work on windows, but sometimes it can cause issues

past field
#

it keeps saying that my bot token can not be used

#

but more importantly

sharp geyser
#

I've had cases where i'd use require statements and it'd not find the file/folder I was looking for because I was using slashes

past field
#

i do have a question 😅

sharp geyser
#

Go ahead and ask.

past field
#

So I’m coding my bot with javascript with slashcommandbuilder in visual studio code