[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4771: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3906)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4773: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3906)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4774: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3906)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4775: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3906)
Skyline Forums • View topic - main.lua or equivalent
Help with your scripting

main.lua or equivalent

main.lua or equivalent

Postby epsilonion » 10 Jul 2015, 22:53

Hi guys, I have been looking at one of my old projects that i did when I used to use l**dw**ks and was wondering.....

In the above software there is a main lua file that your main script goes in and as a result you only have to write the main menu/pause menu etc once and it calls each level/scene from there.

Is there a similar way to do that or do I have to write the menus etc etc into each and every scene?

I am a little confused on this point.
Skyline Help:

User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: main.lua or equivalent

Postby Shando » 11 Jul 2015, 01:04

Hey buddy,

AFAIK there is no main.lua file, though I could be wrong ;)

I would actually create a separate Menu Scene, and call that when you need it by swapping Scenes (you can always use Global Variables, or an XML/JSON/Text file to recreate any variables that you need to retain - hopefully inbuilt XML/JSON support will be coming soon).

So, you would call your Scenes something like this:

Menu -> Scene1 -> Menu -> Scene2 -> Menu etc.

HTH

Shando

PS: There are also the prebuilt Game State options (GameStart, GamePause, GameOver, GameWin, plus 10 User States) which are detailed in the Scripting Docs - . So, you could use these and have different Menus depending on which State is currently selected?
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: main.lua or equivalent

Postby epsilonion » 11 Jul 2015, 03:10

I have never used states before, I take it I would have to recreate them in each scene.

It confuses the hell out of me tbh..

for instance in each scene when calling the mainmenu state it would load the main menu scene, upon exiting the scene making the call you would then save a file with all the data you require such as player stats, position, scene name (for reloading maybe) etc etc..

Maybe do the same for a ingame pause menu....
Skyline Help:

User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: main.lua or equivalent

Postby Shando » 11 Jul 2015, 03:23

Unfortunately, I haven't got time right now to write up a tutorial, but take a look at the resources below and they should help you:

This one is specifically related to Game Programming and seems to be relatively easy to understand (it relates to JavaScript, but don't get put off by that as the principles are the same):



This one is a bit more in-depth and specifically relates to combat design in games:



Hope these help??

If not, post back and I'll see if I can put together a quick tutorial on how they work in Skyline.

Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: main.lua or equivalent

Postby epsilonion » 11 Jul 2015, 11:24

aahhh, its quite streight forward really.

so for a simple menu > play > menu > quit would I have to copy that into every scene? and use global variables to pass the required info across?

I thought it would have been easier to write it into one file.
Skyline Help:

User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: main.lua or equivalent

Postby SolarPortal » 11 Jul 2015, 14:51

For a starting screen with new game, continue, load, quit, options etc.... i tend to make this in its own scene. Then when a button is clicked like new, continue or load; load into another scene.

When you are running in the level though, you cant always load back into the main menu scene to change a setting or save, load a game. This would be more like a pause screen which offers you to save, load, quit to main menu, quit to desktop.

For this i would also use the state system and change the state to the paused state when the p key is pressed and stop all gameplay and load the menu gui. Considering that a pause or main game menu is simply a cheap GUI, it isn't too much work.

Use the scene script per scene to setup the game level menus etc.. easier for copying and pasting or simply save a template scene off and place into the template directory for it too show up on the start screen window, or load from the "File Menu > New from template" and there is also the option of adding all the code into an external script and load everything for the menu at the top of the scene script by including the menu file. Use sky.include("myfile.lua");



Twitter:
Instagram:
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: main.lua or equivalent

Postby epsilonion » 21 Jul 2015, 19:44

Skyline Help:

User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: main.lua or equivalent

Postby SolarPortal » 21 Jul 2015, 19:47

can you send me the files as that error message looks really wrong. It could be a code error in the engine.



Twitter:
Instagram:
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: main.lua or equivalent

Postby epsilonion » 21 Jul 2015, 23:55

Will take a while I am on Mobile.. :D

It seems to be when trying to switch a to a different workspace on the GUI you can load one but it will not load another one.

the error persists after you try to load one scene file (menu) and load another scene file that contains a menu when in this case I load the main menu that has the workspace mainmenu and click on start game the level 1 scene loads but when I press the P key is when the error starts to show then no menu can be loaded only the one from the main menu.

I can load the level 1 scene file and play it in the player and it works but switching from the pause menu to the main menu causes the same error but this time the level 1 menu is the only one that can be loaded. (level 1 menu has the workspace of Pausemenu)

Even when creating a new scene and new menu it can not be loaded and the error persists, the only way to reset it so there is no error is to exit out of skyline and restart.
Skyline Help:

User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: main.lua or equivalent

Postby epsilonion » 22 Jul 2015, 00:10

OK heres the project directory;

Included scenes are:
MainMenu -- This is the main menu
Level 1 -- This is a template scene that will be used for all levels.

They can be run independent of each other but when you load one from the other or visa versa only the menu that was loaded first can be used.

MainMenu uses Mainmenu\ workspace
Level 1 uses PauseMenu\ Workspace

Once you get the error and it refuses to load the later menu it can only be run by using the player (game pad icon on the editor) and takes a reset of the editor to get to run them both independently again.

Well thats as far as I have gotten at the moment...

I have banged my head on the well for hours on this one... :)
Attachments
Game.zip
Menu
(4.4 MiB) Downloaded 1325 times
Skyline Help:

User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: main.lua or equivalent

Postby SolarPortal » 22 Jul 2015, 10:31

looking into this now :)

Edit: I believe these errors are appearing because you are building a project game. We haven't tested projects in some time so it will be good to fix this.



Twitter:
Instagram:
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: main.lua or equivalent

Postby SolarPortal » 22 Jul 2015, 13:09

Fixed: There was an error in code. What happened was when loading the second scene the Filepath structure got messedup. This is due to the fact that we have never loaded between scenes in a project and needed to reference path stuff. Only in the asset library have we done this.

It will now work on the next update :) Thanks again for finding this.



Twitter:
Instagram:
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: main.lua or equivalent

Postby epsilonion » 22 Jul 2015, 15:16

No problems will keep working on the menu system..
Skyline Help:

User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: main.lua or equivalent

Postby epsilonion » 22 Jul 2015, 22:12

Skyline Help:

User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: main.lua or equivalent

Postby SolarPortal » 23 Jul 2015, 10:42

hopefully that wont be a problem on the new version ;)



Twitter:
Instagram:
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 2 guests