Page 24 of 47
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sat Nov 28, 2015 7:36 pm
by Emral
lotus006 wrote:
Code: Select all
[code]
local banana = 1
[b]Currency[/b]:save( banana + 1 );
[b]Currency[/b]:get( banana )
[/code]
Thanks you are very good

, without your help our codes will be disastruous ^^
in talk of this, is there a way to make it dynamic like my graphic menu if I change value like a button if is true then the next time it will be staying on the same value
on the next load ?
I think it should be the same thing ? when the value is saved I can get the saved value and the button will stay true ? I mean just in an example for sure ^^
Alright first off, I JUST explained that you only need Currency:get(). There is no Currency:get(anything) in raocoin. Take a look:
http://engine.wohlnet.ru/pgewiki/Raocoin2.lua
Regarding the 2nd paragraph, I suggest using the data class
http://engine.wohlnet.ru/pgewiki/Data_%28class%29
If you want to save the player having one more powerup after collecting one, for example, you do this:
myData:set("powerupAmount", int)
myData:save()
You want int to reflect the amout of powerups the player had before collecting this new one. You can set that in the beginning of onLoop by typing:
int = myData:get("powerupAmount")
You can also store the type of powerup the player has in which position by checking how many powerups the player has, and dynamically adjusting a different data class variable:
if int == 2 then
myData:set("secondPowerup", 2) -- 2 being Powerup 2, the Fireflower or whatever you want it to be.
myData:save()
I hope this helps a bit.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sat Nov 28, 2015 7:41 pm
by lotus006
Enjl wrote:lotus006 wrote:
Code: Select all
[code]
local banana = 1
[b]Currency[/b]:save( banana + 1 );
[b]Currency[/b]:get( banana )
[/code]
Thanks you are very good

, without your help our codes will be disastruous ^^
in talk of this, is there a way to make it dynamic like my graphic menu if I change value like a button if is true then the next time it will be staying on the same value
on the next load ?
I think it should be the same thing ? when the value is saved I can get the saved value and the button will stay true ? I mean just in an example for sure ^^
Alright first off, I JUST explained that you only need Currency:get(). There is no Currency:get(anything) in raocoin. Take a look:
http://engine.wohlnet.ru/pgewiki/Raocoin2.lua
Regarding the 2nd paragraph, I suggest using the data class
http://engine.wohlnet.ru/pgewiki/Data_%28class%29
If you want to save the player having one more powerup after collecting one, for example, you do this:
myData:set("powerupAmount", int)
myData:save()
You want int to reflect the amout of powerups the player had before collecting this new one. You can set that in the beginning of onLoop by typing:
int = myData:get("powerupAmount")
stuff...
Yep thanks , I have already figured I think with what you say now to me this, but I understand more , I think Lua is very powerfull and my progress is almost done on my inv.
I just need time to polish align sprites and some small sutff,
I figurated how to make a shop system with the scores lol (without other api) and I will maybe try to make this with you can buy items and power

Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sat Nov 28, 2015 11:37 pm
by HenryRichard
I'm trying to make an API that remakes the HUD. It was all going really well until the level I was testing it in literally wouldn't open. Like, if I select it and try to open it, the open window does nothing. I can open other levels, but this one just doesn't work. I'm not totally sure, but I think it has something to do with Misc.resolveFile. Here's what I have in my LuaScriptsLib folder:
https://www.mediafire.com/?vwh7oul0qbb169w (the level is under Readme_For_hudredone.lua)
Does this happen on other machines? How can I fix it?
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sun Nov 29, 2015 12:56 am
by lotus006
I have just a question again about table, just an example about what I'm trying to attempt
local letter = {a, b, c, d, e, f, g, h, i, j }
I want to remove the value ( c ) i tried
table.remove(letter, 3)
but all the letter after ( c ) is removing.
is there a way to make the letter ( e ) and all other after to replace ( c ) ?
like this
local letter = {a, b, d, e, f, g, h, i, j }
Edit:
the table is from a loop Ok i'm not anymore with loop :S
Thanks in advance !
Edit 2 : ok I found when is in the loop when I press enter to execute the table.remove , the "enter button" make on the onInputUpdateOverride() section it make triggering to much time like when I press 1 time it press 10 times, and I dont have any loop made by me i think only by the onInputUpdateOverride(). How can I make it make press just 1 frame ?
Edit 3 : Save of quantity of the powerups in the inventory is successfull

