Does it really make that much of a difference between 86 and "Asteroid Ore" in sending data? Isn't it a matter of 1 KB vs 2 KB or something? That's hardly a difference...
Does it really make that much of a difference between 86 and "Asteroid Ore" in sending data? Isn't it a matter of 1 KB vs 2 KB or something? That's hardly a difference...
It helps to reduce lag, it's not really about the amount of data sent. Every little bit helps, it's far cheaper to send a small packet than a larger one. It's only one byte where the name would be ten or so bytes (number of characters +1)
Isn't that more like painting your car black so it'll absorb more light and thus be less impeded by the numerous photons bouncing around? I can't think that it would honestly help that much...
Yeah
Edited:
As I said, every little bit helps
What is the easiest and best way to add a custom storage?
I tried creating my own entity and I am having no luck. It registers and what not but won't receive the asteroid_ore when the laser is firing SupplyResource("asteroid_ore",100)
edit: nerver mind :P I got it working
Gotta have a file under "EnvironmentsRD\lua\environments\lifesupport" which contains
and Environments does all the hard work :)Code:Environments.RegisterResource("asteroid_ore") Environments.RegisterLSStorage("Asteroid Ore Storage", "env_asteroid_ore2", {[3600] = "asteroid_ore"}, 4084, 400, 300) Environments.RegisterDevice("Storages", "Resource Cache", "Large Ore Storage", "env_asteroid_ore2", "models/Slyfo/t-eng.mdl")
edit2:
You can also add your other stuff so it shows up in the stool and looks neater without the need for a pain in the ass custom stool
edit3:
After further testing I found that CmdrMatthew has made it really easy :)
In your custom addon create the following folder structure
YourAddon
- lua
-- environments
--- lifesupport
Basically when EntRegister.lua is run, at line 652 there is a loop that illiterates through all addon's lua folders looking for "environments/lifesupport/*.lua" and then pcall's "include" and "AddCSLuaFile" thus making your life as a developer easier. :)
I will do up some quick instructions on how to add custom devices/storages to Environments
The latest update is now out. It has some major bugfixes and feature improvements, including duping of cables, data syncing on join is now (hopefully) fixed, and files are more neatly organized.
Im Getting a couple of errors with this. Mainly some blue Lua Errors on the side relating to nil value or something.
Edited:
Filename: CAF_Hooks, Message: Think3 Error: [addons\sb3\lua\entities\base_sb_environment\init.l ua:496] attempt to compare number with nil
See if you make any sense out of that.
Looks like you forgot to remove SB3. That file shouldn't even exist.
Is CAF necessary for Environments?
Nope. If you have errors with it not installed though, please tell me, it means I missed something and need to fix it.
There are a few errors that happen due to missing models, it might be worth listing all the depends so people know what they need
I have the following and its relatively quiet (odd error when i do something arbituary like blow up a power plant, etc)
- SBEP (all inc weapons to be sure)
- SB Dev models (http://sbdevmodels.googlecode.com/svn/trunk/) -- Be careful when checking out... allot of it is raw models not compiled MDLs
You don't have lifesupport entities.
I'm currently having an issue in sb_omen_v2 ( http://www.garrysmod.org/downloads/?a=view&id=123405 ) where, on the spawn planet, I lose health as if there's no oxygen whenever I take off my helmet, and putting the helmet on slowly drains oxygen in the same way. But I used the atmospheric probe, and all the gas levels and such were totally normal... Not sure what caused it, either. Everything is up to date, too.
Try and clear out your data/environments folder and restart, or completely reload from map with the admin menu.
I don't have ls entities (as in the CAF'd version) and it works using the models included in the repo.
I wrote a little C# program that lists all the models referenced by lua files in a folder...
I am gonna prolly take some time in developing a repository of known addons that contain xyz models so that this little widget of mine can say "right, these are the models in use, these are the addons known to contain said models"
These are all the models used in environments/environmentsRD
Code for the little program is here :), note this was written in MS VS 2010 using .NET 3.0 framework not sure if code will work in previous versions of the framework.Code:models/SBEP_community/d12airscrubber.mdl models/props_canal/canal_bridge03a.mdl models/props_canal/canal_bridge03b.mdl models/props_canal/canal_bridge03c.mdl models/props_lab/tpplugholder_single.mdl models/props_lab/tpplug.mdl models/player/charple01.mdl models/punisher239/punisher239_reactor_small.mdl models/ce_ls3additional/fusion_generator/fusion_generator_huge.mdl models/ce_ls3additional/fusion_generator/fusion_generator_large.mdl models/ce_ls3additional/fusion_generator/fusion_generator_medium.mdl models/ce_ls3additional/fusion_generator/fusion_generator_small.mdl models/Punisher239/punisher239_reactor_small.mdl models/Punisher239/punisher239_reactor_big.mdl models/ce_ls3additional/solar_generator/solar_generator_c_huge.mdl models/ce_ls3additional/solar_generator/solar_generator_c_large.mdl models/ce_ls3additional/solar_generator/solar_generator_c_medium.mdl models/ce_ls3additional/solar_generator/solar_generator_giant.mdl models/ce_ls3additional/solar_generator/solar_generator_huge.mdl models/ce_ls3additional/solar_generator/solar_generator_large.mdl models/ce_ls3additional/solar_generator/solar_generator_medium.mdl models/chipstiks_ls3_models/LargeH2OPump/largeh2opump.mdl models/props_phx/life_support/gen_water.mdl models/ce_ls3additional/compressor/compressor.mdl models/props_outland/generator_static01a.mdl models/ce_ls3additional/water_air_extractor/water_air_extractor.mdl models/Slyfo/electrolysis_gen.mdl models/ce_ls3additional/water_heater/water_heater.mdl models/props/de_nuke/storagetank.mdl models/ce_ls3additional/resource_tanks/resource_tank_large.mdl models/ce_ls3additional/resource_tanks/resource_tank_medium.mdl models/ce_ls3additional/resource_tanks/resource_tank_small.mdl models/ce_ls3additional/resource_tanks/resource_tank_tiny.mdl models/props_phx/life_support/battery_large.mdl models/props_phx/life_support/battery_medium.mdl models/props_phx/life_support/battery_small.mdl models/props_c17/substation_stripebox01a.mdl models/props_c17/substation_transformer01a.mdl models/props_wasteland/coolingtank02.mdl models/props_phx/life_support/canister_large.mdl models/props_phx/life_support/canister_medium.mdl models/props_phx/life_support/canister_small.mdl models/chipstiks_ls3_models/LargeSteamTank/largesteamtank.mdl models/ce_ls3additional/resource_cache/resource_cache_large.mdl models/ce_ls3additional/resource_cache/resource_cache_medium.mdl models/ce_ls3additional/resource_cache/resource_cache_small.mdl models/props_combine/combine_emitter01.mdl models/props_combine/combine_mine01.mdl models/Slyfo/t-eng.mdl models/props_phx/life_support/crylaser_small.mdl models/Slyfo_2/miscequipmentradiodish.mdl models/Spacebuild/Nova/recieverdish.mdl models/props_wasteland/panel_leverBase001a.mdl models/Environments_Node.mdl models/props_canal/rock_riverbed02c.mdl models//props_debris/concrete_spawnchunk001a.mdl models//props_debris/concrete_spawnchunk001b.mdl models//props_debris/concrete_spawnchunk001c.mdl models//props_debris/concrete_spawnchunk001d.mdl models//props_debris/concrete_spawnchunk001e.mdl models//props_debris/concrete_spawnchunk001f.mdl models//props_debris/concrete_spawnchunk001g.mdl models//props_debris/concrete_spawnchunk001h.mdl models//props_debris/concrete_spawnchunk001i.mdl models//props_debris/concrete_spawnchunk001j.mdl models//props_debris/concrete_spawnchunk001k.mdl models/props_wasteland/rockcliff01g.mdl models/props_wasteland/rockgranite01c.mdl models/props_wasteland/rockgranite04b.mdl models/props_wasteland/rockcliff01c.mdl models/props_wasteland/rockcliff01j.mdl models/props_wasteland/rockgranite02a.mdl models/props_wasteland/rockcliff01e.mdl models/props_wasteland/rockgranite01a.mdl models/props_wasteland/rockgranite03c.mdl models/props_wasteland/rockcliff01b.mdl models/props_wasteland/rockcliff01f.mdl models/props_wasteland/rockgranite01b.mdl models/props_junk/watermelon01.mdl models/props_wasteland/rockgranite04c.mdl models/ce_ls3additional/plants/plantfull.mdl models/slyfo/cup_noodle.mdl models/player/combine_super_soldier.mdl models/SBEP Player Models/bluehevsuit.mdl models/SBEP Player Models/orangehevsuit.mdl models/SBEP Player Models/redhevsuit.mdl models/Combine_Soldier_PrisonGuard.mdl models/Combine_Soldier.mdl models/Combine_Helicopter/helicopter_bomb01.mdl models/player/barney.mdl models/Slyfo_2/mmu_mk_1.mdl models/props_phx/construct/glass/glass_curve90x1.mdl
form1.cs
form1.designer.csCode:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace GarrysModDependancyFinder { public partial class Form1 : Form { private delegate void ThreadSafeCall(String msg); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { folderBrowserDialog1.ShowDialog(); textBox1.Text = folderBrowserDialog1.SelectedPath; } private void RecurseFolder(String path) { String[] files = Directory.GetFiles(path); foreach (String file in files) { if (file.Contains(".lua")) { ProcessFile(file); } Application.DoEvents(); } String[] folders = Directory.GetDirectories(path); foreach (String folder in folders) { RecurseFolder(folder); Application.DoEvents(); } } private void ProcessFile(String file) { StreamReader fs = new StreamReader(file); while (fs.EndOfStream == false) { String line = fs.ReadLine(); if (line.Contains(".mdl")) { handleLine(line); } } fs.Close(); } private void handleLine(String line) { line = line.Substring(0, line.IndexOf(".mdl\"")+4); line = line.Substring(line.LastIndexOf("\"")+1); if(!listBox1.Items.Contains(line)) AppendList(line); } private void AppendList(String item) { if (this.listBox1.InvokeRequired) { ThreadSafeCall tsc = new ThreadSafeCall(AppendList); this.listBox1.Invoke(tsc, item); } else { this.listBox1.Items.Add(item); } } private void Form1_Load(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { RecurseFolder(textBox1.Text); } private void button3_Click(object sender, EventArgs e) { textBox2.Text = ""; foreach (String item in listBox1.Items) { textBox2.Text += item + "\r\n"; } } } }
You can use the code for what ever you want on the provisio if released it is open source and you give attribution for the parts of my code used :)Code:namespace GarrysModDependancyFinder { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); this.button2 = new System.Windows.Forms.Button(); this.listBox1 = new System.Windows.Forms.ListBox(); this.button3 = new System.Windows.Forms.Button(); this.textBox2 = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(13, 13); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(29, 13); this.label1.TabIndex = 0; this.label1.Text = "Path"; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(54, 10); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(224, 20); this.textBox1.TabIndex = 1; // // button1 // this.button1.Location = new System.Drawing.Point(284, 8); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 2; this.button1.Text = "Find folder"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(365, 8); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(137, 23); this.button2.TabIndex = 3; this.button2.Text = "List all refences to mdls"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // listBox1 // this.listBox1.FormattingEnabled = true; this.listBox1.Location = new System.Drawing.Point(23, 54); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(578, 290); this.listBox1.TabIndex = 4; // // button3 // this.button3.Location = new System.Drawing.Point(516, 361); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(75, 23); this.button3.TabIndex = 5; this.button3.Text = "Spew items to text area"; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // // textBox2 // this.textBox2.Location = new System.Drawing.Point(33, 358); this.textBox2.Multiline = true; this.textBox2.Name = "textBox2"; this.textBox2.ReadOnly = true; this.textBox2.Size = new System.Drawing.Size(379, 44); this.textBox2.TabIndex = 6; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(641, 415); this.Controls.Add(this.textBox2); this.Controls.Add(this.button3); this.Controls.Add(this.listBox1); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.Controls.Add(this.label1); this.Name = "Form1"; this.Text = "Garry\'s Mod Dependancy Finder"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; private System.Windows.Forms.Button button2; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.Button button3; private System.Windows.Forms.TextBox textBox2; } }
Yes it's missing the error catching... this is a developer tool not a tool for nublets with random button clicking tendencies.
I wish lua wasn't so complicated. I want to learn it. but like, spoon feedi-I mean, putting food in the spoon and forcing it down my throat-feeding.
It's basically a program looking for any string which is in double quotes (") and has .mdl in it :)
.mdl is the extension for models.
edit: lua is easy :), C++ is a nightmare :). Though I can code in C, C#, PHP, GarrysMod Lua, shell, ms batch.
Lua is piss easy. The only language that's easier to learn is Python.
Also, @mbainrot, nothing hard about C++. You just need to memorize it.
Whatever you just said I'm sure was a waste of time because I don't know what it means.
It's the memory crap that does my head in :| having to alloc memory etc to avoid crashes.
Anyway getting the thread back on topic :)
Here is how to create an addon that adds a new storage device to Environments :) (Better documentation then my previous post)
1) Create your basic addon (as in create the info.txt and "lua" folder)
2) Go into the command prompt (In Windows 7 it's Start -> Run, then "cmd")
3) Navigate to your garry's mod addons folder.
For x64 users
For 32 bit usersCode:cd C:\Program Files (x86)\Steam\steamapps\<steam username>\garrysmod\garrysmod\addons
4) move into your addon (in this tutorial it will be "example_env_addon")Code:cd C:\Program Files\Steam\steamapps\<steam username>\garrysmod\garrysmod\addons
5) run the following command (this is the easiest way of creating the directory structure needed)
6) Then run the following commandCode:mkdir lua\environments\lifesupport
What "tree" does is spits out the directory structure allowing you to verify that you have done everything correctly (see the bellow screenshot)Code:tree
7) Create a file with a meaningful name in the "lua/environments/lifesupport" directory. In this example I will call it env_example_storage.lua
8) Open up the file you created in step 7 in your favorite text editor (I personally use Notepad++ as it is free and has syntax highlighting) and drop the following text inside
Quick explanation of what these fields do (of the ones I know of anyway)Code:Environments.RegisterResource("some random resource") Environments.RegisterLSStorage("My Random Storage", "env_random_storage", {[3600] = "some random resource"}, 4084, 400, 300) Environments.RegisterDevice("Storages", "Random Storage", "My Random Storage", "env_random_storage", "models/Slyfo/t-eng.mdl")
Environments.RegisterResource("some random resource")
This adds the resource to the system so any traffic involving the resource is sent as a number instead of a string... This is good because it reduces traffic on your server.
Environments.RegisterLSStorage("My Random Storage", "env_random_storage", {[3600] = "some random resource"}, 4084, 400, 300)
As the command suggests, it creates the "entity".
First Argument: Human Readable name
Second Argument: the ""class"" of the device, this can be either something you have made up (and thus unique) or an existing class (such as one you made)
Third argument: is a list, I am not 100% sure what the number means but in order for the resource to register in a multi-resource storage device this number must be unique. CmdrMatthew could you please clarify exactly what the number does?
Forth Argument: is listed as basevolume. This prolly has something todo with the amount of goo you can store in your tank
Fifth Argument: is the base health of the storage. This determines how much abuse the storage can take before it goes pop
Sixth Argument: is the base mass of the storage. E.g. how heavy it is.
Environments.RegisterDevice("Storages", "Random Storage", "My Random Storage", "env_random_storage", "models/Slyfo/t-eng.mdl")
This command tells environments to add the storage to the derma menu allowing the player to spawn it without l33t hax
First Argument: This is what category the device lives under the "Life Support" category in the "Environments" tab
Second Argument: This is what category the device lives under in the First Argument's category, e.g. for storage, it would be what category under the storage context
Third Argument: This is the human readable name
Forth Argument: This is the class of the entity you specified in the previous command.
Fifth Argument: This is the model the object will spawn with. Note that you can have any number devices that are mechanically identical but have different models and will appear as separate devices.
So there you go, that's how you create your own custom storage.
So have fun and happy resourcing :)
That number is the multiplier for how much of that resource can be put in that object. It is multiplied by the (model's volume)/(basevolume) to get how much can be stored of that resource. I need to get the table switched around so you can have multiple resources with the same multiplier. ex. {["steam"] = 3600}
PLEASE tell me you're planning to round the final number off so that I don't have to see "Oxygen tank: 21353568634574676358/6678569672685673746783567847852".
2 500 000 is a valid amount of storage. 2 536 043 isn't.
Well, if you could tell me how to do that (in Lua) I could. The only method I can think of is pretty bad, and involves strings....
The syntax is more pseudo-C++ than Lua, but I'm pretty sure there's a round function there somewhere, right?Code:function roundToNearest(n,magnitude){ return int(round(n/magnitude)*magnitude) }
It's not the neatest thing ever, but at least the end result will look nice.
Edited:
Obviously, you need to add some special cases and long number detection.
This Python program seems to do the trick, only skewing the result slightly when going into negatives:
This is, for the record, how my programming looks at 7AM after not getting any sleep. Don't bash me :(Code:def roundToNearest(n,mag): if len(str(abs(n)))>=10:return "Number too large" elif mag==0: return 0 elif abs(n)<=abs(mag): return 0 else: return int(round(n/mag)*mag) _______________________________________________________________________________ >>> roundToNearest(2346467356,100000) 'Number too large' >>> roundToNearest(2569246,10000) 2560000 >>> roundToNearest(2569246,100000) 2500000 >>> roundToNearest(-2569246,100000) -2600000
That just rounds it. -snip-
EDIT: Figured it out,gives me the number of places the number has. Ex. 100 has 3, 50000 has 5. I then use this with math.Round().local pow = math.ceil(math.log(num)/math.log(10))
Very nicely done :)
Edited:
Oh there is an error that occurs when someone nukes a planet (e.g. using the GigaFish with gcombat)
Timer Error: [addons\environments\lua\environments\core\sv_envir onments.lua:463] attempt to call method 'IsStar' (a nil value)
The hud is not displaying correctly seems to be like my screen is zoomed in, could be caused by of these errors that appear when i connect to my srcd
Timer Error: [@addons\envcore\lua\environments\spacesuits\sv_sui t.lua:108] Tried to use a NULL entity!
Timer Error: [@addons\envcore\lua\environments\core\sv_environme nts.lua:795] Tried to use a NULL entity!
Timer Error: [@addons\envcore\lua\environments\core\sv_environme nts_players.lua:387] Tried to use a NULL entity!
None of those lines you gave me match up with anything I have. Try updating? Or tell me the code on those lines.
well I think the helmet is broken for wide screen resolutions, what its doing is that its using the overlay used for non widescreen, but not stretching it
Yeah, go to the environments toolmenu tab, then settings. Use the bottom six sliders to adjust it to your screen. Quite a few people were complaining about resolutions not working (ones that my screen wouldnt go to) that I made a manual setup.
oh kk, awesome, didn't realize it, oh and would it be possible to add a compass to the bottom of the helmet HUD?
What would it point to?
Also, does anyone have any ideas on anything new to add? I am making a new map especially for this addon, so basically the sky is the limit with your ideas.
well, it would use the same system that depthHUD inline uses, or you can have it so that it points the the center of the last atmosphere entered
Hey, you should add a change log. :D I always love seeing what devs have added, changed, removed or fixed.
Edit: Also, how well does this work with the Gravity Hull Designator (GHD)?
It works perfectly as far as I know. The change log is the svn, it tells you the changes made each update.
Ah, thanks. Is there support for 1440x900? Because when I look at the cool HUD on that resolution, I can't see the temperature of the atmosphere, only the label...
oh about the HUD config thing, it causes issues in pods, where I have it set up for 1920*1080, it loks fine out of pods, but when you hop in it cuts the top off, and that it dosn't save the values I set, so I have to change them every time I play
never mind the saving thing, I'm an idiot
Well, I need values from people about the proper settings for in and out of vehicles, at many resolutions. So once I get alot of them, I cant make it entirely automatic.
kk, well, for mine, its been looking quite nice at 1.46 for both X-Y scales, and the Z scale is 1.8, I leave the offsets alone, while in pods I cannot change the offsets, but I leave the X-Y scales the same and set the Z scale to 1.45
oh I also thought of a new feature, make it so that players can name the planets themselves, clientside, that way instead of a number it'll show a name for the planet, yet no extra data would be transmitted between the server and client since the names would be chosen by the client, it would also add to the exploration feeling of the game