Scripts / update global variables between levels [standalone]

Author
Message
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 27th Aug 2019 13:38 Edited at: 27th Aug 2019 13:46
Since it is a headache to keep the global variables between levels, I have thought to do something about it.
A workaround of course.
I will try to explain with my oxford English and with as much detail as possible, how the thing works.

The script called "all_in_one.lua" must be attached to an entity, I used a barrel, although in a serious game, we can use a trigguer and force the player to pass near it, for example an arch, a door, etc.

This script will create 4 files.

filename_list.txt
This file will list the fpe files of all dynamic entities on the map.
It will open all the fpe files and read the script that each one uses, create a new file and store it there.

script_list.txt
It will store all the names of the scripts in a list, which will be used later to obtain all the global variables used; which will be stored in a new file.

globalvars_list.txt
It will store all the global variables used in your map, and use this file to create a lua file.

update_globalvars.lua
This script will update all the global ones in your level 2 or later.
Attach this script to an entity, use the same previous tactic.

Many files and many scripts already know, and that's why I decided to put everything in a single script, and that's why I decided to call it "all_in_one"


requirements

You must declare all your global variables at the beginning of the script.
You must enclose your global between 2 tags, one at the beginning: "- -{globals_start}" and another at the end: "-- {globals_end}", without the quotes, example:



Note: please do not modify the tags, they are used as flags that help to read global variables more easily and faster.

Do not delete or rename the files, do not change them either, unless you know what you are doing, and know how to modify the scripts to match the new paths.

Feel free to modify, improve this script, and share with all your improvements.

I hope this helps to alleviate the problem of global variables in standalones, at least until GG offers us a durable and reliable solution.

I should to say than I have not standalone maps to try it, and not intention to do any in a long time, so please can somebody to try it and back with the results. Thanks in advance.
best reggards

Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

Attachments

Login to view attachments
PM

Login to post a reply

Server time is: 2024-04-16 17:12:08
Your offset time is: 2024-04-16 17:12:08