I'm running into some bugs with the sound mixer. The first one is that sounds set to loop indefinitely keep looping after the player dies and the level reloads. If you quit and start a new game without restarting the program, those sound channels might not play sound at all. Fortunately you can set an expire time on the channel to avoid this; give it, say, 100 ms and refresh it on camera update.
The second one is caused by the fade-in settings. The channels can get stuck on a low volume when the player dies and the level reloads during fade-in.
Ness-Wednesday wrote:I want Wart to shoot a dozen of npcs, but when I tried this:
Code: Select all
function onLoop()
for k,v in pairs(NPC.get(15,player.section)) do
npca = ownRNG.randomInt(0, 1000)
if(npca < 100) then
tableofdath[m]:mem(0xE2, FIELD_WORD, 30)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 210)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 202)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 134)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 282)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 87)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 27)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 7)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 153)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 246)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 259)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 12)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 17)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 40)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 45)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 48)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 85)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 133)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 137)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 166)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 179)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 206)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 230)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 269)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 276)
tableofdath[m].height = 32
else
tableofdath[m]:mem(0xE2, FIELD_WORD, 286)
tableofdath[m].height = 32
end
end
end
I got an error stating that end expected (to close to if at line 7) near else.
I tried to put ends, but it doesn't work.
Any ideas?
You can't put a bunch of else's in a row like that, you have to use elseif with a condition for each one. It would be more efficient to do something like:
Code: Select all
local wartNPCids = {30,210,202,134,282,87,27,7,153,246,259,12,17,40,45,48,85,133,137,166,179,206,230,269,276,286}
local wartNPCheights = {32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32} --change these to the actual heights of the npcs
npca = ownRNG.randomInt(1, 26)
tableofdath[m]:mem(0xE2, FIELD_WORD, wartNPCids[npca] )
tableofdath[m].height = wartNPCheights[npca]
I don't understand what you're trying to do, because you're grabbing every npc-15 (boom boom) in the player's section and then trying to modify the unrelated tableofdath[m] for each one.