0
0
この記事誰得? 私しか得しないニッチな技術で記事投稿!
Qiita Engineer Festa20242024年7月17日まで開催中!

DeSmuMEで組み込まれているLua用API 非公式リファレンス ~stylusライブラリ~

Posted at

この記事はニンテンドーDS向けエミュレータの一つである「DeSmuME」(以降Desmume)のLua用APIの非公式日本語リファレンスです。今回はstylusライブラリについてのリファレンスです。

このリファレンスは非公式の日本語リファレンスです。そもそも英語のリファレンスも公式のリファレンスもありません。
さらに詳細の仕様を確認したい場合はDesmumeのソースコードを参照することを推奨します。
https://github.com/TASEmulators/desmume/blob/master/desmume/src/lua-engine.cpp


stylus.get()
タッチ操作のX座標Y座標とタッチしていたかを取得する。(1F前の情報)

引数

無し nil

戻り値

table
<キー>
[x]:X座標 int
[y]:Y座標 int
[touch]:タッチの有無 boolean

example.lua
local function Fn()
local table = {}

table = stylus.get()

if table.touch then

gui.text(0,10,"X: "..table.x)
gui.text(0,20,"Y: "..table.y)

end

end
gui.register(Fn)

stylus.peek()
現在のタッチ操作のX座標Y座標とタッチしているかを取得する。

引数

無し nil

戻り値

table
<キー>
[x]:X座標 int
[y]:Y座標 int
[touch]:タッチの有無 boolean

example.lua
local function Fn()
local table = {}

table = stylus.peek()

if table.touch then

gui.text(0,10,"X: "..table.x)
gui.text(0,20,"Y: "..table.y)

end

end
gui.register(Fn)

現在情報なので一時停止中でもとにかく取得します。


sylus.set()

引数

第一引数 操作内容
table
<キー>
[x]:X座標 int
[y]:Y座標 int
[touch]:タッチの有無 boolean

戻り値

無し nil

example.lua
local table = {}

table.x = 100
table.y = 100
table.touch = true

stylus.set(table)

実際に使う際にはemu.registerbefore()で呼び出すかemu.registerboundary()で呼び出さないと描画が更新されずにdesyncする。
サンプルコードは一回切りのコードで、なおかつframe advance操作を行っていない。これはあくまでも動作確認用コード


代替名一覧
以下の関数でコードを書いても右側の関数として認識されます。
stylus.read()stylus.get()
stylus.write()stylus.set()

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0