Difference between revisions of "FAQ Lua Errors"

From Moondust Wiki
Jump to navigation Jump to search
(Created page with "This page should help developers to fix their lua errors. ==Runtime Errors== ==='''No static 'something' in class 'Player''''=== This happens if you use the Player-class rath...")
 
m
 
Line 31: Line 31:
...
...
local frame = 5
local frame = 5
printText("Hello " + frame, 10, 100)
Text.print("Hello " + frame, 10, 100)
...
...
</syntaxhighlight>
</syntaxhighlight>
Line 39: Line 39:
...
...
local frame = 5
local frame = 5
printText("Hello "..frame, 10, 100)
Text.print("Hello "..frame, 10, 100)
...
...
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 11:55, 27 January 2018

This page should help developers to fix their lua errors.

Runtime Errors

No static 'something' in class 'Player'

This happens if you use the Player-class rather than the player-object.
Wrong:

...
Player.x = 5
...


Right:

...
player.x = 5
...

or create your own Player-object:

myPlayer = Player()
...
myPlayer.x = 5
...

Attempt to perform arithmetic on a string value

This is probably one of the most beginner mistakes. Concating two string is done with ".." instead of "+".
Wrong:

...
local frame = 5
Text.print("Hello " + frame, 10, 100)
...


Right:

...
local frame = 5
Text.print("Hello "..frame, 10, 100)
...