DoomRL > Modding
Can we have tutorial on how to make a the main.lua file?
SPTX:
What we have here doesn't explain anything about the needed "run" function, for example.
It would be nice to have such things explained.
tehtmi:
"run" is a special function required "single" type levels that does what the OnCreate hook normally does for levels that are declared with register_level. For other level hooks, "single" levels can just use the corresponding module hooks since there is only one level anyway.
Typically, the "run" function will set up the map (maybe with a generator.place_tile call) and place the player (level:player(x,y)). Any other stuff is typically just as effective if it appears in the top-level scope of main.lua (or a required file).
As far as making a tutorial, we'd love to do it, but it is just a matter of finding the time, but feel free to continue asking questions.
SPTX:
--- Quote from: tehtmi on March 29, 2013, 11:27 ---"run" is a special function required "single" type levels that does what the OnCreate hook normally does for levels that are declared with register_level. For other level hooks, "single" levels can just use the corresponding module hooks since there is only one level anyway.
Typically, the "run" function will set up the map (maybe with a generator.place_tile call) and place the player (level:player(x,y)).
--- End quote ---
That's what I figured out. So I used episode instead, but it seems I have to script the whole episode myself. Isn't there a way to just call for the default one?
tehtmi:
--- Quote from: SPTX on March 29, 2013, 11:42 ---Isn't there a way to just call for the default one?
--- End quote ---
You can call DoomRL.OnCreateEpisode in the OnCreateEpisode hook to create the default episode (and use DoomRL.OnGenerate to use the default generator).
SPTX:
--- Quote from: tehtmi on March 29, 2013, 11:54 ---You can call DoomRL.OnCreateEpisode in the OnCreateEpisode hook to create the default episode (and use DoomRL.OnGenerate to use the default generator).
--- End quote ---
I tried this
--- Code: ---function SPTXContentPack.OnCreateEpisode()
DoomRL.CreateEpisode()
end
--- End code ---
But get this error : main/lua6: attempt to call field 'CreateEpisode' (a nil value)
Line 6 is "DoomRL.CreateEpisode()". Do I have to send any argument? I tried DoomRL.CreateEpisode(1) for shit and giggles, but it lend the same error.
Navigation
[0] Message Index
[#] Next page
Go to full version