This is the place for discussion and support for LunaLua and related modifications and libraries.
Moderator: Userbase Moderators
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
|
|
|
|
-
lotus006
- Spike

- Posts: 284
- Joined: Thu Sep 24, 2015 12:59 am
Postby lotus006 » Wed Mar 23, 2016 11:13 pm
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 should post the entire code because there is a end who is not supposed to be here probably
|
|
|
|
|
|
|
|
|
-
Ness-Wednesday
- Purple Yoshi Egg

- Posts: 1660
- Joined: Sun Jun 28, 2015 3:50 pm
- Flair: Diverse Scouts
- Pronouns: He/Him
Postby Ness-Wednesday » Wed Mar 23, 2016 11:24 pm
lotus006 wrote:
You should post the entire code because there is a end who is not supposed to be here probably
That was the entire code.
I tried to move one of them, but I get the same error.
|
|
|
|
|
|
|
|
|
-
Quantumenace
- Chain Chomp

- Posts: 308
- Joined: Mon Dec 28, 2015 2:17 am
Postby Quantumenace » Wed Mar 23, 2016 11:37 pm
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.
|
|
|
|
|
|
|
|
|
-
lotus006
- Spike

- Posts: 284
- Joined: Thu Sep 24, 2015 12:59 am
Postby lotus006 » Wed Mar 23, 2016 11:37 pm
Ness-Wednesday wrote:lotus006 wrote:
You should post the entire code because there is a end who is not supposed to be here probably
That was the entire code.
I tried to move one of them, but I get the same error.
but what is define the [m] ?
in this :
|
|
|
|
|
|
|
|
|
-
Ness-Wednesday
- Purple Yoshi Egg

- Posts: 1660
- Joined: Sun Jun 28, 2015 3:50 pm
- Flair: Diverse Scouts
- Pronouns: He/Him
Postby Ness-Wednesday » Thu Mar 24, 2016 8:28 am
Changed it to this:
Code: Select all local npca = 0
local ownRNG = loadAPI("rng")
function onLoop()
for k,v in pairs(NPC.get(202,player.section)) do
npca = ownRNG.randomInt(0, 2000)
if(npca < 800) then
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]
end
end
end
It says that attempt to index global 'tableofdath' (a nil value), is there supposed to be a define here?
If there is, I don't think I had one.
|
|
|
|
|
|
|
|
|
-
underFlo
- Wart

- Posts: 4456
- Joined: Mon Jul 14, 2014 10:44 am
- Flair: sup im lesbiab
- Pronouns: They/She
-
Contact:
Postby underFlo » Thu Mar 24, 2016 8:37 am
You need to define tableofdeath as a table first, so just put
at the start
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Thu Mar 24, 2016 8:54 am
Ness-Wednesday wrote:Changed it to this:
Code: Select all local npca = 0
local ownRNG = loadAPI("rng")
function onLoop()
for k,v in pairs(NPC.get(202,player.section)) do
npca = ownRNG.randomInt(0, 2000)
if(npca < 800) then
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]
end
end
end
It says that attempt to index global 'tableofdath' (a nil value), is there supposed to be a define here?
If there is, I don't think I had one.
I suggest before you ask for any more help here you check out all the tutorials on the wiki and some basic ones about lua coding. It looks to me as if you have no idea what you're doing and asking us to write your code bit by bit isn't gonna get you anywhere in terms of coding experience. It just makes you look like a lazy leech.
|
|
|
|
|
|
|
|
|
-
Ness-Wednesday
- Purple Yoshi Egg

- Posts: 1660
- Joined: Sun Jun 28, 2015 3:50 pm
- Flair: Diverse Scouts
- Pronouns: He/Him
Postby Ness-Wednesday » Thu Mar 24, 2016 5:02 pm
Enjl wrote:
I suggest before you ask for any more help here you check out all the tutorials on the wiki and some basic ones about lua coding. It looks to me as if you have no idea what you're doing and asking us to write your code bit by bit isn't gonna get you anywhere in terms of coding experience. It just makes you look like a lazy leech.
Tbh, I didn't really mean it like that.
I didn't want anyone to write my code, I was just wondering what was wrong.
But I'll accept your suggestion, and will try to read the PGE wiki and learn about Lunalua more.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Thu Mar 24, 2016 5:07 pm
Ness-Wednesday wrote:Enjl wrote:
I suggest before you ask for any more help here you check out all the tutorials on the wiki and some basic ones about lua coding. It looks to me as if you have no idea what you're doing and asking us to write your code bit by bit isn't gonna get you anywhere in terms of coding experience. It just makes you look like a lazy leech.
Tbh, I didn't really mean it like that.
I didn't want anyone to write my code, I was just wondering what was wrong.
But I'll accept your suggestion, and will try to read the PGE wiki and learn about Lunalua more.
The problems you were having were that your code made absolutely no sense and you had no idea what you are doing. Reporting a bug here, getting a response and reporting the next one right after will barely teach you anything and only lead to your code being slowly constructed by people nice enough to help you out.
|
|
|
|
|
|
|
|
|
-
HenryRichard
- Reznor

