Joined: 10/2/2015
Posts: 91
my computer is poop. it's very bad. i am having trouble with playback when i open the ram watch viewer, but not running lua scripts. my question is, what syntax is wrong here? Download test.lua
Language: lua

local ramAddress = 0x7E0577 local ramValue while true do ramValue = memory.readbyte(ramAddresss) gui.text(0,0, ramValue) emu.frameadvance() end
ultimately, i want to write a script that displays things like speed and position on the screen. this will circumvent playback issues.
I didn't kill donkey, I saved it. Current projects: Misc Donkey hacks :) Past projects: Pacifist DKC1 DKC1 Entrance randomizer DKC2 Entrance randomizer DKDC (a troll hack of DKC1) DKC1 Enemy randomizer (among other things)
ALAKTORN
He/Him
Former player
Joined: 10/19/2009
Posts: 2527
Location: Italy
You wrote ramAddresss with 3 s within the loop.
adelikat
He/Him
Emulator Coder, Site Developer, Site Owner, Expert player (3570)
Joined: 11/3/2004
Posts: 4754
Location: Tennessee
Also, from the looks of it, it seems you are attempting to read a SNES address. The address you have is from system bus, but memory is set to WRAM space by default. You either need to set the memory domain to the bus, or convert your address to WRAM. I think you chop off the 7E to convert from bus to WRAM? I'm not 100% sure of that though.
It's hard to look this good. My TAS projects
Joined: 10/2/2015
Posts: 91
thanks for noticing the typo. the code works perfectly well with snes9xrr, but still throws an error on bizhawk :/ the current error is an infinite loop
I didn't kill donkey, I saved it. Current projects: Misc Donkey hacks :) Past projects: Pacifist DKC1 DKC1 Entrance randomizer DKC2 Entrance randomizer DKDC (a troll hack of DKC1) DKC1 Enemy randomizer (among other things)
Amaraticando
It/Its
Editor, Player (159)
Joined: 1/10/2012
Posts: 673
Location: Brazil
As adelikat said, BizHawk defaults to WRAM region. You cannot use the bank $7E at the beginning of the address, unless you set the region to BUS, "System Bus" IIRC.
Language: lua

local ramAddress = 0x0577 -- WRAM is from $00000 to $1FFFF for SNES local ramValue memory.usememorydomain("WRAM") -- just in case while true do ramValue = memory.readbyte(ramAddress) -- ramValue = mainmemory.readbyte(ramAddress) -- is valid too, without using memory.usememorydomain gui.text(0, 0, ramValue) emu.frameadvance() end
Reference: http://tasvideos.org/Bizhawk/LuaFunctions.html
Joined: 10/2/2015
Posts: 91
thanks! sorry for my noobiness!
I didn't kill donkey, I saved it. Current projects: Misc Donkey hacks :) Past projects: Pacifist DKC1 DKC1 Entrance randomizer DKC2 Entrance randomizer DKDC (a troll hack of DKC1) DKC1 Enemy randomizer (among other things)
Amaraticando
It/Its
Editor, Player (159)
Joined: 1/10/2012
Posts: 673
Location: Brazil
Tip: Is memory.readword or mainmemory.readword listed in the reference?
Joined: 10/2/2015
Posts: 91
no, i looked at your references shortly after posting. im using memory.read_s16_le now. it works for 1 ram value but not for 2
I didn't kill donkey, I saved it. Current projects: Misc Donkey hacks :) Past projects: Pacifist DKC1 DKC1 Entrance randomizer DKC2 Entrance randomizer DKDC (a troll hack of DKC1) DKC1 Enemy randomizer (among other things)
Joined: 10/2/2015
Posts: 91
[string domain = null]) <- what do i replace that with?
I didn't kill donkey, I saved it. Current projects: Misc Donkey hacks :) Past projects: Pacifist DKC1 DKC1 Entrance randomizer DKC2 Entrance randomizer DKDC (a troll hack of DKC1) DKC1 Enemy randomizer (among other things)
Editor
Joined: 3/31/2010
Posts: 1466
Location: Not playing Puyo Tetris
This appears to be something you may want: memory.getmemorydomainlist
When TAS does Quake 1, SDA will declare war. The Prince doth arrive he doth please.
Editor, Skilled player (1438)
Joined: 3/31/2010
Posts: 2106
RainbowSprinklez wrote:
[string domain = null]) <- what do i replace that with?
This means that "domain" is optional and will be set to null by default if you leave it out. In this case, you should be safe to just leave it out, because you set the domain earlier.
Joined: 10/2/2015
Posts: 91
thx! btw, this is the code im using: Download this.lua
Language: lua

