Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 21 22 [23] 24 25 ... 61

Author Topic: [SUGGESTIONS] for DFhack plugins  (Read 143295 times)

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #330 on: December 12, 2013, 12:16:34 pm »

Workshops that can use up fluids from a square below would be awesome as well...


Since the steam engine can do both of those things it surely couldn't be too hard to make plugins to allow both behaviors.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #331 on: December 12, 2013, 03:10:02 pm »

No it's not too hard.

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #332 on: December 13, 2013, 11:03:54 am »

Awesome! Now "someone" just needs to do it. Of course in my experience "someone" always has a todo list that, if printed out, would completely swamp the word in paper ;)
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #333 on: December 13, 2013, 11:45:17 am »

Awesome! Now "someone" just needs to do it. Of course in my experience "someone" always has a todo list that, if printed out, would completely swamp the word in paper ;)
It's not that long: https://gist.github.com/warmist/3905090
Although currently working on multiplayer...
Also there is uglyish thing with not knowing which version to compile to (because this will have to be compiled to .dll/.so) and other small stuff (e.g. how to signal if it needs power, how to signal if it eats lava/water?, maybe add generic tick function that you would then add with lua? but then how the performance will suffer? etc...)

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #334 on: December 13, 2013, 12:04:17 pm »

Could water/magma eating be a command? then you could use autosyndrome to call a command like this "eatfluid magma 3 3 2 2 /LOCATION" (where the "3 3 2 2" part is the building size and work location, for determining where to take fluids from)
« Last Edit: December 13, 2013, 12:13:19 pm by milo christiansen »
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [SUGGESTIONS] for DFhack plugins
« Reply #335 on: December 13, 2013, 12:41:40 pm »

I am more interested in the buildings that need power.

If you just want a workshop that uses up water, copy the steamengine, add the reactions you want, and then use that.. yes, it might create power, but you dont need to tell people that. Just call it a water reservoir and done. As long as no one builds axles underneath it, it will use up the water and no one will be any wiser. (ok, maybe the reactions will still work if the water is empty, I havent tested that.)
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #336 on: December 13, 2013, 12:54:19 pm »

That would probably work, but I am more interested in using magma (without also using water)
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [SUGGESTIONS] for DFhack plugins
« Reply #337 on: December 13, 2013, 01:10:18 pm »

Might I ask what for? Using up magma seems a bit pointless, considering that magma pools, lakes and volcanos refill themselves. Using up 1/7 or even 7/7 will have no bigger consequence as the NEEDS MAGMA tag. Because a magma-using workshop which such a plugin would remove only a tiny part of an endless resource.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #338 on: December 16, 2013, 12:11:07 pm »

For things like a "magma extractor" that allows you to get tiny amounts of metals from magma. I want to use it up so that you need to put such a building near the magma source and not on top of a 1 tile pool that was created from a magma melter or pumped up via magma piston.

Also I want to make a "minecart filler", and it would be best for that to use fluids as well. If the cart filler didn't use fluids it would be possible (easy in fact) to get two or so minecarts full from the magma sea and use them to create a filling station on the surface. Free easy to get magma anywhere you want, not good.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [SUGGESTIONS] for DFhack plugins
« Reply #339 on: December 16, 2013, 12:19:04 pm »

For things like a "magma extractor" that allows you to get tiny amounts of metals from magma. I want to use it up so that you need to put such a building near the magma source and not on top of a 1 tile pool that was created from a magma melter or pumped up via magma piston.

Also I want to make a "minecart filler", and it would be best for that to use fluids as well. If the cart filler didn't use fluids it would be possible (easy in fact) to get two or so minecarts full from the magma sea and use them to create a filling station on the surface. Free easy to get magma anywhere you want, not good.
Ok, that makes sense. I do have one of these minecart filler things, and yes, as soon as you have one active workshop you make unlimited magma.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #340 on: December 23, 2013, 01:52:44 pm »

I just downloaded the latest DFHack source, so providing I don't run into weird issues I should have something that "just works" for liquid consuming workshops :)

Don't expect it to be perfect though...

I may also make an attempt to do something about power using workshops as well, but C++ is not my main language so I may not be able to.

