#⌨coders-cave
1 messages · Page 27 of 1
Dear god, that'd feel like torture if I were to do that with my current knowledge. xD
In some cases, you're by some miracle also just a natural at it.
Never seen anyone be naturally good at something. Some people just have easier time at learning some things
I mean, it's a matter of where you draw the line for how minimal the time/effort required for them to understand the thing is.
When I first started learning Java, I never really had any issues understanding anything, I was immediately able to apply anything the teacher explained in exercises without much thinking about it.
The only time I needed to "study" for a programming test was the first ever test, when I was frantically trying to memorize "public class FileName { public static void main(String[] args) {" for the test, since we were forced to use Notepad++ back then.
It took me an incredible amount of effort to get out of the tutorial hell and be able to apply what I knew of coding. I partially blame school for that, school was stupidly easy for me always and nothing before learning coding had challenged my brain before coding. Nowadays I've joined Mensa which is mostly just a circle jerk club so I am not that active in it but I found good material there that helped me realize that school was absolutely awful for me. God knows how succesfull I could be if I could've progressed in school in my own pace and not in my classmates pace
I also currently feel like I'm wasting time in school, the last time they taught some coding topic that I didn't already understand for a school unrelated reason was almost a year ago. Most of my classmates are all pretty bad at coding and struggle a lot with stuff we're currently learning about like generics, but it's all incredibly boring to me because I know it all already.
The time I did in vocational school classes was mostly wasted lmao. They were very beginner classes and my teacher noticed I mostly played video games in the class and still completed everything in 10th of the time others did so he sent me to work and I've worked since
Only reason why I'm still going is because the degree from finishing is effectively the only "opening key" required education wise by most companies in my country for getting a programming job.
Is there really no way to fast track it? In Finland you can always do your studies faster (expect primary education for some fucking reason)
I mean, that makes sense, I'd assume that that work helped you quite a lot more than staying there could've.
I mean, I do have the theoretical option to skip a grade, but that'd probably screw me over in subjects I don't care about like geography/history.
Also this was when xbox released cloud gaming to game pass which was fucking amazing in school. I just brought a controller and could play xbox games in class
Doesn't sound like the best system ngl
Tbh, I never before used any of that sort of stuff.
I only used it during vocational school
Never since
Mostly because of the amount of artifacting
Theoretically, I could also just start working instead of school right now, but companies would then legally not have to pay me nearly as much as if I had finished school.
I'm talking 2k/month I stead of 3k/month on an entry level.
Companies would probably love the value proposition in that, but I sure don't.
I have the lowest level degree possible and get paid as much as people with bachelor degrees. If a company requires an education from me over knowledge and experience I wouldn't want to work there anyway
And if I don't get paid fairly I'll just jump ship
Companies in Finland have started learning that it ain't wise to look at degrees
atleast in IT that is
Yeah, I think that a most Austrian companies aren't at that point yet.
So I'd rather just go the 2.5 more years of school while working part time.
So that I can then easily get a good job.
Plus if I don't find a new job I am just gonna go study something. I'd go to fire academy but because I had asthma as kid I can't because too big risk for the work to cause the asthma to return so I've been thinking of possibly studying to be a police, would be cool
That's fair but sounds like a pain
I could never do that sort of physical stuff, way too much effort.
I've pretty strongly thought before of getting straight to full time work instead of school, I think that the two main things holding be back from doing it are the fact that my current work place is probably (I have no proof, but would be surprised if not) transphobic, when I'd need to stay with them for a while to get full time work experience to "substitute" for the education, and the fact that the average older person in my country would effectively consider me a school dropout that got lucky.
Not trying to be rude, but who are you? 🧐
You probably don’t remember, but I’m zeivt. Old user.
"not trying to be rude" proceeds to be rude
I didn’t find it rude?
Hi
its a joke smh 
I didn’t find it funny.
Hi
major issue in the skill department
(Normal zeivt moment. :P)
can you code
No.
(their previous username is Decafa)
Right
L only coders allowed here
I just realised that a very useful Reflection feature in Java for working with generic types doesn't exist in C#, and me having assumed that the feature must exist wasted a whole lot of my time. My hopes and dreams have now forever been shattered by the fact that there's Reflection related tasks that Java can do infinitely better than C#. TwT
(I'm talking about Javas wildcard operator for generic type specification and the lack of it in C# btw.)
This is why Java is goated
C# is way better in most things. 
Like, for the love of god, Java literally makes me code out private fields with getter and setter methods.
Instead of having some proper property syntax like C#.
Wdym
I think it is in c#, mb i am wrong and misunderstood
I couldn't find a way, and StackOverflow also doesn't know one: https://stackoverflow.com/questions/116830/is-there-an-anonymous-generic-tag-in-c-like-in-java .
I'd be very glad if I'm wrong though.
what is it
And how it should works?
The wildcard just means that you have no idea what the type parameter is.
So use object
Something like a Foo<bool> can't be stored in a Foo<object>, I specifically tried.
Lets google java explanation
it seems like this way of doing things is full of problems
Don't think so, it works pretty well in Java whenever I used it.
the point of having a generic is to use the generic functions
When you use a method that returns the generic type, you get a ?.
but how would you use the generic functions if you dont know what the generic type is
too much ambiguity for a typed language
Well, yeah, it's stupid in normal usage.
But can be needed when doing Reflection.
I even don't know what to google, googling anonymous generics in java does nothing
because i never had to think about using this
(Btw, I already resolved this by creating a non generic version of the class that the generic version inherits from, so I don't really need actual help with this, I can happily discuss it anyways though.)
What ? does in java?
Try something like "java wildcard type parameter", I think that should give good results.
Yes
and then you can
A a = new A<T>();
Yeah, that's how I ended up circumventing the issue.
the non generic functions go to A and the generic functions go to A<T>
but at least here its not amigious as it is with the <?>
I'm using Reflection to iterate through every Type of an Assembly, grab ones that inherit from my generic base class, then grab their static properties, then filter out the properties that don't return some implementation of the generic type, and with the other ones, I need to access a field of them that has the generic type as its type and pass that to some other method as an object.
Oh, i understood wildcards, its generisation for generics, true, sometimes in c# i need it
well
Let me show example
In Java, I can easily use ? for making the steps past grabbing the properties easy.
use this i guess
In C#, I needed to go out of my way to implement a version of the class that doesn't use generics.
it does
For example for generic methods
yeah i dont think in java you get generic methods when you use<?>
because you cant know the type
Literally made me write this atrocity.
Luckily, it happens to work out in my particular case.
No, its can be with extend, like, define base class, and all which inherits from it will work
But in c# it doesn't
that boxes the default value
how would you know the return type
Base class
It is extends something specific
I am not talking about this
So, anything inherited from animals can be casted like whole collection
isnt that void iterateAnimals (Collection<T> animals) where T : Animal in C#
I literally needed to make this stupid non generic base class, just so that I can use Reflection to do some stuff with it. In Java, I could do the same thing while having only the generic class.
Imagine casting List<string> to List<object> and back just as usual cast
too much boxing 
do you need the defaultValue in the non generic class?
Oh, yes, true, there is more specific cases, i can't remember them
Yes, so that I'm able to get it with Reflection.
It's literally the only reason why the non generic class has to exist.
idk through all my 7 years of using C# i never ran to this problem
To what extents do you use Reflection?
a lot
sb 2 is full of reflection
i use it for spells
and of course other stuff like this
Ok, fair, but how about Reflection code that interacts with generic classes?
I used it for my bot only for commands initialization
So you have different class for every spell?
never
maybe dont use generics for this
why do you need your configoption to be generic
Still can't understand wdym
I mean, that's exactly the feature combination in which I'm running into this problem.
So that it's easier to use in non Reflection code.
If I want to access a config option value.
I just want to get its type right away.
why cant you just add it directly to the config
Instead of needing to do weird casting.
What do you want to do with generic classes using reflection?
class Config {
public A ConfigOptionA { get; set;}
public B ConfigOptionB { get; set;}
}
like this
or if you wanna do sections
I'm not using my own config made from scratch, I'm building a wrapper on top of the Config system build into the BepInEx modlaoder so that I don't need to worry about stuff like locally saving the data.
hmmm
With its Config system, you get your values as an object, and need to cast everything.
i guess that's the only way
And I'm working on a system that takes care of those aspects for me.
that's why i never build on top of stuff 
I didn't know that it'd go so horribly wrong in C#. 
You'd be looking at quite the code attrocity.
You want to see anyways?
IEnumerable<ConfigOption> configOptions = typeof(ConfigOption<>).Assembly.GetTypes().Where(t => t.BaseType == typeof(ConfigOption<>)).SelectMany(t => t.GetProperties()).Select(p => p.GetMethod).Where(m => m.ReturnType == typeof(ConfigOption<>)).ToList().Select(m => m.Invoke(null, null)).Where(o => o.GetType().IsAssignableFrom(typeof(ConfigOption<>))).Cast<ConfigOption>();
// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
configOptions.Where(configOption => _configFile[configOption.Section, configOption.Field] == null).Select(configOption => _configFile.Bind(configOption.Section, configOption.Field, configOption.DefaultValue, configOption.Description));
Yeah.
Takes two strings to specific Section/Field.
And an object that's the default value.
Well, and also a description string, but that's kinda besides the point rn. :P
internal static T Get<T>(string section, string field) {
if (typeof(T) == typeof(string)) return (T) Convert.ChangeType(_configFile[section, field].GetSerializedValue(), typeof(T));
return JsonConvert.DeserializeObject<T>(_configFile[section, field].GetSerializedValue().Replace("\\", ""));
}
internal static void Set(string section, string field, object value) {
_configFile[section, field].SetSerializedValue(JsonConvert.SerializeObject(value));
_configFile.Save();
}
internal static T Get<T>(ConfigOption<T> configOption) {
return Get<T>(configOption.Section, configOption.Field);
}
internal static void Set<T>(ConfigOption<T> configOption, T value) {
Set(configOption.Section, configOption.Field, value);
}
I can then conveniently interact with the config like this.
Without needing to worry about any sort of type casting or anything like that.
namespace KeyGUI.Menus.ModConfig.ConfigOptions {
public abstract class ConfigOption<T> : ConfigOption {
public new T DefaultValue => (T)base.DefaultValue;
internal ConfigOption(string field, T defaultValue, string description) : base(field, defaultValue, description) { }
}
public abstract class ConfigOption {
public string Section { get; }
public string Field { get; }
public object DefaultValue { get; }
public string Description { get; }
protected ConfigOption(string field, object defaultValue, string description) {
Section = GetType().Name;
Field = field;
DefaultValue = defaultValue;
Description = description;
}
}
}
These are the base classes.
namespace KeyGUI.Menus.ModConfig.ConfigOptions {
public class General<T> : ConfigOption<T> {
public General(string field, T defaultValue, string description) : base(field, defaultValue, description) { }
public ConfigOption<bool> IgnoreCriticalMods => new General<bool>("IgnoreCriticalMods", false, "If true, KeyGUI won't do anything about mods that the server flags as critical.");
public ConfigOption<bool> OnlyAllowOneOpenSubmenu => new General<bool>("OnlyAllowOneOpenSubmenu", false, "If true, KeyGUI will only allow one submenu to be open at a time.");
public ConfigOption<bool> ForceOpenAllMenus => new General<bool>("ForceOpenAllMenus", false, "If true, KeyGUI will force all menus to be open.");
public ConfigOption<bool> InitializeAssetFoldersEveryStartup => new General<bool>("InitializeAssetFoldersEveryStartup", true, "If true, KeyGUI will create the most recent needed asset storage structure every startup. This is useful if you want to make sure that mod updates keep the folder up to date.");
}
}
And from there, I ext4end them like this to create specific sections and their fields.
namespace KeyGUI.Menus.ModConfig.ConfigOptions {
public class Traits<T> : ConfigOption<T> {
public Traits(string field, T defaultValue, string description) : base(field, defaultValue, description) { }
public ConfigOption<bool> ShowTraitsTutorial => new Traits<bool>("ShowTraitsTutorial", true, "If true, KeyGUI will show basic instructions on how to use the custom trait maker.");
public ConfigOption<bool> AutoloadTraits => new Traits<bool>("AutoloadTraits", true, "If true, KeyGUI will automatically load custom traits stored in worldbox_Data/KeyLibraryModsData/KeyGUI/Traits.");
}
}
using System;
using Newtonsoft.Json;
namespace KeyGUI.Menus.ModConfig.ConfigOptions {
public class Internal<T> : ConfigOption<T> {
public Internal(string field, T defaultValue, string description) : base(field, defaultValue, description) { }
public ConfigOption<string> Id => new Internal<string>("Id", "UNABLE_TO_DETERMINE", "A made up ID for some simple data collection during server communication. Change this value to -1 to prevent any data collection from happening, refrain from touching it otherwise. To get data deleted that has already been stored of you, contact keygui-data-management@keymasterer.uk with your ID.");
public ConfigOption<string> WhitelistedMods => new Internal<string>("WhitelistedMods", JsonConvert.SerializeObject(Array.Empty<string>()), "Mods that are whitelisted by the user and won't be flagged as problematic.");
}
}
namespace KeyGUI.Menus.ModConfig.ConfigOptions {
public class Items<T> : ConfigOption<T> {
public Items(string field, T defaultValue, string description) : base(field, defaultValue, description) { }
public ConfigOption<bool> AutoloadItems => new Items<bool>("AutoloadItems", true, "If true, KeyGUI will automatically load custom items stored in worldbox_Data/KeyLibraryModsData/KeyGUI/Items.");
}
}
namespace KeyGUI.Menus.ModConfig.ConfigOptions {
public class GameSettings<T> : ConfigOption<T> {
public GameSettings(string field, T defaultValue, string description) : base(field, defaultValue, description) { }
public ConfigOption<bool> DisableAutosaves => new GameSettings<bool>("DisableAutosaves", false, "If true, KeyGUI will disable the games autosave system.");
public ConfigOption<bool> DisableBoatsBreakingIce => new GameSettings<bool>("DisableBoatsBreakingIce", false, "If true, KeyGUI will disable the ability of boats to break ice.");
}
}
With the system as it currently is, I only need to create a new property in one of these sections, or a new section, and I can just use them with the wrapper, without needing to write any extra code for stuff like binding them to the underlying config.
I thought my generics are weird
I just declare the property; pass it to the Get/Set methods.
And all of the initial config file binding is handled by Reflection.
That's quite some interesting nesting. IwI
@prisma grail ditch the non generic
and use more reflection

its gonna be the same performance as you are still boxing
but it looks nicer
var defaultValues = typeof(ConfigOption<>).Assembly.GetTypes()
.Where(t => t.BaseType == typeof(ConfigOption<>)).SelectMany(t => t.GetProperties()).Select(p => p.GetMethod)
.Where(m => m.ReturnType == typeof(ConfigOption<>)).ToList().Select(m => m.Invoke(null, null))
.Where(o => o.GetType().IsAssignableFrom(typeof(ConfigOption<>))).Select(x => x.GetType().GetProperty("DefaultValue").GetValue(x));
defaultValues is an IEnumerable<object?>
you might need to remove the nulls if you dont want them with another Where
I mean, I'll need to also grab every other property with Reflection.
oh you need them all
Major pain right there. 
yeah i guess the way youre doing it is the only waay
this is the pain of building on top of things
a lot of reflection
a lot of object
doesnt look as clean as normal code
Yeah, fair, but if I were to make my own config system from scratch, I can already feel myself somehow messing up the IO aspects.
JSON it?
File.WriteAllLines(); and File.ReadAllLines();
oh i guess you dont need File.ReadAllLines();
I mean the actual file operations and stuff for storing in a local file. 
or write all lines
Oh, wait.
literally just File.WriteAllText();
and give it a path
use / at the start to make it local
Well, I already have this logic now, and this rewrite would also mean that I'd need to write code for migrating already stored data from the old system to the new one.
var json = "AAA";
File.WriteAllText("/config.cfg", json);
var readJson = File.ReadAllText("/config.cfg");
var results = JsonSerializer.Deserialize<object>(readJson);
make sure you wrap it all in a try catch and display an error if it throws
file read/write throws a lot
especially on windows
at least a lot more than expected
_Reasons why MacOS is superior:
_
also wrap the json serialize and deserialize
i dont like C# cuz it doesnt tell you all of this can through
there should be a strict option where it doesnt allow you to code like this
can i put it in taco instead of wrapping it
i wanna enable that on sb 2 and watch it get destroyed
you can do whatever you want cody
C# stands for Cody Sharp after all
tacode time
Nah, make it all unsafe instead. :P
And then write unsafe code too.
which even the Unsafe class doesnt have
That's what my second message was for.
i like how the Unsafe class is full of memory safe methods 
Awesome logic right there. IwI
its just unsafe because the result you get might not be what you expect
Ah, fair.
Marshal and Unsafe are the classes of the C# gods
i dont dare touch them
also Span
requires too much brain
can give you extra fast for loops though
I've had to touch Memory for sb 2 though
and ever since i feel like ive added a memory leak somewhere
these classes are too dangerous 
Good that I'm not doing any string manipulation stuff in my mod as far as I can recall. :P
What in the world is Marshal?
Understandable.
i mean these kind of optimizations are not really necessary
good question
i bet it has a good answer too 
To quote my IDEs docs:
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks, and converting managed to unmanaged types, as well as other miscellaneous methods used when interacting with unmanaged code.
sounds like Marshal to me
Reading that, I'd say that not touching it is quite the good idea.
@barren shale C# is making my life with this more and more painful by the second.
Rn, I'm getting exceptions thrown at me by Reflection because I'm trying to invoke a getter where the return value has a generic type.
Like, whoever made Reflection in C# seems to have a hatred towards generics.
Wdym? The property is static.
and what exception are you getting
Well, it's not in the code I sent above.
wtf is a static property
On accident.
you mean field
public static ConfigOption<bool> IgnoreCriticalMods => new General<bool>("IgnoreCriticalMods", false, "If true, KeyGUI won't do anything about mods that the server flags as critical.");
I meant that it's got a static modifier?
Something like this.
what is the reflection code
System.InvalidOperationException: Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.
IEnumerable<ConfigOption> configOptions = typeof(ConfigOption<>).Assembly.GetTypes().Where(t => typeof(ConfigOption).IsAssignableFrom(t)).SelectMany(t => t.GetProperties()).Select(p => p.GetMethod).Where(m => typeof(ConfigOption).IsAssignableFrom(m.ReturnType)).Select(m => m.Invoke(null, null)).Where(o => o is ConfigOption).Cast<ConfigOption>();
The Select() with the m.Invoke() is where the exception is thrown.
Just tried changing it from a property to a field.
C# literally gave me a warning for that right away.
nah this is a property
The above thing is a property, yes.
I also called it that.
.
No. xD
so what is the m.Invoke invoking
The getter method of the property.
All properties where this is happening are something like this.
That's safe to assume; I already debugged through the code to assure that it's grabbing the correct properties.
And trying to use a field instead of a property gets me a System.InvalidOperationException: Late bound operations cannot be performed on fields with types for which Type.ContainsGenericParameters is true..
Imagine it like the enums in Java.
That's basically what I'm doing.
can you show me the whole code for this
like whole file
or a bigger part of the file
namespace KeyGUI.Menus.ModConfig.ConfigOptions {
public abstract class ConfigOption<T> : ConfigOption {
public new T DefaultValue => (T)base.DefaultValue;
internal ConfigOption(string field, T defaultValue, string description) : base(field, defaultValue, description) { }
}
public abstract class ConfigOption {
public string Section { get; }
public string Field { get; }
public object DefaultValue { get; }
public string Description { get; }
protected ConfigOption(string field, object defaultValue, string description) {
Section = GetType().Name;
Field = field;
DefaultValue = defaultValue;
Description = description;
}
}
}
namespace KeyGUI.Menus.ModConfig.ConfigOptions {
public class General<T> : ConfigOption<T> {
public General(string field, T defaultValue, string description) : base(field, defaultValue, description) { }
public static readonly ConfigOption<bool> IgnoreCriticalMods = new General<bool>("IgnoreCriticalMods", false, "If true, KeyGUI won't do anything about mods that the server flags as critical.");
public static ConfigOption<bool> OnlyAllowOneOpenSubmenu => new General<bool>("OnlyAllowOneOpenSubmenu", false, "If true, KeyGUI will only allow one submenu to be open at a time.");
public static ConfigOption<bool> ForceOpenAllMenus => new General<bool>("ForceOpenAllMenus", false, "If true, KeyGUI will force all menus to be open.");
public static ConfigOption<bool> InitializeAssetFoldersEveryStartup => new General<bool>("InitializeAssetFoldersEveryStartup", true, "If true, KeyGUI will create the most recent needed asset storage structure every startup. This is useful if you want to make sure that mod updates keep the folder up to date.");
}
}
public static void SetUpConfig() {
IEnumerable<ConfigOption> configOptionsTest = typeof(ConfigOption<>).Assembly.GetTypes().Where(t => typeof(ConfigOption).IsAssignableFrom(t)).SelectMany(t => t.GetFields()).Where(f => typeof(ConfigOption).IsAssignableFrom(f.FieldType)).Select(f => f.GetValue(null)).Where(o => o is ConfigOption).Cast<ConfigOption>();
IEnumerable<ConfigOption> configOptions = typeof(ConfigOption<>).Assembly.GetTypes().Where(t => typeof(ConfigOption).IsAssignableFrom(t)).SelectMany(t => t.GetProperties()).Select(p => p.GetMethod).Where(m => typeof(ConfigOption).IsAssignableFrom(m.ReturnType)).Select(m => m.Invoke(null, null)).Where(o => o is ConfigOption).Cast<ConfigOption>();
// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
configOptions.Where(configOption => _configFile[configOption.Section, configOption.Field] == null).Select(configOption => _configFile.Bind(configOption.Section, configOption.Field, configOption.DefaultValue, configOption.Description));
}
Unless I'm forgetting something, these classes and this method are everything that's relevant to the error.
And that first line of the method is the eroneous one.
Oh, wait, there's two lines there.
The first one is the test I just did with using a field instead of property.
For which I also made one property in general a field isntead.
And the second line is the one for when the classes contain properties.
Both of these throw exceptions when trying to get their values, because said value has a generic type.
first you might want to add && !t.IsAbstract to the first where
probably wont fix it
but this is a property so it might be causing a problem
Fair.
i think that fixes it
because the only property that has an unbound generic is the DefaultValue
No, still gives the same exact error.
System.InvalidOperationException: Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.
Yes, I checked in the debugger, and it's only grabbing the desired getter methods, no other ones.
Results of typeof(ConfigOption<>).Assembly.GetTypes().Where(t => typeof(ConfigOption).IsAssignableFrom(t)).Where(t => !t.IsAbstract).SelectMany(t => t.GetProperties()).Select(p => p.GetMethod).Where(m => typeof(ConfigOption).IsAssignableFrom(m.ReturnType)).
A.k.a. all of the LINQ from before the .Select() that invokes the methods.
after the error happens
which one is causing it
hover on the m in m => m.Invoke
what is the Id property
well
i just ran the code
and it ran completely fine
your error is in these @prisma grail
Wait, what .net version are you using?
.net 8
I forgot to mention this, but I'm running .net framework 4.8.
I need to stay on that version since I'm modding WorldBox, and it's what WorldBox runs.
unity ☕
Totally forgot that I need to point that out, since this channel isn't WorldBox related. :P
they are going to add .net core support this year apparently
but i dont think wb code base will update
might cause too many problems
but tbh .NET 8 is so much faster than .NET framework that an upgrade would be cool
have you checked these?
It'd definitely be nice, especially as .net framework is only meant for Windows.
So I get to deal with mono instead.
mono 🤮
And stuff is all weird.
mono is so stupid
I will now.
first i would change .Select(m => m.Invoke(null, null) with .Select(m => { Console.WriteLine(m.name); return m.Invoke(null, null); })
unless you can tell exactly which property is causing the error
with your IDE
the last name written in the console should be the name of the erroneous method
Which I can't, because the debugger is stepping weirdly fsr with my setup.
yeah just do this
because it doesnt seem like these fields are late bound generics
you are specifiying that they are bool in this case
Ok, Mono just got onto drugs, I'm quite sure.
The entire console output.
Random NRE.
No line counts.
And break points aren't working correctly.
It's still giving the right one when I throw the LINQ into an eval console while stepped into the method.
so which method is causing the error
Only method change I made is to comment out the LINQ line that was attempting to use fields.
did you do this?
Yes.
what did it print?
What the above screenshot shows...
but this
it cant throw the right one
without it giving you the name
Well, yeah, the output was weirdly bugged. I was just able to make it work properly by moving the code to somewhere else.
Problem seems to be OnlyAllowOneOpenSubmenu.
Yes.
switch generics with classes
only way
i guess
public class BoolConfigOption : ConfigOption {
public new bool DefaultValue => (bool)base.DefaultValue;
internal ConfigOption(string field, bool defaultValue, string description) : base(field, defaultValue, description)
{
}
}
public abstract class ConfigOption
{
public string Section { get; }
public string Field { get; }
public object DefaultValue { get; }
public string Description { get; }
protected ConfigOption(string field, object defaultValue, string description)
{
Section = GetType().Name;
Field = field;
DefaultValue = defaultValue;
Description = description;
}
}
something like that
not as clean as the generics though
or use
public static ConfigOption OnlyAllowOneOpenSubmenu => new General<bool>("OnlyAllowOneOpenSubmenu", false,
might fix it
Last thing I could try is to back those with the generics, to reduce the amount of code duplication.
but you dont get the type of the configoption
Should technically satisfy the weird requirement C# is imposing unless I'm being stupid rn.
That one wouldn't work for me because it once again means that I gotta do type casting stuff when accessing specific config fields.
public class BoolOption : ConfigOption<bool> {
}
public abstract class ConfigOption<T> : ConfigOption
{
public new T DefaultValue => (T)base.DefaultValue;
internal ConfigOption(string field, T defaultValue, string description) : base(field, defaultValue, description)
{
}
}
public abstract class ConfigOption
{
public string Section { get; }
public string Field { get; }
public object DefaultValue { get; }
public string Description { get; }
protected ConfigOption(string field, object defaultValue, string description)
{
Section = GetType().Name;
Field = field;
DefaultValue = defaultValue;
Description = description;
}
}
doesnt look too bad
ofc you gotta add the consturctor
but yeah
Yeah, could be worse.
Question: Why is ConfigOption abstract?
Because my implementation makes it so that the section is decided by the exact subtype that's being constructed.
Section = GetType().Name;
Did that to save myself the writing effort of needing to specific a category via constructor arguments.
Makes sense
Since the Section is always the same per subclass.
Gotta say goodbye to that system now though, because of the stupid reflection limitations.
Yup, it works now.
noice
(Still kinda hurts though how horrible C# reflection is at dealing with generics.)
I miss you guys my nerds
I'm forced to. 
we are not nerds
u are
we are femboys
you are both
with our programmer socks
all femboys are nerds but not all nerds are femboys
all fenasi kerim are fake
two nerds #⌨coders-cave users hanging out
Those sure look very comfy. IwI
if only I had a spanish girl to do that with
Most certainly o( ̄▽ ̄)ブ
Gives me quite the urge to order some right now. UwU
Same tbh OwO
Might even be able to keep me sane while I continue to debug the new exceptions that are now arising in my code. OwO
Thigh highs are proven to raise computer science capabilites by 200 % when worn (p≧w≦q)
UwU
Layering
Great strats right there.
Ngl, I really could need the skill rn. The code is working when I run it normally, but not when I run it in my mod, and I can't attach a debugger to the game on my Mac.
To figure out why.
Yup. IwI
Rn, I literally have to try spamming console logs to try figuring out what's wrong.
I am so done rn.
It's literally finding them.
All.
So why is it not being loaded into the config.
print out the keys of the dictionary
Doing that rn.
Ohhh.
Nvm, I'm a huge idiot.
I'm literally running this on every config value.
Before adding it.
To check if it exists.
Ouch.
I sometimes sure am quite the idiot. 
we all are
Fair.
The type problems are only getting more attrocious.
Literally doing a horrendous type check.
Just to always run the exact same code.
wait what
you dont need that
configOption does have a value right?
configOption.defaultValue
Yes, but if I simply use configOption, the type is object.
And Bind is a generic method.
That only supports certain types.
Ngl, at this point, merely reading such statements is making me emit laughs of insanity.
oh wait this might not work
But how do I upcast from ConfigOption onto ConfigOption<T>?
cause you cant cast to ConfigOption<T>

i feel like there should be a way to make this work
Example of when the ? operator would be useful:
Wildcard for generics.
From Java.
i guess
(? as nullable doesn't exist in the .net framework version of WorldBox.)
No bool?, string?, etc possible.
oh yeah
everything is nullable 
bool? does exist
because its not nullable its a struct
TwT
You wouldn't believe how common it is for you to make a small change.
Just for it to result in some random method by the game throwing an NRE.
And the methods tend to be quite long, and stack traces don't show line numbers.
So you don't even get to easily find out what's causing the NRE.
sounds fun 
At times, I'm not even sure what's more painful: That, or making a Discord bot in Python.
dont make anything in python
Those two things are pretty much my only personal coding projects atm. TwT
AMP moment:
AMP was a mistake
No, only it's programming language was. 
Anyways, want to see what I just went through all of that pain for?
All of it just so that I get to have IDE autocomplete for Config values without needing any code duplication for it @barren shale .
I SOLVED IT
I SOLVED YOUR ISSUE
omg im the best C# dev
public abstract class ConfigOption
{
public string Section { get; }
public string Field { get; }
public object DefaultValue { get; }
public string Description { get; }
protected ConfigOption(string field, object defaultValue, string description)
{
Section = GetType().Name;
Field = field;
DefaultValue = defaultValue;
Description = description;
}
public void Bind()
{
typeof(ConfigOption)
.GetMethod("F")
.MakeGenericMethod(DefaultValue.GetType())
.Invoke(this, new object[] { DefaultValue });
}
public void F<T>(T param)
{
Console.WriteLine(param);
}
}
F is the test function here
instead of calling F you'd call the actual Bind function in the ConfigFile
sometimes things like these make me love typescript
notice how this only gives me two options for the string
the two options i specified here
type inferenace is the heaven C# needs
If that were a thing in C#, I could've spent the last 5 hours of my life not suffering.
yeah 
have you tried the solution?
dis
My brain was already so dead on the inside that I stragiht up didn't notice it. TwT
Lemme give it a shot real quick.
I can't even use an ! to surpress the null warning. 
should never be null wrap it in a try catch if you wanna be cautious i guess
Nah, I just applied a ? instead.
Wait WorldBox modding uses .NET Framework?
Took them long enough
but i dont think wb will migrate
even though i think they should
at least a slow one
If your code does it's job, I'll forever be in your debt. xD
xD
📸
@barren shale Giving up on improving it for now, but whenever you see this, this that I've got a shot at somehow bypassing C# restrictions by grabbing the MethodBody, stuffing the IL instructions into a DynamicMethod, and then running that?
Yay
i dont think that's possible
and i dont think it would look cleaner
Yeah, ok, that's fair. I'm just kinda grasping at whatever at this point, should probably instead just accept the system for what it already is. 
Tbh I used to do this a lot but then I stopped and started optimizing on the go
Because sometimes you don’t really know how you want it to be in the end
Fair, though there's one thing bugging me like crazy about my current implementation.
I have these methods that construct the Options for me duplicated in every class.
But if I were to move them to a separate utility class, I'd need to specify the section every time, instead of being able to put it into the methods.
Theoretically, if I could inherit, this wouldn't even be a problem because I could just get the class name of the specific type as the section.
But I can't inherit since it's all static. 
Wait, nvm, I'm an idiot, I can just make the parent class a singleton.
Yeah, ok, nvm all of that, I was just casually forgetting that design patterns exist, Ig. 
@barren shale Turns out that we were being stupid yesterday all along, not C#. Simply gotta add this Select, and C# can suddenly deal with the generic types.
Yeah, the only weird generics workaround that's still in there is your Reflection code in ConfigOption.
I mean it was working for me
And it can also work in .net framework with that single extra select. TwT
Yup, I was able to go back to the General<T> thing.
Pog
Indeed, the code is so much better to look at now. 
the power of reflection
this guy is what aspired me to code in 2015
buy a new pc before debugging anything
What are you making in Unity?
hmmm
nahhhh im good 
Yo can I have some C# vs C++ memes lol
no
😦
one of you shut-ins should make an interface ideal for map wars
No experience in graphical design 😔
neither
i guess its a union type but a specific feature in the union type
when actionButton is true, action is defined
when actionButton is false, action is undefined
so if i check if the action button is true, the typescript language server knows that action is defined in the if statement
it makes making optional arguements so much easier
so i guess its not neither
its both merged together 
Ah, I see, the syntax tripped me up because I barely do any TS.
yeah ts type syntax is super confusing
The feature that almost sold ts to me
why almost though
ts is the best option for web
and a pretty good option for small projects
Because i didn't work on js after species box
Only c# for now
If i will need to do something on js, ts will be used of course
After sb i understood that fully 🫠
i saw 
I made sb and ncms by working on both projects at same time, because i wanted to done them before wb steam release, it was a rush, this is why its not so good 🫠
yeah when i heard how fast sb was done i was impressed tbh
i wouldnt be able to do it this quick
kinda off
I'm need to commit to either learning masm or opengl doing both is greatly impacting my sanity I think I'm hearing voices 💀
Even just programming. I was awake for like 40hrs the other day just reimplementing C standard library functions to add functionality because I didn't like the current function base's limits
Learn everything
You’ll thank me for this advice later by killing me
But heh
It’s for science

My ultimate goal in this industry is to make it more approachable so this isn't a terrible idea
Welp, you’re fucking crazy
You really do hear voices
I thought I made that clear 😭
Plus this is worldboxcord we're all crazy
This resolution of mine came to me in a hallucination
No wonder
True
Let yourself be guided into the grinder
Cya in there
🫡
What should I start eith to learn coding like I assume Python
Don’t code. Easy as that
@queen zodiac
Mmmh
I wanna be a developer in worldbox team so yeh
Worldbox will be finito when you’ll graduate from coding, my boy
Depends what you want to make. If video games are your goal try C#
Ohk
But isn't game like minecraft made on Java?
Oh wait a sec I just realized I need to learn C and c++ before java
Minecraft is the only big game made in Java
Indie games are usually made in Unity with C# including WorldBox
AAA games are usually made with C++ using UE or similar game engine
Imo C and C++ are not a good starting point to learn coding
you dont need to learn anything before anything
Fr I thought their would be more
you can learn any language at any time
I personally love indie game will if so I guess C is my target
C works but its 20x times harder
or 100x
or 1000000x
would not recommend for beginners 
C is mostly used for embedded
C# ohk let's me do a quick YouTube search

Do u have experience with unity??
U can help me improve my goofy ass game
Why ask me questions. Ask the nerds around here questions.
But you are
Mf

Is there some specific problem you're encountering?
Not yet
relatable
I fucking suck at using blender
I have friends who are amazing with it but I can barely make anything with it
its not a problem
its a skill you havent acquired yet
go practice
Hi
hi
Bye
he's holding them wrong
Hi
Hi
Hi 🤖
Hi
Hello
Guys tell me why active all code not work for me @everyonw
Visual studio code enough to make mods, its like a notepad, but very powerful
But for codding better to use visual studio (not visual studio code)
What
I've only had bad experiences with visual studio
And it gets worse with each passing version
While visual studio code has only done good things for me
the only thing that could save me during all of this was chasing cars; a glimmer of hope amidst a dystopian fuckmare taking place before my own two eyes (have they not deceived me) and may christ lay my wretched soul soon to rest.
like that video you haved to fucking deal with all of vs's shit, and it traps you into vs if you don't use cmake
And it's broken half the time
Meanwhile the only problem I've had with vsc so far is the settings not carrying over instantaneously from wsl to desktop
and vsc is 80 gigabytes while vs is 200 megabytes, and mingw64 plus all the libraries I installed make like 50 megabytes
What languages are y’all using? I’m over here locking in trying to get better at Java
Why does everybody try to learn Java?
I use grass 👍
Like why
Minecraft suckers I guess
So many people uniformly decide they want to learn it
Hey I need help with something, if anyone has taken Computer Science A and did the resource finder projects where do you find the data file to start the project, I can't find it anywhere in the page, online, by my teacher, so I'm at a lost
That’s... specific
I've been searching for a solution all day and litterallly nothing about it has come up
So I'm slowly going down into insanity
Punch your teacher a few times and ask him. Always works
Will do, however if anyone knows anyone, tell me
Another problem I'm having: so I'm tryna make blackjack in Python, but this error keeps coming up AttributeError: 'str' object has no attribute 'point_value' and no matter what I do, any fix, any video tutorials, nothing works
So anyone got a solution or tip
class
your trying to do (probably)
a = "whatever the hell"
a.point_value
``` I think
which is weird and why are you programing objects in python at that skill level
Why i found out this just now
It looks so clear
Removes so many repeats
By this way c# will looks like js because of lack of types in code
doesnt remove so many repeats if you use var 
i prefer var
i guess
i always initialize in constructors
but yeah its useful if you dont do that
In game engines usually initialization of components happens not in constructors
Unlike unity godot allows to use constructors but i got used to do it by this way
yeah i used to use var a lot before new()
so i just got used to it
too hard to stop a habbit smh
It's been a 2 year gap since I coded anything related to this as I've been focusing on another coding language but now I have to take this specific class for this coding language again
But thanks for the help
I had no choice in the matter- my school has me doing it. But I’m learning C# and eventually C++
If your goal is to learn a language, I wouldn't recommend including an intermediary language, especially if the goal is to learn something like C/C++. The features of one language will disrupt your learning of the features of another and playing the de-abstraction game of going from a high level completely object-oriented language to a "mid" level language like C/C++ is very difficult. I'd say focus on C++ now if your goal is to learn C++. This will also make it much easier to learn C# if you want to use C# for whatever reason.
My sith lord advice is fuck object oriented programming, drop out of school so you don't have to learn Java, learn C, and do crazy shit
Holy-
I got carried away but it's good advice I swear 😭
My sith lord advice is fuck object oriented programming
Bro what, C# is literally 😍
You are the enemy
Also C# is not even close to high level if you comapre it to the likes of JS and Python
I do also know how to write C and C++ but I rarely ever use them
Compared to C it is
fair
I mean fair enough
but it's pretty mid level language
It's a high mid level
I can agree to that
Tbf I use C# mostly because I got a job where I use it
I'd like to get into embedded programming tho
which afaik is mostly C
But I kinda suck at C rn so I gotta get a bit better in it lol
If you want money => learn c#
If you want fun => dont
Disagree, you can start with any language without it having a negative effect
Assembly 🤭
Any
Higher level languages tend to have a lot of abstraction which can make a migration to a lower level language a bit jarring
True
A bit less jarring than learning from scratch
Not in my experience
Imagine you had to learn what a pointer is while not even knowing what a string is
This
Or the basics of memory
My point exactly
Isnt that the opposite of your point
No?
Whats your point
Higher level languages add too much abstraction
I’ve taught programming to over 70 people, the ones who had previous programming experience learned faster than the ones who didn’t
It didn’t matter what language the previous experience was in
Im lost on what the topic is
I struggled switching between higher and lower level languages 🤷♂️
How
And which
I learned a lot more focusing on C++
But you’ve never learnt a lower level language before a higher level language
Python and js into Java into C++
Well you learned the two highest possible language
This is true
And then switched to c++ obviously it's not gonna be a breaze but still
It was definitely easier than goikg from nothing to c++
I used to think it would be harder to transition from high level to low level
But after teaching all of these people it turned out that it’s the opposite
Its def the other way around
Going from c to c# is such a headache
And js is just js
Its not even a topic
I don’t think it is
I think a lot of misconceptions and bottlenecks could've been avoided if I just leapt into low level, obviously some of it would've been harder but I struggled with the idea of memory for quite a while because I didn't start actually thinking about how it worked
Having any programming experience makes it easier
It doesn’t matter what the language is
It makes learning syntax easier
Yea but still
Learning syntax is a joke 
Most languages have the same syntax
Functional to oop is 😶
And it takes a couple of days at most to learn a syntax as someone who never looked at code before
Okay?
Thats why learning python as first language is not good because of syntax
I mean, kinda, but even C and C++ are very distinguishable
Very much true
That’s a different type of programming
When learning it you should see it as something new
Python is a great scripting and prototyping language
Bro they are so similar
Gcc and compile c++ code and the other way around
99% the same id say
bool 🤷♂️
I learned g++ exists a few months ago
Just define it yourself its muscle memory
C++ hates the preprocessor
I see. I’m going to eventually make a network scanner out of Java for training purposes
The only difference they have is c++ has shitty oop noone uses and structure declaration
It also has STL which is a blessing and a curse
Uhhh
And namespaces
That’s the point of cpp
C++ has strayed from C in many ways
Idk these days I feel like it’s a waste to use C/C++ for anything not embedded these days
Low level?
Go or rust
Super fast
Way better DX
Rust 😍
I disagree, the problems rust solves are not worth writing such ugly code 😭
UGLY????
I should learn rust eventually
Nah bro you dead to me
😭
Writing rust is still way better DX than C/C++
You dont fucking insult my baby and get awya bro
Well, C++ is becoming closer to Rust and C isn't object-oriented
Rust isn’t oop
It isn't?
No
No
Holy fuck
Its perfect is what it is
It has very very very powerful structures which are basically like objects
Now if only it looked like C++
Unreadable syntax sugar my beloved
Eh
Like C
Not really
Wdym not really the entire language revolves around them
Yes X1000
I mean they are not like objects
I'd argue basically all languages are built data structures in some way
Similar use case or smt
But yeah C/C++ should not be used in 2024 
If there are member functions then it's an object
Embedded 🤓☝️
I disagree
No excuses to use them
The only reason
That's exactly what you're saying 😭
Also if you need to mix assembly its better to go with c/c++
I learned something useful from this conversation: y'all can't shut up
You can write code faster in rust or go
Because the rust way of transitioning to assembly is
And it doesn’t run slower than C/C++
Not great
If your goal is to write code that will be reused in another language, C/asm is the way. They have standardized calling conventions that make code highly adaptable, as was the point of the language
Your like that kid in the friend group who just listens to a convo without anyone noticing him there, makes a joke that doesn't make sense and goes home to ask why noone likes to talk to him
Lmao
He's redeemable though, he just needs to learn something from our pointless convos
Yeah C/C++ still have their uses but “I want my code to run fast” is no longer one of them
Yes I took alot of brainpower to make that up
If you want your code to run fast, and you already know C/C++, there's no point in learning Rust for a project

Have fun! Cya
Long term investment
That's not a project
Obviously I need to learn Rust
tell me is something wrong?
It's not in any of my projects
World doesn’t have creatures
Gotta move on to better languages at some point
ok
Or you will be like the Java and php devs

We're maybe closer than we might think :3
i dont know how to fix this
Something to learn I guess 
No I have a Frankenstein type master plan for a code-only game engine I'm working on
No need to write a scripting language for modding/general usage when there's already a very powerful language hanging around that has all the features I'd want heheh
Why must you hurt me in this way
Did you read everything? Get some friends
I saw something I found a bit relatable so I replied to it. By the way what do you even think chat rooms are for?
To pretend you're talking to others when, in reality, you're talking to yourself or alone (#🌎general )
Why no?
better start liking other languages
C/C++ wont stay with us forever
new companies are not using them and old companies are switching to more modern languages
microsoft switched some services from C#/C/C++ to rust the last couple of weeks
Assembler will (at least for very long time), so your logic says to learn it
and C/C++ will stay
but what percentage will be using them?
its growing smaller by the year
"growing smaller" 
there are still apps written in visual basic in my country
and they get maintained
Negative growing
@queen zodiac you always here?
Our politicians using such phrases
I do not have a life
Zig has so much potential its unreal
Get one its not difficult trust
Zig is like if rust and c had a baby and it was beautiful
Easier said than done
And they named her "Isabella" and she grew up to be the queen of some big ass kingdom
Thats how I imagine zig as a person
You go to a group of people talk to them for 20 minutes they start yapping about the last party they threw you get interested they ask wanna come to the next done
Its literally that simple
