Инсталирайте Steam
вход
|
език
Опростен китайски (简体中文)
Традиционен китайски (繁體中文)
Японски (日本語)
Корейски (한국어)
Тайландски (ไทย)
Чешки (Čeština)
Датски (Dansk)
Немски (Deutsch)
Английски (English)
Испански — Испания (Español — España)
Испански — Латинска Америка (Español — Latinoamérica)
Гръцки (Ελληνικά)
Френски (Français)
Италиански (Italiano)
Индонезийски (Bahasa Indonesia)
Унгарски (Magyar)
Холандски (Nederlands)
Норвежки (Norsk)
Полски (Polski)
Португалски (Português)
Бразилски португалски (Português — Brasil)
Румънски (Română)
Руски (Русский)
Финландски (Suomi)
Шведски (Svenska)
Турски (Türkçe)
Виетнамски (Tiếng Việt)
Украински (Українська)
Докладване на проблем с превода
This looks like an infinite loop to me. No wonder the game crashes.
The game only ever use one version of a file. Either the original one, or the modded one if present. Never both. Thus making a script call to the script of the same name results in an infinite loop.
Do this properly (and that means using a mod folder, so no update issue) and it works.
Could you please send the script over to modding@starpointgemini.com so we can check it out in detail?
Running a script from within the same script will definitely create a loop. Running other scripts is naturally possible.
But:
My point was that the current system is messed up. The example I gave above was just to point out the problem of not being able to "add" modded functionality on top of the existing one, without having to copy and paste the original code in FULL. The moment the game is updated, the script may have changed, and so it makes my mod useless. My example above just shows how I would like it to work to "at least" make it safe and future proof, by calling the original code, instead of copying it, though it still only supports one mod for the same script at a time which is the biggest issue here.
If I want to write two mods working together, if both are installed, but each one being usable on its own, I can't do it in the current implementation. I can only have one working or the other, or merge them into one.
Sorry for stating this so bluntly, but the scripting is not really advanced at all, it lacks any kind of structure, advanced control blocks or any way to make reusable pieces of code (except for calling script), that proper languages like python/lua/perl/squirell or even vbscript provide. It completely isolates the mod from the rest of the game engine.
I get that it's been with you for 2+ generations but why prevail and keep it now for the SGW? Are you really going to remake SG yet again, just to make it use lua?
Even if we have to stick with the current scripting system, can you at least add another method called: "script2" or something that will call the original code, rather than the one in the mods folder? This would at least make the mods safer and more future proof.
It would be waaaay better though, if you could add a way to register a method in a mod to be called when certain event happens.
Example:
I. Three methods (for simplicity) could be added for event handling:
- OverrideEvent <- this overrides the original event replacing the functionality - current behaviour
- RegisterEventBefore <- this calls the script provided in argument list, before calling the original or overriden event
- RegisterEventAfter <- this calls the script provided in argument list, after calling the original or overriden event
II. Each mod could contain special script MAIN.SAL which would be called by the engine when the mod is loaded.
III. Then:
1. "main.sal" file in the First mod could contain line:
RegisterEventAfter "Any_Panel_OnShow" "MyAnyPanelOnShow.sal"
2. "main.sal" file in the Second mod (in order) could contain line:
RegisterEventBefore "Any_Panel_OnShow" "MyAPOS.sal"
When the "Any_Panel_OnShow.sal" is to be called by the game engine, it would call the:
1. APOS.sal - registered second but as a before event
2. Any_Panel_OnShow.sal - original script if there were no overrides made, or the one from any other mod registered via OverrideEvent method - this also works for backwards compatibility
3. MyAnyPanelOnShow.sal as registered first on After
Do you see my point? Two or more mods can work off the same event at the same time, in order as they registered their interest in handling the event in the mod manager and both can call the original script if the want to via OverrideEvent, or leave it to the engine via Before/After events.
Any chance of getting this minimal functionality added before the release ?
PS> It can be improved further by providing access to the event handlers and event registration lists, but it could make scripting a bit hard on some.
I'll check with the scripters though
Sadly, this is correct and current scripting system, at least "advanced" part of it, requires quite some knowledge about the game inner workings.
As Karlito mentioned: we have "CreatePreScript" and "CreateScript" events for some functionalities on some objects but that is for the game objects(like ships, structures etc.) and is not exactly the same what you are asking for and thank you for the nice write-up, your points are spot on. I was thinking something along this lines would be great but unfortunately I am not in charge of it and judging by the amount of other game work that needs to be done I don't think any system besides "script2" and some script exceptions(example: WorldReadyForUse.sal that runs in any mod after the main script) will make it in game any time soon. I will try to put some main programmer attention to it.
Maybe the CreatePreScript and CreateScript could be extended to support a wider range of events? It would be a lot easier to extend existing functionality than to create a new mechanism. I guess we would need to be able to access every game object, including panels, world, etc... and the number of commands would have to expand as well.
Cheers.
Then just see if a script that is being loaded matches the one in the database and just load that before the original GlobalOnPulse60.sal. This way you could have multiple unique scripts being loaded before the original script, without it having to be modified.
The concept of CreatePreScript seems alright, but you still need to modify a core script in order to fire it off, rather than just a loose file. So the consumer has to be very much comitted to just using one modded script, because it's very likely to run into collisions on scripts like OnPulse.
I come from various modding scenes, I actually am a little baffeled as to why this scripting language does not have native support for side loading functions of loaded scripts at the very least the ability too override functions within a script on run.
The first is pretty much fundementally the core of extended functionality & modding ease. The later however allows for both developers and modders alike to make minor changes to existing scripts without replacing the entire function or relying on full copy paste. A good example of this is how Starbound uses JSON where a mod can simply override a vanilla scripts function without ever touching the orignal script this allows parts of the script to be replaced and multiple mods to change the same script so long as they do not override the same variable within the script it usually works fine together.
In my case I have extensive expierence working with the SourceEngine and Gmod script.
where if you need to call functions, or register events within another script at the first line of a new or existing script simply do this -
Example: from ULX MOD for Gmod
In example above the script "cl.in.lua" is requesting that the other scripts be included (not run) but they must exist so that this script can call check those scripts and run its own functions which may or may not need to collect infromation from running functions within those scripts.
Another way of doing this is use the "require" method this checks another script or file is loaded and the script functions will do nothing unless that file exists and is loaded.
It would be 200% easier too call a function override it with a priority based system where mods at the bottom are loaded last and override the mods above. It seems tedioud for me to have to update the entire sectors script just to add a few minor changes to existing sectors or add a new sector I should be able to just include the script I want to change then tack on addtional code within my mod that overrides specific lines or adds new lines to the open handle.
That's what it already does. ModX overwrites ModY if they use the same scripts, depending on priority. Events are hooked through CreatePreScript and CreateScript and you can run external functions by passing a scriptvar or globalvar when executing scripts as functions - if they require data. Kind of like if you're pushing data to a class.
Then you're doing something wrong, because new and existing sectors have exactly that luxury by just editing the respective files.
Eg.
The real issue for me are collisions that come from other mods. Updating them isn't a problem because git basically does that for you, but eventually there's going to be a guy who uses the same file as someone else to initiate his scripts and that's just going to break it. The scripts aren't particular complex to a point where you would absolutely need to include your own script at a specific location. 99% of the times you can get away by just running your logic at the end of other scripts (Although you have to undo some things in your own script then if it's not favourable to have), but even for that there aren't enough diverse events. Ideally, users should be able to attach their own script to any existing script, without the possibility of overwrites happening.
Feel free to add me so we can learn it together, I am quite interested in understanding this further.