Please not that my dev system WILL NOT be able to compile DFHack, so I will be providing the result as UNTESTED source code :(
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #341 on: December 30, 2013, 10:25:00 am »

OK, I have something that should work, but it is very basic (only handles magma in 3x3 workshops). I do not want to do more work on it until I know if it will compile, but seeing as I do not have the required C++ compiler some one else will need to do that step.

I will upload the code as soon as I can get to a real computer (which may be few days)
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [SUGGESTIONS] for DFhack plugins
« Reply #342 on: December 30, 2013, 05:03:51 pm »

No matter what, its good to see that someone is doing something with the suggestions in here. :)
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #343 on: December 30, 2013, 05:42:32 pm »

Faster than I thought :)

Code: [Select]

// Some of these may not be needed.
#include <stdint.h>
#include <iostream>
#include <map>
#include <vector>
#include "Core.h"
#include "Console.h"
#include "Export.h"
#include "PluginManager.h"
#include "modules/Maps.h"
#include "modules/World.h"
#include "modules/MapCache.h"
#include "modules/Gui.h"

using namespace DFHack;
using namespace df::enums;
using df::global::world;

DFHACK_PLUGIN("eat-magma");

// Only use with a NEEDS_MAGMA workshop and in a reaction that has FUEL,
// that way the workshop is guaranteed to have a usable amount of magma below.

// This program is an example of cut and paste codding at its worst,
// too bad DFHack isn't written in Go :p
// Anyway my C++ skills have atrophied more than I thought, plus I know nothing about the DFHack API...

// This function is copied directly from the steam engine plugin.
// BTW: why use the "auto" keyword? I thought that was implicit.
void decrement_flow(df::coord pos, int amount)
{
auto pldes = Maps::getTileDesignation(pos);
if (!pldes) return;

int nsize = std::max(0, int(pldes->bits.flow_size - amount));
pldes->bits.flow_size = nsize;
pldes->bits.flow_forbid = (nsize > 3 || pldes->bits.liquid_type == tile_liquid::Magma);

enable_updates_at(pos, true, false);
}

command_result eat_magma(color_ostream &out, std::vector<std::string> & params)
{
// How much to eat
int min_level = 1;

if (parameters.size() != 3) {
return CR_WRONG_USAGE;
}

// Is int the correct type to use here?
int c_x = atoi(parameters[0].c_str());
if ( c_x < 0 || c_x > 1 )
return CR_WRONG_USAGE;

int c_y = atoi(parameters[1].c_str());
if ( c_y < 0 || c_y > 1 )
return CR_WRONG_USAGE;

int c_z = atoi(parameters[2].c_str());
if ( c_z < 0 || c_z > 1 )
return CR_WRONG_USAGE;

// These will need to change for non-3x3 workshops.
int t_x = c_x-1;
int b_x = c_x+1;
int t_y = c_y-1;
int b_y = c_y+1;
int z = c_z;

for (int x = t_x; x <= b_x; x++)
{
for (int y = t_y; y <= b_y; y++)
{
auto ptile = Maps::getTileType(x,y,z);
if (!ptile || !FlowPassableDown(*ptile))
continue;

auto pltile = Maps::getTileType(x,y,z-1);
if (!pltile || !FlowPassable(*pltile))
continue;

auto pldes = Maps::getTileDesignation(x,y,z-1);
if (!pldes || pldes->bits.flow_size < min_level)
continue;

if (pldes->bits.liquid_type == tile_liquid::Magma)
{
decrement_flow(df::coord(x,y,z-1), min_level);
out.print("Successfully ate one magma.\n");
return CR_OK;
}
else
{
// Eat water here,
// if I can ever think of a way to keep the reaction from working if there is no water...
}
}
}

out.print("Failed to find magma tile.\n");
return CR_OK;
}

DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand("eat-magma", "Remove 1/7 magma from a tile below a 3x3 workshop centered on the specified location.", eat_magma));
return CR_OK;
}


I think I got all the semicolons, but I have spent so long working with Go (in which semicolons are optional and discouraged) that I have probably missed a few.
Another possible/probable problem is includes, I may have some that are not needed and lack some that I need.

This is a very basic test version, it only eats 1/7 magma and the parameters should be the center tile of a 3x3 area that the workshop should cover.

Usage:
eat-magma x y z

(I have no idea if this works, will someone please compile it for me?)
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: [SUGGESTIONS] for DFhack plugins
« Reply #344 on: December 31, 2013, 10:29:33 am »


Just something i was working on...
« Last Edit: December 31, 2013, 10:31:43 am by Warmist »
Logged
Pages: 1 ... 21 22 [23] 24 25 ... 61