Can I use std/json to serialize objects in a Table?

2024-05-05 Thread ninovanhooff
proc saveJson*[T](value: T, path: string) {.raises:[].} = let jsonNode = %(value) [...] more code Run Gives this error: Executing /Users/ninovanhooff/.nimble/bin/nim c --colors:on --noNimblePath -d:simulator -d:debug -d:NimblePkgVersion=0.2.0 --path

Can I use std/json to serialize objects in a Table?

2024-05-05 Thread ninovanhooff
Thanks for the suggestion, but adding the tables import didn't help

Can I use std/json to serialize objects in a Table?

2024-05-04 Thread ninovanhooff
following: /Users/ninovanhooff/PlaydateProjects/wheelsprung.worktrees/level-data/src/data_store/configuration.nim(14, 11) template/generic instantiation of `saveJson` from here /Users/ninovanhooff/PlaydateProjects/wheelsprung.worktrees/level-data/src/common/json_utils.nim(23, 18) templa

Please review my types: ref object or plain object

2024-04-27 Thread ninovanhooff
I did have terrible performance issues related to the seq being copied when stored as a temp variable in a function scope. Thinking back on it, the problem there might have been that I used let while I should have used var. I suspected as much with the direct result assignment. (hence the commen

Please review my types: ref object or plain object

2024-04-27 Thread ninovanhooff
Found a discussion on the return question here: Thanks for the help @Araq

Please review my types: ref object or plain object

2024-04-26 Thread ninovanhooff
In my game, I want to show a replay of character movement after the level is completed. This is known as a Ghost. I'd like to ask you to review the types I have set up for this. It should not blow up the stack or cause performamce degrading effects like memory fragmentation. The recording is co

How to use inherited Object type as return type?

2024-04-04 Thread ninovanhooff
facepalm:| This is what I get from coding in 3 languages. Thanks.

How to use inherited Object type as return type?

2024-04-03 Thread ninovanhooff
Given this type definition: type Asset* = ref object of RootObj position*: Vertex flip*: LCDBitmapFlip Texture* = ref object of Asset image*: LCDBitmap Animation* = ref object of Asset bitmapTable*: LCDBitmapTable frameCount*:

Am iterating over this sequence correctly?

2024-04-03 Thread ninovanhooff
I was hoping to learn about something like `mitems` Excellent answer, thank you!

Am iterating over this sequence correctly?

2024-04-01 Thread ninovanhooff
I'm trying to modify a sequence in-place by modifying the values without copying the data. This worrks, but I wonder wether I'm doing it in an idiomatic 'Nim' way, rather than trying to use `ptr` too much. I feel the answer should be here, where it is suggested to use `ref`. Not sure how to ge

Warning: method has lock level , but another method has 0 [LockLevel]

2024-03-18 Thread ninovanhooff
Hello from the future! I'm using Nim 1.6 at the moment, moving to 2.0 soon. I'm targeting a single core system without threading and would like to turn off the locklevel warning project-wide. 1. Is it true that this whole concept is gone or deprecated in v2? 2. This doesn't work when I stic

How to use nimble develop with a fork?

2024-02-24 Thread ninovanhooff
As a dependency for my game, I want to list my own fork of a nimble dependency. Subsequently, I want my game to use the local copy of that fork for easy development The nimble dependency I forked is `chipmunk7` My fork is at <https://github.com/ninovanhooff/nim-chipmunk-playdate> Note t

Unreachable code is reached

2024-02-07 Thread ninovanhooff
It was something else entirely. There are multiple LevelObjectEntity's to load, some of which have a gid. That's the whole reason why gid is an Option[unint32]. So for some calls to loadGid, the code would indeed return early, while for others it would run completely. The breakpoint hit for tho

LLdb: Is there an .lldbinit file available for Nim's own types?

2024-02-06 Thread ninovanhooff
Great, thanks for thinking outside the box and providing a solution to problem rather than my original question. Perhaps the official extension needs to be promoted more, it seems suspicious, with only 700 downloads. I was using another extension for that reason. I gave it 5 stars, hope it help

Unreachable code is reached

2024-02-06 Thread ninovanhooff
I feel I fundamentally don't understand something about Nim, or that the code in my editor is not actually the code that is executed. What I'm trying to achieve is an "early return pattern", where a proc exits if some precondition is not met. In this case the Option value `gid` should be presen

LLdb: Is there an .lldbinit file available for Nim's own types?

2024-02-06 Thread ninovanhooff
Hmm nimlldb.py does not seem to work for me in 1.6.16. It has a bool IS_NIM_V2. I tried both False and True for it. It would either format a string as an empty string or an array of chars. I do use the CodeLLDB extension, not sure if you meant that one @jmgomez. I hadn't noticed any effect of a

LLdb: Is there an .lldbinit file available for Nim's own types?

2024-02-06 Thread ninovanhooff
Thank you! I'm using Nim 1.6.16 and I see that script is only available since Nim 2. But I'll try to see if it works anyway. If there is a specific version for Nim 1.6 I haven't found yet, please let me know

LLdb: Is there an .lldbinit file available for Nim's own types?

2024-02-05 Thread ninovanhooff
I just managed to setup lldb and add a rule to format (one of?) Nim's string type:`NimStringV2` With this rule, the actual human-readable value of the string is shown in the editor, instead of an object containing a pointer to the actual characters I did this by adding the following to the `.ll