Sorry, I can't get it to work, always the same, or very similar error. could you make an example of a cs chat-sender? visual studio always tells me stuff is not defined except i do "root.ModApi.Application.SendChatMessage" (or make a local variable of ModApi or Application - CsRoot.Root also seems not to have Application, at least IntelliSense does not show it) Thank you
Murphy: Anything you don't try doesn't work ;-) I had forgotten to initialize the ModApi property in ScriptSaveGameRootData. With 13.2.1 it works now. https://github.com/GitHub-TC/EmpyrionScripting/releases/download/13.2.1/EmpyrionScripting.zip And here is the savegamescript Code: if (!(CsRoot.Root is IScriptSaveGameRootData root)) return; if(root.E?.S?.Pilot.Id == 0) return; root.ModApi.Application.SendChatMessage(new Eleon.MessageData() { Channel = Eleon.MsgChannel.SinglePlayer, RecipientEntityId = root.E.S.Pilot.Id, SenderNameOverride = "TEST", SenderType = Eleon.SenderType.ServerPrio, Text = "TEST" });
Thanks a lot, everything started to work. only my own errors that still need fixing. a little Problem I have is the 10s runtime, a 10s countdown is a bit strange if it only counts each 10s ;P but i guess i can just change the config as I have enough cpu power on the server. (and the branches with high calculations only happen once each 10 runs, the other are the countdown)
I haven't found a way to get the actual Max shield level, but I came up with a "hack" to almost get what you want using CacheData: Code: {{setcache 'SL' (max CacheData.SL E.S.ShieldLevel)}} This way, as your shield charges up, @root.CacheData.SL will always contain the maximum amount that your shield has achieved. Semantically it's not very "correct" per se, but practically it will 99% of the time show you the actual maximum shield level your entity can attain. Remember though that CacheData is cleared every time you switch PlayFields, and that if you alter your shields resulting into the maximum amount of shield being less than before, then @root.CacheData.SL will retain the old max value until you change playfield.
Cool idea Hint: If you save the number in an LCD, it would even survive the playfield change and a logout/server start. You could also "fine-tune" it manually
Indeed, however saving it and reading it on an LCD requires significantly more characters in the script, and I've been trying hard to optimize the scripts to fit the 2k character limit. Although I've been leveraging Server side scripts as of late to overcome the 2k limit (and finally have proper code indentation). I play with a friend on a private server of mine (linux with docker and wine) and since we both write scripts I had to set up the server scripts folder as a github repo, and then set a webhook to call a hook service upon any change to the main branch on the server, which in turn calls a local script to git pull the repo in the Saves script folder
Also @ASTIC I noticed that the LCD outputs for Server scripts work on a wildcard? For instance, if my server script is called "Refuel.hbs", then I can put an LCD called "Refuel" and it will show the output of the script. However, if I name it "RefuelLog", it will still show the output of Refuel.hbs. Is that by design? or is this a bug?
For SavegameScripts it's by design Code: AddTargetsAndDisplayType(data, Path.GetFileNameWithoutExtension(S) + "*");
@ASTIC Is the Ammo type that an Entity's guns can accept exposed in the game's API? If yes, can we get our hands on it in the next EmpyrionScripting version?
That is cool, I need to dig a bit deeper on what I can get from the cfg file. Now I need to find a way to get what sort of guns an entity has attached to it so I can automate ammo supply when an entity docks to the "mothership". The only ways I can think of is either have it hardcoded in a "config lcd" on the ship, or scan the blocks of the ship and get the turret/gun ids somehow?. Would there be a better way to get that info?
Scanning the blocks is very complex and time-consuming, better is a hard coded list in a fixed named LCD which contains the IDs or names of the weapon blocks
I can't figure out why this script is not working. I've written a boatload of move item scripts to sort items and feed constructors, but this is frustrating me: Code: {{~set 'Ammo' '[c][703300]Ammunition'}} {{~#each @root.E.S.DockedE}} {{~set 'CurES' S}} {{~#devices S 'ShipConfig'}} {{~gettext .0 }} {{~fromjson .}} {{~jsontodictionary .}} {{~#each AmmoIn}} {{~jsontodictionary .}} {{~#items @root.E.S @root.Data.Ammo}} {{#test id in ../id}} {{move .. @root.Data.CurES @root.Data.Ammo ../../amount}} {{Count}} Items moved {{/move}} {{/test}} {{/items}} {{/jsontodictionary}} {{/each}} {{/jsontodictionary}} {{/fromjson}} {{/gettext}} {{/devices}} {{/each}} The ShipConfig LCD holds a JSON structure such as: Code: { "AmmoIn": [ {"id":1234,"amount":12000}, {"id":1235,"amount":8000} ] } So essentially I'm iterating through all docked ships, and each of those ships has a ShipConfig LCD on it with its requirements for ammo. I use those values to find the items in the local Ammo Controller, and then try to move them to the docked ship's Ammo Controller. However the move command fails to move anything, with no errors whatsoever (the test before the move works fine). What am I doing wrong?
ASTIC, I got a question and maybe request Is the GameTicks variable (in save game c# its root.ModApi.Application.GameTicks) available in non-admin handlebars (or c#)? (If not can I get it?) Thanks a lot!
13.2.3 contains GameTicks https://github.com/GitHub-TC/EmpyrionScripting/releases/download/13.2.3/EmpyrionScripting.zip What do you need them for?
Thanks a lot! I play with db requests again, especially with PlayerPosHistory. There is a timestamp in gameticks... I managed to get it kind of working in a savegame script, but was not exactly pleased with it. Maybe with my new SQL I cooked up in the last hours it could also work there - still when possible I try not to use savegame scripts. And besides that that I also wanted to look into sunrise/sunset at a remote base, if it can be predicted by gametime from another playfield.
@ASTIC After quite a few tests, I came to the conclusion that you cannot move any items between two Ammo Controllers on different entities, and the move command will fail silently. Any container -> Ammo controller works Ammo Controller -> Any Container works Ammo Controller -> Ammo Controller does not work.
There was an bug when the container has the same names -> move do nothing fixed in 13.2.4 and update Demo-CV https://github.com/GitHub-TC/EmpyrionScripting/releases/download/13.2.4/EmpyrionScripting.zip
Is there a way with a C# SaveGameScript to set the state of a lever. And in same way to open/close a door, a shutter or something like without the use of a signal ?
GetSwitchState/SetSwitchState on the lever block You can find a “documentation” of the Empyrion API here EGS\Content\Extras\Modding Doc here I use this for scripting https://github.com/GitHub-TC/Empyri...yrionScripting/CustomHelpers/SignalHelpers.cs