Getting
classes/newTileMap.lua:9: attempt to call a nil value
stack traceback:
classes/newTileMap.lua:9: in function 'init'
[string "property.lua"]:59: in function '__new'
[string "property.lua"]:66: in function 'new'
classes/TileMap.lua:35: in function 'init'
[string "property.lua"]:59: in function '__new'
[string "property.lua"]:66: in function 'new'
classes/ScenePlay.lua:19: in function 'init'
[string "property.lua"]:59: in function '__new'
[string "property.lua"]:66: in function 'new'
classes/scenemanager.lua:287: in function 'changeScene'
classes/SceneLobby.lua:35: in function
classes/Button.lua:54: in function |
I looked at a
previous thread, but the solution isn't fully clear to me. Not sure how to structure this so it properly packs on export.
Line 9 is
map = loadfile("level1.lua")() |
level1.lua is a file generated by tiled. I tried to mark it "exclude from execution" or not, neither worked. It seems to be part of the export as the log says
How am I supposed to this this?
level1.lua starts like this, basically returning a big structure. It's a straight Export As Lua from tiled, and Gideros wouldn't really manage the file except for packing it up. It does work on the local player.
return {
version = "1.2",
luaversion = "5.1",
tiledversion = "1.3.4",
orientation = "orthogonal",
renderorder = "right-down",
width = 36,
height = 36,
tilewidth = 100,
tileheight = 100,
nextlayerid = 4,
nextobjectid = 1,
properties = {
["Title"] = "Bushido Battle Level 1"
},
tilesets = {
{
name = "Bushido",
firstgid = 1,
tilewidth = 100,
tileheight = 100,
spacing = 0, |
Comments
As you wrote, I only exclude the tiled.lua from execution.
A wild guess, is your path to your tiled.lua file correct?
Is your tiled.lua file in the assets folder?
Example: self.tiledlevel = loadfile("tiled/level01.lua")()
PS: an easy way to insert any files into your code is right click the file and choose insert into document
What you see is selection bias on what I post in the forums :-) Also, I am exporting pretty trivial games, but the export is still the same high complexity.
I have lots of issues beyond exporting. I just don't bother the forums, because I can generally figure things out. Much of my other problems have been worked through years ago by others, many have sample code, and many are more straight-forward to debug. It's slow going, but I can all do it on one machine, within the tool. It's actually pretty awesome. I spent 2 days getting my tiled import to work because I create my own texture maps from scratch, and couldn't get any of the demo projects to work and eventually rewrote it from scratch (learning from the demo projects), and 2h of it were lost because I didn't have a self:addChild(tilemap) at the end of my init() code. But it's doable and I learn Lua and Gideros. Persistence leads to outcomes here.
The export issues are trickier as they are often not documented, not well discussed in the forums, and very configuration dependent. I don't fully understand the HTML export and player magic, and I am only slowly figuring out how to debug it. I don't fully understand what "exclude from execution" actually means. Is is still packed? Does it go into the same directory? Which directory does it go into anyway? What is the asset folder, and why do some files in some demos end up in there, and others don't. Much of that works in the IDE and the local player, but on export, stuff happens. It doesn't help that the export files are all packed into an archive that I haven't figured out yet how to peek into. The problem here is that once I try every combination of options, or many of them, I don't know how to proceed to unstuck.
For example, I failed at directly creating APKs from Gideros, I have to go through Android Studio. That is suboptimal, and ads time, and lots of manual patching of the exported files, but I have a working solution, so not bothering the forums either with that one, not until I understand better. I may try again in a month or two.
Also, don't get me wrong. The fact that these exports mostly work is pretty awesome by itself.
Don't get me started about getting Google Play Console to publish anything, or dealing with Android in general.
Likes: antix
I'll have to figure out where to put all the other files and a workflow with tiled, but that's for tomorrow.
About player vs export differences, there are few well known ones:
- in the player, files are uploaded independently, and neither encrypted nor compiled. During export lua files are compiled, merged together (unless excluded from execution), and then encrypted (if required)
- in the prebuilt desktop player, all plugins are available even if not selected in the project. On export only those selected are actually exported
- on windows, file names are not case sensitive, but they are on most other platforms
About the 'exclude from execution': in Gideros all lua files are read and executed by default, you don't need to 'require' them, and if you do those files will be parsed twice. To tell Gideros that a particular file shouldn't be read and executed by default, you "exclude (it) from execution". During export, and unlike on the player, files meant to be executed on start are merged together in a single, compiled main.lua file. This shouldn't cause any trouble since they are not expected to be require'ed or loaded from some other lua code. Gideros 2020.4 will have an option to only load main.lua by default.
Now about the assets folder: this is a relatively new addition. Gideros used to have a virtual file hierarchy, in which all files were just links to real files anywhere on your hard drive. This was inconvenient when working with versionning systems, archiving projects and other related stuff. Gideros now has an assets folder that is synchronized with the studio's file view. If you create files from the studio, they go in that folder. If you add files externally into this folder, then they will appear in the studio on next 'Refresh'. Links still exists though, they are marked with a little 'chain' icon in the studio.
Likes: MoKaLux
My workflow is:
- put all your files in the assets folder
- I put my tileset in a separate folder
- then in the Tiled lua file I remove the ../ I would be interested in that code
Congrats for your game. Don't be shy to show your work: https://www.perrochon.com/BushidoBattlePreCompress/
PS: a little self promotion: I built the tileset with my program https://mokalux.itch.io/onetiletotileset made with gideros Hope you are on windows
A better URL for a sneak peak at the game is the WIP version at https://www.perrochon.com/BushidoBattle/ which has the tiled map. It's always work in progress, e.g. as of this writing, the damage circles no longer work while I am refactoring the layers code. I also have an Android internal release, PM me if you want to get on the testers list. The game is so basic, you won't spend more than 5 minutes until you are bored :-)
Thanks @hgy29 for the explanation. I was speculating something along the lines as I did notice the little link items. I was slowly reverse engineering it :-) I do like the way it is (I think :-) )
@MoKaLux I remove the "tiles/" like this when I read the tiled generated level.lua file
Full code
Likes: MoKaLux