( I mean when you leave the game and you get in the power ups his saved on a file

)
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sun Nov 29, 2015 10:44 am
by Emral
HenryRichard wrote:I'm trying to make an API that remakes the HUD. It was all going really well until the level I was testing it in literally wouldn't open. Like, if I select it and try to open it, the open window does nothing. I can open other levels, but this one just doesn't work. I'm not totally sure, but I think it has something to do with Misc.resolveFile. Here's what I have in my LuaScriptsLib folder:
https://www.mediafire.com/?vwh7oul0qbb169w (the level is under Readme_For_hudredone.lua)
Does this happen on other machines? How can I fix it?
I had that happen with a HUD I made, too. It's Misc.resolveFile's fault, you should try doing without it.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sun Nov 29, 2015 2:40 pm
by Kevsoft
Misc.resolveFile was a bit broken, so I did some fixup... You may want to try out the
nightly dev-build.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Tue Dec 01, 2015 8:39 am
by Hoeloe
Enjl wrote:Let me run over this, I marked the areas which are faulty or weird to me in the quote. Keep in mind that I never used raocoin.
SuperMario12345 wrote:local coins = Graphics.loadImage("coincounter.png") -- Do you want "coins" to be the image file, or the registered currency (further down)?
local raocoin = true
raocoin = loadSharedAPI("raocoin2"); -- What are you trying to accomplish in these lines? You're setting the variable you just set to "true" to hold the raocoin API
rc = raocoin.registerCurrency(274, true, 472, 66); -- You're registering ID 274, but further down you're calling for 272
coins = raocoin.registerMemCurrency(0x00B2C5A8,FIELD_WORD,true,false,0,0,"coincounter.png"); -- This overwrites "coins" set in the first line. I'd just get rid of the first line altogether.
function raocoin.onCollect()
if(currency.id == 272) then --SMB2 Hoopster || EVERYTHING IS CASE SENSITIVE BY THE WAY
Currency:get(1) --From looking at the wiki, this will return the value of the currency. With Currency.get() you can store the value of the currency in a variable. An example: local stuff = Currency:get()
currency:save(1); --There is no such thing as Currency:save(1). It's just Currency:save() and saves the currency value set with Currency:set(number)
end
end
Want to add to this that the definition of "onCollect" is wrong. If you look on the documentation, you'll see that the function has 3 arguments. Just like when you define functions like "onEvent", you need to define these arguments. As it is, Currency:get() etc. is not valid, because "Currency" doesn't exist as an object.
Instead of this:
You should use this:
Code: Select all
function raocoin.onCollect(currency, increment, npc)
This will define the "currency" variable (note the lowercase C), which marks the currency object you just collected something from. The "increment" variable marks the amount the currency is increasing by, and "npc" holds the NPC object you just collected (or nil if the currency is a mem currency).
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 02, 2015 6:39 pm
by Kyoya
Question, unrelated to the currency system, I'm trying to build a custom HUD similar to SMB1 and I wanted to keep the option open for the player to have a secondary power up but there is a problem with that, there is no memory code for the item box. I tried using the "pc+" code and it crashed the whole game.
So is there any way to use the item box? I don't mean make it usable I mean display the current powerup as a sprite placed in a specified area. I know how to place the sprite but obtaining information for what power up is in the item box appears to be unknown.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 02, 2015 6:49 pm
by Emral
Kyoya wrote:Question, unrelated to the currency system, I'm trying to build a custom HUD similar to SMB1 and I wanted to keep the option open for the player to have a secondary power up but there is a problem with that, there is no memory code for the item box. I tried using the "pc+" code and it crashed the whole game.
So is there any way to use the item box? I don't mean make it usable I mean display the current powerup as a sprite placed in a specified area. I know how to place the sprite but obtaining information for what power up is in the item box appears to be unknown.
0x158

Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 02, 2015 7:18 pm
by TheSaturnyoshi
Hello everyone!
This is my first post, so sorry if it's in the wrong place.
Anyways, I downloaded LunaLua earlier today and I made my first thing in it a while ago, but there is this strange issue, whenever I exit level testing in any way (ESC, die) an error message pops up saying "Invalid Player-Pointer" this doesn't pop up when I start testing like other errors and it doesn't seem to effect how the code runs.
Here's the code;
Code: Select all
PreviousPowerup=PLAYER_SMALL
PreviousPlayerY=player.y
DoTurnBig=false
function onLoop()
if player.powerup == PLAYER_SMALL then
if PreviousPowerup ~= PLAYER_SMALL and PreviousPowerup ~= PLAYER_BIG then
DoTurnBig=true;
end
end
if DoTurnBig then
player.powerup = PLAYER_BIG;
player.y=PreviousPlayerY
if player:mem(0x140, FIELD_WORD) == 150 then
DoTurnBig=false
player.y = player.y+24;
end
end
printText ( player:mem(0x140, FIELD_WORD), 4, 5, 475)
printText ( DoTurnBig, 4, 5, 500)
printText ( PreviousPowerup, 4, 5, 525)
PreviousPowerup=player.powerup
PreviousPlayerY=player.y
end
(I'm also using the timer API but I removed that)
Anyways, the code makes getting hit more like SMB3, so if you get hit and you have a powerup better than the super mushroom, you go back to being big rather than small.
Thanks in advance!
EDIT: Sorry if the code is sloppy, I know nothing about lua ^^;
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 02, 2015 7:28 pm
by Emral
You're trying to define player values outside of functions. These are also checked when the level is loaded in the editor. When you're in the editor, no player exists, and therefore the pointer is invalid.
You can circumvent this by replacing the first three lines with this:
Code: Select all
local PreviousPowerup
local PreviousPlayerY
local DoTurnBig = false
function onLoad()
if player.isValid then
PreviousPowerup = PLAYER_SMALL
PreviousPlayerY = player.y
end
end
What I'm essentially doing is a check for whether the player exists, and only set the initial variables if he does.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 02, 2015 7:36 pm
by TheSaturnyoshi
That makes sense, thank you! Works perfectly!
(Very quick response, too!)
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 02, 2015 8:09 pm
by Kyoya
Enjl wrote:Kyoya wrote:Question, unrelated to the currency system, I'm trying to build a custom HUD similar to SMB1 and I wanted to keep the option open for the player to have a secondary power up but there is a problem with that, there is no memory code for the item box. I tried using the "pc+" code and it crashed the whole game.
So is there any way to use the item box? I don't mean make it usable I mean display the current powerup as a sprite placed in a specified area. I know how to place the sprite but obtaining information for what power up is in the item box appears to be unknown.
0x158

Yes and storing the code required there caused the whole game to crash as I just said.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 02, 2015 8:12 pm
by Emral
Kyoya wrote:
Yes and storing the code required there caused the whole game to crash as I just said.
What you said is that you used the PC+ code. Did you actually type
Code: Select all
player:mem(PC+0x158, FIELD_WORD, itemid)
or type
Code: Select all
player:mem(0x158, FIELD_WORD, itemid)
Cause only the latter will work. Your first post wasn't very clear about this, and this is probably your problem. I just tested it. It works fine for me. Here's some code I used to put a goomba into my reserve item box:
Code: Select all
function onLoad()
if player.isValid then
player:mem(0x158, FIELD_WORD, 1)
end
end
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Dec 02, 2015 9:45 pm
by Kyoya
Thank you... I used the first way and it killed it all.
Question now is, is there a quick way of telling what value each power up has? Or do I go to test ever single one to get the values using Text.print?
Edit: didn't help, I think u misunderstood I dont want to assign the reserve item I want to obtain the value of the reserve item box with the item in it so I can display the item on screen.
Sort of like (I know this isn't code):
reservedItemBox = Code for the item box contents in memory.
if reservedItemBox = 0
end
if reservedItemBox = the value for mushroom
place a mushroom sprite on the screen at a certain point
end
^ Get it?
I try to use the memory code and it causes it to crash when I try to capture the value.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Thu Dec 03, 2015 6:50 am
by Kevsoft
I just want to note, that onStart is currently in the dev-version and not in the current released one yet.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Thu Dec 03, 2015 6:57 am
by Emral
Yeah, I know about onStart, but I used the onLoad code as an example because of what Kevsoft just said.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sat Dec 05, 2015 10:54 am
by Mable
When i downloaded the a2xt lunalua one. Is it normal for the furba to do the moonwalk?
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sat Dec 05, 2015 7:21 pm
by TheSaturnyoshi
That's because the Furbas replace Goombas, so they need the npc-.txt to animate properly.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Tue Dec 08, 2015 11:23 pm
by HenryRichard
So I'm trying to make this really cool x Bro api where you can have multiple different kinds of bros in a level (hammer bros, goomba bros, and rinka bros in this code). The functionality is there (type what you want them to throw in the message box, disable friendly, and they throw it), but I'd like to give them all different graphics (because I have a feeling that some people will be annoyed when enemies that look the same throw different things). I've tried setting v.animationFrame, but that's not working the way I want. Here's my code:
Code: Select all
function onLoop()
for k, v in pairs(NPC.get(29, -1)) do
if(not v.friendly) then
if(v.msg.str ~= "") then
if(v.msg.str == "goomba") then
v.ai4 = 1;
v.ai5 = 89;
elseif(v.msg.str == "rinka") then
v.ai4 = 2;
v.ai5 = 210;
end
v.msg = "";
end
v.animationFrame = v.animationFrame + 6 * v.ai4;
for k,v1 in pairs(NPC.getIntersecting(v.x, v.y, v.x + v.width, v.y + v.height)) do
if(v1.id == 30 and v1.ai1 == 0) then
if(v.ai4 == 0) then
v1.ai1 = 1;
else
v1.id = v.ai5;
end
end
end
end
end
end