Skip to content

Commit

Permalink
Fix std/random not compiling, add playdate.system.randomize, minor Lu…
Browse files Browse the repository at this point in the history
…a changes
  • Loading branch information
samdze committed Nov 18, 2023
1 parent e4be6eb commit c7d9bac
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion playdate.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.11.0"
version = "0.11.2"
author = "Samuele Zolfanelli"
description = "Playdate Nim bindings with extra features."
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/playdate/bindings/lua.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sprite {.all.}
import types

type
LuaStatePtr* = pointer
LuaStatePtr* {.importc: "lua_State*".} = object
LuaNimFunction* = proc (L: LuaStatePtr): cint {.cdecl, raises: [].}
LuaUDObject* {.importc: "LuaUDObject", header: "pd_api.h", bycopy.} = object

Expand Down
3 changes: 2 additions & 1 deletion src/playdate/build/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ if not testing:
switch("noMain", "on")
switch("backend", "c")
switch("mm", "arc")
switch("os", "any")
switch("parallelBuild", "0") # Auto-detect
switch("hint", "CC:on")

Expand All @@ -36,6 +35,7 @@ switch("passC", "-Wdouble-promotion")
switch("passC", "-I" & sdkPath() / "C_API")

when defined(device):
switch("os", "any")
switch("gcc.options.always", "")

switch("nimcache", nimcacheDir() / "device")
Expand All @@ -47,6 +47,7 @@ when defined(device):
switch("assertions", "off")
switch("hotCodeReloading", "off")
switch("define", "useMalloc")
switch("define", "standalone")

let heapSize = 8388208
let stackSize = 61800
Expand Down
1 change: 0 additions & 1 deletion src/playdate/lua.nim
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,4 @@ proc callFunction*(this: ptr PlaydateLua, name: string, argsCount: int = 0) {.ra
var err: ConstChar = nil
var success = this.callFunction(name.cstring, argsCount.cint, addr(err))
if success == 0:
playdate.system.logToConsole(err)
raise newException(LuaError, $err)
8 changes: 7 additions & 1 deletion src/playdate/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,10 @@ proc removeAllMenuItems*(this: ptr PlaydateSys) =

proc getReduceFlashing* (this: ptr PlaydateSys): bool =
privateAccess(PlaydateSys)
return this.getReduceFlashing() == 1
return this.getReduceFlashing() == 1


import std/random

proc randomize*(this: ptr PlaydateSys) =
randomize(this.getSecondsSinceEpoch().milliseconds.int64)

0 comments on commit c7d9bac

Please sign in to comment.