1. Post #1
    bgb

    September 2011
    10 Posts
    I was given a script by someone who's an experienced LUA coder, but the script itself is rather unoptimized and unfinished (so sayeth the author - he just didn't have interest in it), but it recreates rain, fog, thunder, and lightning in such a great way that I have to use it for a map set in a hurricane.

    Here's my previous thread, where they tell me to ask you guys:

    http://www.facepunch.com/threads/112...7#post32510857

    The problem I'm having is that in-game, I can run the script no problem in the console. Getting it to run through triggers in the map is quite different.

    The script is located in /lua/hurricane/rain.lua but directing the trigger to RunPassedCode of TRIGGER_PLAYER:SendLua(string.format('include(%q)' ,location)) simply corrupts the VMF. The comma in the way it's formatted ends up corrupting the VMF, and while the map will build, it won't run in-game when triggered.

    If needed, I can post the script if you need to see it, but my question is this: is there a way to for my map to tell each client to start rain.lua once they enter the map? And if so, how would it be formatted since Hammer doesn't like quotation marks, commas, or backslashes? What am I doing wrong?

    Thank you!

  2. Post #2
    JonBons's Avatar
    November 2010
    95 Posts
    Put your rain script in autorun/client/rain.lua then make a file in autorun/client/server/rain.lua with AddCSLuaFile on the clientsided script. This should make the client download the file and run the file since the file is in the clientsided autorun folder. You don't need to make the map run the file, you just need to add the file to the datapack and it will run if it is placed in the autorun directory.

  3. Post #3
    bgb

    September 2011
    10 Posts
    Put your rain script in autorun/client/rain.lua then make a file in autorun/client/server/rain.lua with AddCSLuaFile on the clientsided script. This should make the client download the file and run the file since the file is in the clientsided autorun folder. You don't need to make the map run the file, you just need to add the file to the datapack and it will run if it is placed in the autorun directory.
    While that would work, the map will be played on servers that I don't own (and don't have access to those directories), so I unless it's pakratted into the bsp, or I talk to the server owner, that won't work. Can a lua file like this be pakratted at all?

  4. Post #4
    Gold Member
    thegrb93's Avatar
    June 2006
    1,316 Posts
    While that would work, the map will be played on servers that I don't own (and don't have access to those directories), so I unless it's pakratted into the bsp, or I talk to the server owner, that won't work. Can a lua file like this be pakratted at all?
    Just distribute the map as an addon with the lua file included.

  5. Post #5
    bgb

    September 2011
    10 Posts
    Just distribute the map as an addon with the lua file included.
    But that's not viable either - it's a map for the Zombie Survival gamemode within gmod, so it has to be contained to its own bsp.

  6. Post #6
    Man Without Hat's Avatar
    September 2011
    969 Posts
    Just a little FYI you can pack lua files in the bsp and then use the lua_run entity to include it.

  7. Post #7
    bgb

    September 2011
    10 Posts
    Just a little FYI you can pack lua files in the bsp and then use the lua_run entity to include it.
    Yes, but the problem is getting it to run at all - setting up a trigger_multiple to RunPassedCode doesn't seem to accept any form of syntax to get the rain.lua to run.


    Even if I stick the code in the lua_run entity itself, it won't run, because hammer is so finicky when it comes to commas or quotation marks or backslashes. It's not getting the lua in the map or on the server - I'll worry about that later - it's just getting the clients to execute the lua when called.

    edit: (but thank you for the confirmation that I can pakrat the lua file at all. yay!)

  8. Post #8
    One way is in the script, just added a console command and then after that add a hook that uses Gamemode.InitPostEntity on the client to run the concsole command ( G.RunConsoleCommand ). You will need a If (CLIENT) check though.

  9. Post #9
    Man Without Hat's Avatar
    September 2011
    969 Posts
    You could try decompiling gm_construct to see how the entity is fired in it.

  10. Post #10
    Gold Member
    thegrb93's Avatar
    June 2006
    1,316 Posts
    We might be able help better if we had this lua file.