Scripts / Teleport to another map

Author
Message
Dunvel
15
Years of Service
User Offline
Joined: 10th Feb 2009
Location:
Posted: 23rd May 2015 11:03
I checked the available LUA commands but could not really find anything. What I am looking for is a way to have the player teleport from a trigger zone in map 1 to a waypoint (or something similar) in map 2. This would allow for travel between maps without having to follow the map 1 => map 2 => map3 approach. As an example: map 1 would be a village. map 2 would be a dungeon. I want the player to be able to enter the dungeon from the village and also leave the dungeon again and go back to the village only to re-enter the dungeon again later on.

Is there a way to do this with the current LUA possibilities in GameGuru? I am not looking for the full code but rather for a hint which command might help. I think TransportToIfUsed(e) would not work if the target is in another map, right?

The next question would then be how to add global variables so they can be called from anywhere (like if certain mobs in a map have been killed so they would not be there anymore if the player re-enters the same map again later. But I would look into that later - maybe checking if variables could be added like player stats etc ...)

Thanks for any help anyone can provide on this!
PM
Ratall
15
Years of Service
User Offline
Joined: 29th Jun 2008
Location: Not Here
Posted: 24th May 2015 00:15
The answer you seek maybe in global.lua

JumpToLevelIfUsed(e)
JumpToLevel(levelname)
FinishLevel()

Though I suspect changing level may be slow.

Why not just create your dungeon on the current level hidden away in a corner accessible only by a TransportToIfUsed.

PM
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 24th May 2015 01:30 Edited at: 24th May 2015 22:14
JumpToLevel in either form is indeed the correct way, you simply put a playerzone at the dungeon on map2 from a trigger or winzone from map1. You can also place a zone on 2 to return to 1 etc. Note that you need to follow a set procedure with saving the levels and it only works on saved levels, not in test mode.

If your "play" area is small, consider placing both the village and dungeon on the same map and contain the player within those areas. (using TransportToIfUsed(e) is probably easiest)

On your AI entities, globals only work for each map so there is nothing to reference on map 2 that is related to map 1 (ed: fixed typo) etc. You'll need to keep a list (as an array) of killed enemies, save before jumping out (use the io facilities of LUA) and when you re-enter you can Destroy(entitynumber), possibly even reposition previous AI locations if you're prepared to put in the work to pick up their locations.
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 24th May 2015 01:37
Here's a short example of how to use io. This is part of my player save system.

Add the line


You can save on an event (changing levels), autosave on a timer (which is how this works - timer call is not included) or an explicit keyboard call. Obviously you then to read this back in and do whatever you need done....

Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
Dunvel
15
Years of Service
User Offline
Joined: 10th Feb 2009
Location:
Posted: 24th May 2015 14:13
Awesome! I will tinker around with that and see if I can get it to work.

Thanks a lot for your help, guys!!
PM
Rexzooly-Steam
8
Years of Service
User Offline
Joined: 2nd Jun 2015
Playing:
Posted: 2nd Jun 2015 20:23
How would we load back?
Autoplay Media Studios Lua Scripter, RPG Maker Creator, FPSC and now GG user.
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 2nd Jun 2015 21:38 Edited at: 2nd Jun 2015 21:40
@Rexzooly. io.read is the LUA call to get what was written to file to repopulate your variables. In the example I used above (and it is only an example) you also need to parse the read to get the values. (tbh, if you're asking mate, there is a possibility that the process will be too difficult )

I'd love to be able to create a nice "save plugin" to share but it's just too difficult given the variability if you use any kind of custom player values. In my view, if people are using custom variables etc. and need to write script to save to to file they need to be just as capable of reading from a file - otherwise... cough.... why bother? Necessity is the mother of invention they say.

Yes, one could be readily written that saves a fixed set of custom variables (with minor script edits) but I imagine there will be 50 scenarios where that won't be enough - saving and redistributing n entities across maps is one of them because the scripter would require the end-user to follow pretty strict conventions.
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
Rexzooly-Steam
8
Years of Service
User Offline
Joined: 2nd Jun 2015
Playing:
Posted: 2nd Jun 2015 22:27
I would read it to a ini for other formats like xml and read them with one of lua's libs that control ini or xml that way so reason I asked how you would do it the way you demoed I use lua 5.1 in a good handful of other tools so knowing a few things about file loading but not in GG
Autoplay Media Studios Lua Scripter, RPG Maker Creator, FPSC and now GG user.
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 2nd Jun 2015 23:32 Edited at: 2nd Jun 2015 23:33
Sweet. Looks like you're up to speed. Sorry if I made an incorrect assumption based on your question.

As far as GG is concerned, you simply need to read in the file, parse/populate etc. into global array/vars and treat them as any other variable. The only serious restriction to saving/loading across maps is you cannot use entity numbers to reference (well, technically you could but it'd be a nightmare to manage it). Reloading using entity number as the reference on same map should be fine provided you write proper error handling - specifically if using arrays (tables in LUA). If you forget to zero out dead entities in a custom array, a reload could bomb the map on re-entry.

A preferred technique would be using the "names" property and as long you kept the naming convention in proper order, you could technically have an entity "follow" you from map 1 to map 2 using save/load and cloning. In the project I'm doing myself, one particularly unsavoury character is tracking my guy across multiple maps and I have to do exactly that.

It's actually good fun making it all work too. It's a sickness
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM
Rexzooly-Steam
8
Years of Service
User Offline
Joined: 2nd Jun 2015
Playing:
Posted: 3rd Jun 2015 12:29
You have just pointed out my big problem I always get my head mixed up on tables lol I hate them in Lua I really do I know there as simple as arrays in php what I get the basics of but both of them give me a head smack lol

I know it once its done its done lol I am really not sure why my head likes them.
Autoplay Media Studios Lua Scripter, RPG Maker Creator, FPSC and now GG user.
Tarkus1971
Audio Media Maker
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: England, UK
Posted: 3rd Jun 2015 12:42
nice work on the save lua, just hope we get a hard coded savegame trigger zone soon. Very important.
Aftershock Quad Core AMD FM2+ 3.5 GHz 8GB Motherboard and Processor, A7700k apu, AMD HD7870 gfx card.
King Korg Synth, Alesis SR18 Drum Machine, Akai MPX8 sample player, Roland Fantom XA Synth, Axus Digital AXK2 Digital Drum Kit.
Rexzooly-Steam
8
Years of Service
User Offline
Joined: 2nd Jun 2015
Playing:
Posted: 3rd Jun 2015 12:50
That would be nice depending on what states they let us save and if they let use save more data if we wanted
Autoplay Media Studios Lua Scripter, RPG Maker Creator, FPSC and now GG user.
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 3rd Jun 2015 12:54
A big "Aye" on that one Tarkus. I suspect any save option can only include what is "standard fare" (part of core) due to it being impossible to know what developers want to save in advance.

A fixed set of general vars is possible but it really opens a Pandora's Box for non-scripters at the first query for more complex saving.

The best we can hope for is a good framework to save with that is readily edited and..... almost idiot proof. I do not envy Lee's job on that one
AKA SisterMatic (Steam)
Development/ Gaming Rigs
Sys 1: i7-4770 (3.5)/16Gb/128 SSD/3Tb/970gtx/2 x 23, 1 x 27 LCD - Sys 2: i7/8Gb/670gtx/1.5Tb/1 x 23 LCD - Sys 3: Amd Quad/8Gb/645gtx/1Tb/30" LCD
PM

Login to post a reply

Server time is: 2024-05-03 13:27:08
Your offset time is: 2024-05-03 13:27:08