local front = 0x056F local frontVal local xDiddySpeed = 0x0E8D local xDidSpdVal local xDiddyPosition = 0x0B1D local xDidPos memory.usememorydomain("WRAM") -- just in case while true do frontVal = memory.readbyte(front) if (frontVal == 2) then xDidSpdVal = memory.read_s16_le(xDiddySpeed) gui.text(0, 50, "Speed - "..xDidSpdVal) xDidPos = memory.read_s16_le(xDiddyPosition) gui.text(0, 65, "Position - "..xDidPos) end emu.frameadvance() end
Why wont this work??
I didn't kill donkey, I saved it. Current projects: Misc Donkey hacks :) Past projects: Pacifist DKC1 DKC1 Entrance randomizer DKC2 Entrance randomizer DKDC (a troll hack of DKC1) DKC1 Enemy randomizer (among other things)
Editor, Skilled player (1438)
Joined: 3/31/2010
Posts: 2106
RainbowSprinklez wrote:
thx! btw, this is the code im using: Download this.lua
Language: lua

Why wont this work??
I don't have a ROM of DKC handy, so I can't tell what's wrong with the script. What is the script supposed to do, and what does it do instead?
Joined: 10/2/2015
Posts: 91
well, it's supposed to display speed and position on screen. instead, it falls in an infinite loop of some sort. so something is obv wrong in my syntax/code
I didn't kill donkey, I saved it. Current projects: Misc Donkey hacks :) Past projects: Pacifist DKC1 DKC1 Entrance randomizer DKC2 Entrance randomizer DKDC (a troll hack of DKC1) DKC1 Enemy randomizer (among other things)
Editor, Skilled player (1438)
Joined: 3/31/2010
Posts: 2106
RainbowSprinklez wrote:
well, it's supposed to display speed and position on screen. instead, it falls in an infinite loop of some sort. so something is obv wrong in my syntax/code
That's weird. Trying the script on another game displays the values fine for me. The game also runs normally. I don't know what's going wrong for you.
Joined: 10/2/2015
Posts: 91
idk either! D: This sucks! I KNEW I coded it right!
I didn't kill donkey, I saved it. Current projects: Misc Donkey hacks :) Past projects: Pacifist DKC1 DKC1 Entrance randomizer DKC2 Entrance randomizer DKDC (a troll hack of DKC1) DKC1 Enemy randomizer (among other things)
Joined: 10/2/2015
Posts: 91
only thing i could think now is im using bizhawk v 1.11.4. Did something change?
I didn't kill donkey, I saved it. Current projects: Misc Donkey hacks :) Past projects: Pacifist DKC1 DKC1 Entrance randomizer DKC2 Entrance randomizer DKDC (a troll hack of DKC1) DKC1 Enemy randomizer (among other things)
Editor, Skilled player (1438)
Joined: 3/31/2010
Posts: 2106
RainbowSprinklez wrote:
only thing i could think now is im using bizhawk v 1.11.4. Did something change?
Try version 1.11.6. Sometimes bugs do sneak their way into these things.
Invariel
He/Him
Editor, Site Developer, Player (171)
Joined: 8/11/2011
Posts: 539
Location: Toronto, Ontario
Your script is working for me. Remember that it only displays that information if Diddy is the active character, not Donkey. Also, I would recommend using a colon instead of a dash to separate your text from your value, as speed goes negative when traveling left.
I am still the wizard that did it. "On my business card, I am a corporate president. In my mind, I am a game developer. But in my heart, I am a gamer." -- Satoru Iwata <scrimpy> at least I now know where every map, energy and save room in this game is
Joined: 10/2/2015
Posts: 91
ok! got it! using an updated bizhawk did the trick!
I didn't kill donkey, I saved it. Current projects: Misc Donkey hacks :) Past projects: Pacifist DKC1 DKC1 Entrance randomizer DKC2 Entrance randomizer DKDC (a troll hack of DKC1) DKC1 Enemy randomizer (among other things)
Joined: 10/2/2015
Posts: 91
i MAY have overcomplicated it and it's not pretty yet, but here is todays work! Download dkcRamWatcher.lua
Language: lua

