Scripts / JumpToLevel within Lua working?

Author
Message
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 5th Nov 2016 00:58
hi guys, trying to get the system to utilise the function ' JumpToLevel(levelname) ' within my code but it doesn't seem to work; I put in my map name test2.fpm as the levelname but I get an error - has any one got this Lua function to work? ; I cant use the ifused principle as its not appropriate in this case

any help would be greatly appreciated on this as I have been on it for nearly a day now and am no closer.

Ian
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 5th Nov 2016 11:47
Firstly, jumptolevel doesn't just the .fpm part of the filename.

Secondly, standalone won't compile your next level unless its listed in an objects infused field.

It would probably be best to wrap your jump to level in an IF loop with a variable, then put a jump to level script that uses ifused when that variable is triggered, in an object somewhere on your level.

That way you can still Kevel jump via your script and it will copy the levels into standalone.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 5th Nov 2016 13:07
Thanks for the reply Belidos I really appreciate your advice; so firstly the command should read JumpToLevel(dufeLevel1a) with no extension or quotation marks? (and is it case sensitive?)

Secondly, I have created a separate standalone for the next level and copied all the relevant assets and map across to the root level and it all works fine when entering a trigger zone and using the ifused field - so I am good there.

However, the 'if used method' is not applicable here due to multiple level selection - What I have created is a levels menu 'a-la Angry Birds' so the player can select what level he wishes to play at the start - each level has been created as a separate standalone and 'infused' within the root standalone - I have also tried LevelFilenameToLoad("mapbank\\dufeLevel1a.fpm") but that didn't work either.

Any further thoughts would be greatly appreciated - this is the last stumbling block to overcome .

smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 5th Nov 2016 14:25 Edited at: 5th Nov 2016 14:26
you don't have to use the method of the 'ifused' but if you have them there in the level somewhere it will let the GG standalone process pick them up automatically - rather than you having to do it.
i.e. even putting the level names in the ifused field of static entities with no script etc will still make GG create the standalone include those maps.

for the actual script you can do it either way,
1 way is like belidos said and involves a bunch of zones/entities and a variable for each to tell them if they should jumptoifused or not - this method works well with the default way GG handles the inclusion of other levels as you will already be inputting the level names in them anyway so a script on each is just a little extra.
so something like this
properties of entity 1;
name = level1
ifused = level1.fpm (note not sure if you need the .fpm or not, been ages since i made a multilevel standalone)

properties of entity 2;
name = level2
ifused = level2.fpm

etc for all levels needed

now for the script they have will look something like this (untested but should work and 1 script should fit all - just name them the same as in the selection script, i would name them like level1, level2 (as i have for this example) or with appropriate titles based on the map etc)


now you just need a script to select the level (which is probably very similar to what you already have).
note i wont write a full working script but the basic idea is -
this code would assume all buttons have already been created and are in a column down the center of the screen (if it doesnt work)


the 2nd option (which i think is what you currently have) is very similar to just the last code snippet but you just call the level directly from there and don't need the first script (but you do need to manually make all your standalones or do the trick we mentioned earlier)
i.e.

code written quickly and untested so forgive any mistakes but i hope you get the idea.
edit, forgot you also need to activate the mouse
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 5th Nov 2016 15:09
Hi Smallg really appreciate your input - thank you. I have more or less got code as per your last snippet indeed I had replaced Lee's loadgame page with a load levels page and his loadgame lua with code similar to yours.
However, therein lies the problem, when the game starts and the player goes to the load level menu, no map has yet been loaded and thus this front end menu code cannot relate to anything within that map such as ifused and zones etc.

When the player clicks a level button It triggers a function such as JumpToLevel("dufelevel2h") but nothing happens - if I lose the quotation marks then I get a nil value error even though that map is in the map bank.

I also tried LoadGame("mapbank\\dufelevel2h.fpm") but again no luck.

I thought maybe you and belidos had cracked it by suggesting that I put a load of hidden entities in the first level and put the different level names in each one's 'ifused' box but that wont work unless this first level is loaded which it isn't at the title screen.

So I'm still stuck but it must be do-able otherwise savegame and loadgame wouldn't work
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 5th Nov 2016 17:18
Create a blank level as the level the start button loads, then have a script on that level that freezes the player, puts up a full screen background image and your menu, that should do it.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 5th Nov 2016 19:11
yh, looks like the commands are only loaded after the first map is started, maybe you could do something with os.execute() but a blank map is easiest.
here's a video explaining how i just got it working. (currently uploading)

and copy the attached into the titlesbank\default folder of your .exe if you want to skip the menu like i did.

also have you tried the program from the third party tools? i thought there was something there to select exe's?
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 5th Nov 2016 19:56
Really appreciate the help guys - you are both singing from the same songsheet and although not ideal its the only workaround that I can see will work - and smallg, I really appreciate you taking the time to demonstrate this in a video - thank you - I get the premise of the work around.

However, the generic loadgame lua script by Lee works on the frontend with no maps open so that begs the question why we cant get the same result using LevelFilenameToLoad(Filename).

I guess I will have to use the work around for now.
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 7th Nov 2016 14:37
Hi guys - tried this workaround - which works but now that I have my main menu within the 1st level the 'about, and saved games' switches wont work in this environment - used smallgs 0s-quit to exit the game which works ok and tried attaching scripts to objects in this menu level for the others but doesn't work - 1 problem solved and one gained! - any ideas?

Login to post a reply

Server time is: 2024-12-22 23:31:45
Your offset time is: 2024-12-22 23:31:45