- Posts: 2843
- Joined: Mon Dec 23, 2013 12:09 pm
- Flair: Is this where I type my password?
-
Contact:
Postby HenryRichard » Fri Mar 25, 2016 12:44 am
So has there been any breakthrough in the past year that I missed that allows you to make clones of the player other than triggering cheats?
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Fri Mar 25, 2016 1:32 pm
I'm consistently getting an error along the lines of "indexing storedchallengedata results in nil", but I don't understand why that's happening. If you see any other errors please say so as well
Lunaworld.lua:
Code: Select all local encrypt = API.load("encrypt")
_G["Borderlands"] = encrypt.Data(Data.DATA_WORLD, "storedchallengedata", true)
function onStart()
if storedchallengedata:get("gameover") == nil then
storedchallengedata:set("gameover", 0)
storedchallengedata:set("wincounter", 0)
storedchallengedata:save()
end
if Level.filename() == "Intro" and storedchallengedata:get("gameover") == 1 then
storedchallengedata:set("gameover", 0)
mem(0x00B251E0,FIELD_WORD,0)
x = tonumber(storedchallengedata:get("wincounter"))
storedchallengedata:set("wincounter", x + 1)
storedchallengedata:save()
end
end
function onInputUpdate()
if Level.filename() == "AA001.lvl" or "AB001.lvl" or "This Hub Has Moving Layers.lvl" or "Intro.lvl" then
if player.altJumpKeyPressing then
player.altJumpKeyPressing = false
player.jumpKeyPressing = true
end
end
end
function onTick()
if mem(0x00B251E0,FIELD_WORD) == 8 then
storedchallengedata:set("gameover", 1)
storedchallengedata:save()
end
end
Lunadll.lua
Code: Select all mem(0x00B2C5AC,FIELD_FLOAT,50)
local goldmedal = Graphics.loadImage("gold-medal.png")
function onDraw()
if storedchallengedata:get("wincounter") > 0 then
w = tonumber(storedchallengedata:get("wincounter"))
if w ~= 1 then
w = w*42
end
Graphics.drawImageWP(goldmedal, w, 0, 5)
end
end
|
|
|
|
|
|
|
|
|
-
HenryRichard
- Reznor

- Posts: 2843
- Joined: Mon Dec 23, 2013 12:09 pm
- Flair: Is this where I type my password?
-
Contact:
Postby HenryRichard » Fri Mar 25, 2016 1:39 pm
You're calling your variable Borderlands instead of storedchallengedata.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Fri Mar 25, 2016 3:39 pm
HenryRichard wrote:You're calling your variable Borderlands instead of storedchallengedata.
Oh. That would do it
|
|
|
|
|
|
|
|
|
-
zlaker
- Reznor

- Posts: 2844
- Joined: Fri Dec 20, 2013 1:46 pm
Postby zlaker » Fri Mar 25, 2016 4:57 pm
So I'm trying place a certain image on my SMBX screen and some text, but whenever I try display the text and the image at the same time, the image won't show up. But if I try to display the image without the text in code the image will show up for some reason.
Code: Select all local slackCounter = 100;
local dummyCounter = 2
img = Graphics.loadImage("meter4.png")
Graphics.placeSprite(1, img, 435, 17)
function onLoop()
Text.print(dummyCounter,0,0)
Text.print(slackCounter,435,97)
end
Is there a way to fix this?
|
|
|
|
|
|
|
|
|
-
HenryRichard
- Reznor

- Posts: 2843
- Joined: Mon Dec 23, 2013 12:09 pm
- Flair: Is this where I type my password?
-
Contact:
Postby HenryRichard » Fri Mar 25, 2016 5:17 pm
I wouldn't recommend placeSprite. Try using Graphics.drawImage.
(and while I'm really not sure why you should probably use onTick because it's apparently better)
|
|
|
|
|
|
|
|
|
-
zlaker
- Reznor

- Posts: 2844
- Joined: Fri Dec 20, 2013 1:46 pm
Postby zlaker » Fri Mar 25, 2016 6:02 pm
HenryRichard wrote:I wouldn't recommend placeSprite. Try using Graphics.drawImage.
(and while I'm really not sure why you should probably use onTick because it's apparently better)
Now I get this message though :V
Here's the code, again.
Code: Select all local slackCounter = 100;
local dummyCounter = 2
img = Graphics.loadImage("meter4.png")
Graphics.drawImage(1, img, 435, 17)
function onTick()
Text.print(dummyCounter,0,0)
Text.print(slackCounter,435,97)
end
|
|
|
|
|
|
|
|
|
-
HenryRichard
- Reznor

- Posts: 2843
- Joined: Mon Dec 23, 2013 12:09 pm
- Flair: Is this where I type my password?
-
Contact:
Postby HenryRichard » Fri Mar 25, 2016 6:10 pm
Erm... that's not how it works.
You would do it like this:
Code: Select all local slackCounter = 100;
local dummyCounter = 2
img = Graphics.loadImage("meter4.png")
function onTick()
Graphics.drawImage(img, 435, 17)
Text.print(dummyCounter,0,0)
Text.print(slackCounter,435,97)
end
|
|
|
|
|
|
|
|
|
-
timocomsmbx2345
- Foo

- Posts: 853
- Joined: Sat Feb 06, 2016 1:44 pm
-
Contact:
Postby timocomsmbx2345 » Sun Mar 27, 2016 7:28 pm
Oh yeah, how do get a hammer bro to throw random things?
|
|
|
|
|
|
|
|
|
-
Valtteri
- Birdo

- Posts: 2150
- Joined: Sun Dec 01, 2013 1:16 pm
Postby Valtteri » Sun Mar 27, 2016 7:53 pm
timocomsmbx2345 wrote:Oh yeah, how do get a hammer bro to throw random things?
Questions about LunaLua should be posted in the LunaLua help topic. I have moved your post. Furthermore, please don't post many times in a row but edit your post instead or at least wait for someone to respond first.
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 2 guests
|