local front = 0x056F local frontVal local xDiddySpeed = 0x0E8D local xDidSpdVal local xDiddyPosition = 0x0B1D local xDidPos local xDiddySub = 0x0DBE local xDidSub local yDiddySpeed = 0x0EF5 local yDidSpd local yDiddyPosition = 0x0FF9 local yDidPos local diddySJ = 0x16FC local didSJ local donkeySJ = 0x16FA local donSJ local status = 0x1B03 local statuss local xDonkeySpeed = 0x0E8B local xDonSpd local xDonkeyPosition = 0x0FC3 local xDonPos local xDonkeySub = 0x0DBC local xDonSub local yDonkeySpeed = 0x0EF3 local yDonSpd local yDonkeyPosition = 0x0FF7 local yDonPos memory.usememorydomain("WRAM") -- just in case while true do statuss = memory.readbyte(status) frontVal = memory.readbyte(front) didSJ = memory.readbyte(diddySJ) donSJ = memory.readbyte(donkeySJ) gui.text(120, 35, "X") gui.text(170, 35, "Y") if (frontVal == 2) then xDidSpdVal = memory.read_s16_le(xDiddySpeed) gui.text(0, 50, "Speed: "..xDidSpdVal) xDidPos = memory.read_s16_le(xDiddyPosition) gui.text(0, 65, "Position: "..xDidPos) xDidSub = memory.read_s16_le(xDiddySub) gui.text(0, 80, "SubPixels: "..xDidSub) yDidSpd = memory.read_s16_le(yDiddySpeed) gui.text(150, 50, yDidSpd) yDidPos = memory.read_s16_le(yDiddyPosition) gui.text(160, 65, yDidPos) elseif (frontVal == 1) then xDonSpd = memory.read_s16_le(xDonkeySpeed) gui.text(0, 50, "Speed: "..xDonSpd) xDonPos = memory.read_s16_le(xDonkeyPosition) gui.text(0, 65, "Position: "..xDonPos) xDonSub = memory.read_s16_le(xDonkeySub) gui.text(0, 80, "SubPixels: "..xDonSub) yDonSpd = memory.read_s16_le(yDonkeySpeed) gui.text(150, 50, yDonSpd) yDonPos = memory.read_s16_le(yDonkeyPosition) gui.text(160, 65, yDonPos) end if (statuss == 1) then if (didSJ == 0) then gui.text(0, 95, "SJ Diddy: Stored!") else gui.text(0, 95, "SJ Diddy: Not stored!") end if (donSJ == 0) then gui.text(0, 110, "SJ Donkey: Stored!") else gui.text(0,110, "SJ Donkey: Not Stored!") end else gui.text(0, 95, "SJ Diddy: Not stored!") gui.text(0,110, "SJ Donkey: Not Stored!") end emu.frameadvance() end
Also, I blame notepad++ for any formatting errors. it looks good to me!
I didn't kill donkey, I saved it. Current projects: Misc Donkey hacks :) Past projects: Pacifist DKC1 DKC1 Entrance randomizer DKC2 Entrance randomizer DKDC (a troll hack of DKC1) DKC1 Enemy randomizer (among other things)