LunaLUA: Player:mem error

Description: Archive discussion
============================
Original description:
Official subforum for LunaLua - an extension framework for SMBX Engine Version 1.3 (which a core of SMBX 2.0). Share your creations that require the use of LunaLUA. You may also share info/tutorials on how to use LunaLUA.

Sambo M
Topic author, Count
Count
Avatar
Sambo M
Topic author, Count
Count
Age: 25
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #1by Sambo » 3 Jan 2015, 0:36

When I try to use the Player:mem function, it just returns an error: "No static 'mem' in class 'Player'"
Here's the code that caused the error:

Code: Select all

printText(Player:mem(0x158, FIELD_WORD).. "", 384, 30)

It is supposed to show the value of the player memory for the reserve powerup. It might seem pointless, but it's just for testing purposes.
Image
Current Project:
Image

Kevsoft M
Angry developer
Angry developer
Avatar
Kevsoft M
Angry developer
Angry developer
Age: 24
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #2by Kevsoft » 3 Jan 2015, 1:21

just a small fix: the instance of the Player class is called "player" (with lower letters)... also you might need to convert the value to a string... so the corrected code should be:

Code: Select all

printText(tostring(player:mem(0x158, FIELD_WORD)).. "", 384, 30)
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

Sambo M
Topic author, Count
Count
Avatar
Sambo M
Topic author, Count
Count
Age: 25
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #3by Sambo » 3 Jan 2015, 23:10

I did other codes without the tostring function, and it works because the .. "" at the end converts the value to a string. You can test this code in the lua.exe to see it works:

Code: Select all

> print(10 .. "") == "10"

If the class "player" is all lowercase, you may want to fix that in the wiki, as it's capitalized there.
Image
Current Project:
Image

Kevsoft M
Angry developer
Angry developer
Avatar
Kevsoft M
Angry developer
Angry developer
Age: 24
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #4by Kevsoft » 4 Jan 2015, 0:18

Sambo wrote:If the class "player" is all lowercase, you may want to fix that in the wiki, as it's capitalized there.
The player class IS right. The class is called "Player" with the constructor "Player(int playerID)" BUT there are two pre-defined player object called "player" and "player2" See here: http://wohlsoft.ru/pgewiki/LunaLua_constants.

I also did write in constructor description the following note:
pgewiki wrote:You might want to use the constants player and player2 (for the 2nd player) instead.
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

Sambo M
Topic author, Count
Count
Avatar
Sambo M
Topic author, Count
Count
Age: 25
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #5by Sambo » 4 Jan 2015, 1:27

Oh, ok. Well, thanks for the help. My problem has been fixed, so you can lock this now.
Image
Current Project:
Image


Return to “LunaLua - Extension Framework”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest