Post

Code Monkey
Code Monkey@UnityCodeMonkey·
Let's say I saved my game data in a text file and I am now trying to load it, does this work? string savedHealthData = "100"; int healthAmount = savedHealthData; A) Yes B) No C) Yes but healthAmount will be 0 (answer in reply below)
English
6
0
16
4.4K
Code Monkey
Code Monkey@UnityCodeMonkey·
#### ANSWER #### #### ANSWER #### #### ANSWER #### #### ANSWER #### #### ANSWER #### #### ANSWER #### #### ANSWER #### #### ANSWER #### #### ANSWER #### #### ANSWER #### #### ANSWER #### #### ANSWER #### (B) You cannot **implicitly** convert a string into an int. In order to do that you can use the function int.Parse(); or int.TryParse(); int healthAmount = int.Parse(savedHealthData); Or you can use something like JSON to handle the type conversion for you, that's how I normally handle saving and loading in my games and I never have to manually parse numbers. Simple Saving and Loading with JSON to a File youtube.com/watch?v=6uMFEM…
YouTube video
YouTube
English
0
0
6
1.5K
Bronze League Pro
Bronze League Pro@BronzeLeaguePro·
@UnityCodeMonkey Depends on what language you're using. Some languages will parse strings to ints, some will be more robust than others, but even if it works you should not do so, be clear in your intents instead.
English
0
0
3
100
Victor Renard
Victor Renard@VictorRenajlj·
This company just took news headlines by storm - Jacob Amsterdam just joined its Advisory Board. WHY? Copper recently traded above $14,000 per ton, near historic highs, as demand from AI infrastructure continues accelerating. Just one electric vehicle can use more than 80 kilograms of copper. Some estimates suggest a single large-scale AI data center can require up to 50,000 tons of copper across power systems, transformers, cooling infrastructure, wiring, and grid connections. AI data centers, robots, military systems, renewable energy, and EV production are all increasing global copper demand at the same time. Entire countries are upgrading electrical infrastructure simultaneously. And while demand rises, new copper mines can take more than a decade to develop. That is where NovaRed Mining enters the story. Its Wilmac Copper-Gold Project spans nearly three times the size of Manhattan across prospective copper-gold terrain in British Columbia. As the global race for copper intensifies, companies connected to future copper supply are attracting increasing investor attention. Always do your own research. This is not financial advice.
Victor Renard tweet media
English
81
297
2.3K
5.2M
RacyPlant
RacyPlant@RacyPlant·
To mogłoby zadziałać w Python savedHealthData = "100" healthAmount = int(savedHealthData) Nadal jest to funkcja konwersji, a nie bezpośrednie przypisanie. W sumie Visual Basic też powinien zadziałać, tylko trzeba Oprion Strict ustawić na Off Dim savedHealthData As String = "100" Dim healthAmount As Integer = savedHealthData
Polski
0
0
0
155
Paylaş