• Environments
    446 replies, posted
  • Avatar of mbainrot
  • [QUOTE=gordliamjack;32496517]Added these: [IMG]http://revolupowered.com/wp-content/uploads/2011/09/stuff.png[/IMG] Here is the lua file. [URL="http://revolupowered.com/scripts/ls_core_entities.lua"]http://revolupowered.com/scripts/ls_core_entities.lua[/URL] Cmdr please add them :)[/QUOTE] Nicely done mate :) [QUOTE=CmdrMatthew;32497906]Added, will be in the next update when I figure out how to fix client syncing on join. It wont send what node the devices have because they don't yet exist on the client :([/QUOTE] Datatables via a timer event bound to the player maybe? edit: Side Question? Is LS3/RD3 stuff compatible with your RD?
  • Avatar of CmdrMatthew
  • [QUOTE=mbainrot;32499371]Is LS3/RD3 stuff compatible with your RD?[/QUOTE] Sorry, it isn't. They are just too different to be compatible. I did convert gas-systems 2 though, if you want I can send you a copy. I don't think I am able to actually release it though :(
  • Avatar of mbainrot
  • [QUOTE=CmdrMatthew;32499720]Sorry, it isn't. They are just too different to be compatible.[/QUOTE] Ok cool :) my mining addon is intended for Environments :) was just curious
  • Avatar of mbainrot
  • Please pardon the double post... (if edits fire thread subscription updates please let me know so I am not needlessly double posting) Could you please at some stage make the [code] local ResourceUnits = {} ResourceUnits["energy"] = " Kj" ResourceUnits["water"] = " L" ResourceUnits["oxygen"] = " L" ResourceUnits["hydrogen"] = " L" ResourceUnits["nitrogen"] = " L" ResourceUnits["carbon dioxide"] = " L" ResourceUnits["steam"] = " L" local ResourceNames = {} ResourceNames["energy"] = "Energy" ResourceNames["water"] = "Water" ResourceNames["oxygen"] = "Oxygen" ResourceNames["hydrogen"] = "Hydrogen" ResourceNames["nitrogen"] = "Nitrogen" ResourceNames["carbon dioxide"] = "CO2" ResourceNames["steam"] = "Steam" [/code] Global and outside of the base_env_entity/base_env_stoarge it's a pain in the ass adding new devices and storages with custom resources :| because you have to redefine the base entity and then make your changes as needed.
  • Avatar of CmdrMatthew
  • [QUOTE=mbainrot;32514660]Please pardon the double post... (if edits fire thread subscription updates please let me know so I am not needlessly double posting) Could you please at some stage make the [code] local ResourceUnits = {} ResourceUnits["energy"] = " Kj" ResourceUnits["water"] = " L" ResourceUnits["oxygen"] = " L" ResourceUnits["hydrogen"] = " L" ResourceUnits["nitrogen"] = " L" ResourceUnits["carbon dioxide"] = " L" ResourceUnits["steam"] = " L" local ResourceNames = {} ResourceNames["energy"] = "Energy" ResourceNames["water"] = "Water" ResourceNames["oxygen"] = "Oxygen" ResourceNames["hydrogen"] = "Hydrogen" ResourceNames["nitrogen"] = "Nitrogen" ResourceNames["carbon dioxide"] = "CO2" ResourceNames["steam"] = "Steam" [/code] Global and outside of the base_env_entity/base_env_stoarge it's a pain in the ass adding new devices and storages with custom resources :| because you have to redefine the base entity and then make your changes as needed.[/QUOTE] You don't have to, this just gives them names different from what they are called in the code on the overlay. Its completely unnecessary, but yet I will make them global, or add a function. For example if the resource "mercury" you want isn't in that table it will simply call it "mercury" rather than "Mercury" or w/e you would have there, its just an aesthetics thing.
  • Avatar of mbainrot
  • [QUOTE=CmdrMatthew;32515015]You don't have to, this just gives them names different from what they are called in the code on the overlay. Its completely unnecessary, but yet I will make them global, or add a function. For example if the resource "mercury" you want isn't in that table it will simply call it "mercury" rather than "Mercury" or w/e you would have there, its just an aesthetics thing.[/QUOTE] Thanks for that :) Sorry if I seem to whinge allot :( Main reason I raised it is because whilst it is astectics people tend to whinge when they see "asteroid_ore" instead of "Asteroid Ore". Also people say stuff is "buggy" when the resource names don't show up ""properly"". To a programmer like me or you it's fine but to the end user they tend to get upset.
  • Avatar of CmdrMatthew
  • [QUOTE=mbainrot;32515163]Thanks for that :) Sorry if I seem to whinge allot :( Main reason I raised it is because whilst it is astectics people tend to whinge when they see "asteroid_ore" instead of "Asteroid Ore". Also people say stuff is "buggy" when the resource names don't show up ""properly"". To a programmer like me or you it's fine but to the end user they tend to get upset.[/QUOTE] You can have spaces in a resource name, you can just call it "Asteroid Ore" everywhere.
  • Avatar of mbainrot
  • [QUOTE=CmdrMatthew;32515379]You can have spaces in a resource name, you can just call it "Asteroid Ore" everywhere.[/QUOTE] oh ok that's easy then :)
  • Avatar of CmdrMatthew
  • [QUOTE=mbainrot;32515388]oh ok that's easy then :)[/QUOTE] I do recommend using this function though, it reduces the networking load considerably. Environments.RegisterResource(name) It basically replaces the name with a number when its being sent to the client to greatly reduce the amount of data sent.
  • Avatar of mbainrot
  • [QUOTE=CmdrMatthew;32515568]I do recommend using this function though, it reduces the networking load considerably. Environments.RegisterResource(name) It basically replaces the name with a number when its being sent to the client to greatly reduce the amount of data sent.[/QUOTE] Okies DONE :) Is it ok for it to be done during InitPostEntity?
  • Avatar of ContiX
  • [QUOTE=CmdrMatthew;32515568]It basically replaces the name with a number when its being sent to the client to greatly reduce the amount of data sent.[/QUOTE] 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...
  • Avatar of CmdrMatthew
  • 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)
  • Avatar of ContiX
  • 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...
  • Avatar of CmdrMatthew
  • [QUOTE=mbainrot;32515586]Okies DONE :) Is it ok for it to be done during InitPostEntity?[/QUOTE] Yeah [editline]27th September 2011[/editline] [QUOTE=ContiX;32516346]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...[/QUOTE] As I said, every little bit helps
  • Avatar of mbainrot
  • 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 [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") [/code] and Environments does all the hard work :) 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
  • Avatar of CmdrMatthew
  • 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. [editline]29th September 2011[/editline] Filename: CAF_Hooks, Message: Think3 Error: [addons\sb3\lua\entities\base_sb_environment\init.lua:496] attempt to compare number with nil See if you make any sense out of that.
  • Avatar of CmdrMatthew
  • [QUOTE=Tomthetechy;32538303]Im Getting a couple of errors with this. Mainly some blue Lua Errors on the side relating to nil value or something. [editline]29th September 2011[/editline] Filename: CAF_Hooks, Message: Think3 Error: [addons\sb3\lua\entities\base_sb_environment\init.lua:496] attempt to compare number with nil See if you make any sense out of that.[/QUOTE] Looks like you forgot to remove SB3. That file shouldn't even exist.
  • Avatar of CmdrMatthew
  • [QUOTE=BoxMonster;32545229]Is CAF necessary for Environments?[/QUOTE] Nope. If you have errors with it not installed though, please tell me, it means I missed something and need to fix it.
  • Avatar of mbainrot
  • 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 ([url]http://sbdevmodels.googlecode.com/svn/trunk/[/url]) -- Be careful when checking out... allot of it is raw models not compiled MDLs
  • [QUOTE=mbainrot;32549633]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 ([url]http://sbdevmodels.googlecode.com/svn/trunk/[/url]) -- Be careful when checking out... allot of it is raw models not compiled MDLs[/QUOTE] You don't have lifesupport entities.
  • Avatar of BoxMonster
  • I'm currently having an issue in sb_omen_v2 ( [url]http://www.garrysmod.org/downloads/?a=view&id=123405[/url] ) 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.
  • Avatar of CmdrMatthew
  • [QUOTE=BoxMonster;32574662]I'm currently having an issue in sb_omen_v2 ( [url]http://www.garrysmod.org/downloads/?a=view&id=123405[/url] ) 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.[/QUOTE] Try and clear out your data/environments folder and restart, or completely reload from map with the admin menu.
  • Avatar of mbainrot
  • [QUOTE=Tomthetechy;32568419]You don't have lifesupport entities.[/QUOTE] 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] 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 [/code] 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. form1.cs [code] 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"; } } } } [/code] form1.designer.cs [code] namespace GarrysModDependancyFinder { partial class Form1 { /// <summary> /// Required de
  • Avatar of endorphinsam
  • [QUOTE] a bunch of confusing stuph that I wont ever know what it means saddowns[/QUOTE] 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.
  • Avatar of mbainrot
  • [QUOTE=endorphinsam;32585822]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.[/QUOTE] 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.
  • Avatar of LemONPLaNE
  • [QUOTE=endorphinsam;32585822]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.[/QUOTE] 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.
  • Avatar of endorphinsam
  • [QUOTE=mbainrot;32585887]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.[/QUOTE] Whatever you just said I'm sure was a waste of time because I don't know what it means.
  • Avatar of mbainrot
  • [QUOTE=LemONPLaNE;32586040]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.[/QUOTE] 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 [code] cd C:\Program Files (x86)\Steam\steamapps\<steam username>\garrysmod\garrysmod\addons [/code] For 32 bit users [code] cd C:\Program Files\Steam\steamapps\<steam username>\garrysmod\garrysmod\addons [/code] 4) move into your addon (in this tutorial it will be "example_env_addon") 5) run the following command (this is the easiest way of creating the directory structure needed) [code] mkdir lua\environments\lifesupport [/code] 6) Then run the following command [code] tree [/code] What "tree" does is spits out the directory structure allowing you to verify that you have done everything correctly (see the bellow screenshot) [img]http://u.filepak.com/oasF_cmdprompt_tree.png[/img] 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 [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") [/code] Quick explanation of what these fields do (of the ones I know of anyway) [b]Environments.RegisterResource("some random resource")[/b] 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. [b]Environments.RegisterLSStorage("My Random Storage", "env_random_storage", {[3600] = "some random resource"}, 4084, 400, 300)[/b] As the command suggests, it creates the "entity". [B]First Argument:[/B] Human Readable name [B]Second Argument:[/B] 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) [B]Third argument:[/B] 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? [B]Forth Argument:[/B] is listed as basevolume. This prolly has something todo with the amount of goo you can store in your tank [B]Fifth Argument:[/B] is the base health of the storage. This determines how much abuse the storage can take before it goes pop [B]Sixth Argument:[/B] is the base mass of the storage. E.g. how heavy it is. [b]Environments.RegisterDevice("Storages", "Random Storage", "My Random Storage", "env_random_storage", "models/Slyfo/t-eng.mdl")[/b] This command tells environments to add the storage to the derma menu allowing the player to spawn it without l33t hax [B]First Argument:[/B] This is what category the device lives under the "Life Support" category in the "Environments" tab [B]Second Argument:[/B] 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 [B]Third Argument:[/B] This is the human readable name [B]Forth Argument:[/B] This is the class of the entity you specified in the previous command. [B]Fifth Argument:[/B] 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 :)