Tuesday, April 17, 2012

[FA] hooking UpdateConsumptionValues problems

Hi,
im trying to hook this function
http://pastebin.com/a3eqH3SY << original..
for some reason, it naffs all the build times up,
like it takes an etternity to build a landfac or upgrade..
also on the construction panel when you hover your mouse over a build icon..
the unit preview window shows 0 as all the rates.. and ###INF as the build time..
anyone seen this problem before... or any problems with this function in general?|||This may be one of those files that just cant be /hook'd
I seam to recall there being a few of these... some are pretty basic while others are core to the game.
You may try looking at the econ mods that GilbotX made.... He did alot of work in this field as well as work with unit / structure adjacency.
Resin|||Yeah, I wouldn't bother trying to hook it. It's 100% local variables, returns no values, and anything you do is just going to override what the original function does anyway.
What are you trying to use it for? If you're trying to do multi-source consumption, just use Fury's mod that does that already.|||post a link to that mod please mithy :)|||http://forums.gaspowered.com/viewtopic.php?f=7&t=44963&start=0
It's bundled in with my BSF mod.
Please note: in its current state, it *ONLY* works with default GPG. It's been a long time since I've really worked on it (and actually, I think the version that is there is a little out of date from what I have on my PC, but not by a whole lot).|||Cool ill check it out pal thx|||Hi,
Fury can i steal your cunsumption function.. i need to mod it a little.. to suit what i have added..
i might as well tell you..
ive done basicly the same as you have done.. adding new functions for energy/mass/buildrate usage.. except i add all the "new usages" to a table which are then accumilated and set in the consumption function.. only the consumtion function was being funny..
this gives a greater amount of control over exactly what you want your unit to use..
ive added functions for : (3 sets one for each value, mass, energy, buildrate)
addenergyusage
removeenergyusage
setenergyusage -- for adjusting and entry
getenergyusage
you can also disable/enable a usage
setenergyusageactive
setenergyusageinactive
its active by default once added.. i added the disable so you can pause it and resume.. without removing it..
a typical table entry looks like
self.EconUsage = {
energyusage = { unit = { usage = 100, enabled = true },},
massyusage = { unit = { usage = 100, enabled = true },},
buildrate = { unit = { usage = 100, enabled = true },},
}
added like so..
self:addenergyusage('unit', 100)
self:addenergyusage('enhancement-blah', 3000)
self:removenergyusage('unit')
self:removenergyusage('enhancement-blah')
self:setenergyusage('enhancement-blah', 2500)
same for mass/buildrate
i think this gives alot of flexability, its the only way i could think of to control multiple usages on per unit basis keepingt he control of each one.|||I guess if you really wanted you could.
So you know, mine is setting it all into tables as well, essentially in the following format:
self.BuffSystemFix = {
EnergyMaintOverrides = {Shield = 400, Intel = 100}
EnergyMaintIsActive = {Shield = true, Intel = false}
MassMaintOverrides = {Production = 5}
MassMaintIsActive = {Production = true}
EnergyMaintAdjs = {All = .5}
EnergyAdjsIsActive = {All = true}
MassMaintAdjs = {Generic = 1.9}
MassAdjsIsActive = {Generic = true}
}
The last 4 categories relating more to adjacency, but left open so anyone can use.
Check out my second post from the linked thread (you'll have to scroll through a bunch of crud before you get to it). It's my special features post and details how a modder can take advantage of the system.
I think my only two short comings of it so far is that I haven't fully taken into account multiple sources of the same thing (ie, multiple shield toggles or intel toggles) and I don't have it working for mods that aren't specifically coded for it.. But otherwise it's all capable of being disabled without removing the values and is working perfectly.
If you want, I can try getting you my current rendition of it, too. If need be, I can pastebin the code. I think only the primary 2 core files (unit.lua and buff.lua) have been changed since the last release.|||Hi,
CRAP! i totally forgot about buffs.. :/ what a nub..
you know this is only one part of my mod.. the energy/mass ect..
if i start taking more stuff from your mod.. specailly the buff system
our mods will be incompatable.. not that they arent now.. i would suspect they are.. :/ seeing as some of our goals for each mod are the same.. except my code is slightly different.. calling different functions.. and adding this to different tables..
my initial goal was to just add multi source energy/mass usage from the same unit..
but the more i worked on it the more i realised it wasnt as easy as first thought, it becomes a mess of bug fixes and overrides :/
what can we do pal?
i mean i need/want this functionality in my mod.. its working well now i have copied your comsumption function.. and edited it slightly to suit my needs.. ummm.. not including the buffs :/
seeing as they not compatable anyway.. can i use your buff code and edit it to suit my system? ill give you credits for the code.. saves me starting from scratch and doing the same code all over again.
i know you have put alot of work into your code and i respect this, if you dont want me to use it i wont, ill just start the work myself :) its not a problem pal :)|||So, you're talking about essentially copy/pasting my code into yours and then altering what parts you have to for them to work? I have no problem with this except... it's still a work in progress. The thought that comes to my mind is creating some kind of plugin mod or just work on having your mod load after BSF/MSS so that you can hook/override in what changes you need to for them to work correctly and then set it to require.
This weekend I'm heading over to a friend's house with my wife so she can help his fiancee with some studying. I should have internet there so I'll work on uploading the current rendition for you to grab. I won't be able to complete my current work on it, though, because my FA computer has had the OS corrupted so it won't boot. Easy fix... just reinstall. Thankfully all of my working files are backed up onto this rig. Unfortunately, I don't expect enough time to actually complete all of my work.
We'll see how things go.|||Hi,
thanks for letting me use that fury, nice one..
cool ill wait for weekend and take a look.. i look forward to that mate.
hit me up with a pm when you have uploaded it :)
im unsure about how to impliment a stable pluggin system, into my current system..
as when i started this project it was not on my mind to add that kind of support..
i would have to rewrite alot of code to do a pluggin system.. although i will seriously think hard about if i want such a system.
the whole idea for my mod is to impliment as many things into one mod as possible..
its for domino mod support (DMS) which is a self contained mod that adds many things from unit modding to layouts ... its not really an option to add a required mod then i could if needed code in my own system for what that mod does.. i only asked can i use your code because it would save me writing basicly the same system as you have done.. id actually already added the functions for multi honed usage..
it was just this one function.. that was giving me jip regarding the build times.. and build rate.. which im sure you know about you prolly had the exact same problem when you first started writing your mod.. weird things happen when the function is changed.
im not trying to steal your idea.. or take anything away from your mod.. in honesty its just a natural progression of my mod, i work on projects that require things.. i add them to mod support because near enough 100% of my mods require this mod.
i none destructively hook as many functions as possible, but sometimes this isnt enough.. in the end it boils down to one or the other.. ;/
im sorry to hear you dont have time to mod.. you have done some fine work pal..
i hope in the future you return to modding, we need people like you in our community
:)
again my friend thanks for letting me use some of your code :)|||Hey, no problem.
Really the only reason I suggest the "plugin" method is simply because I'm still developing the code. BSF itself has some compatibility issues I'm trying to resolve and then MSS... well, as I said before, unless folks specifically script for it, as of now, it isn't compatible with anything. lol
I can certainly understand and support your wanting to make everything into one mod. I personally made things separate in case there are features to one mod that people don't like but there are things in another they do. For example, my BF mod is straight bug fixes, that's it. BSF does a lot of bug fixing, but it also adds a lot of content so I kept that separate even though it was made to be backward compatible. MSS currently isn't, but if I ever get that figured out, I'll probably integrate it into BSF as it'll have no affect unless the user has a mod running that takes advantage of it.
Actually, now that I think about it, are you keeping a running log somewhere of what features/changes your mod support mod makes? If so, could I get a copy? I'd like to look it over. I could always go through the code, but that doesn't always reveal all changes. Reason being is because depending on what your doing, I'd like to considering asking you if all of my stuff (feature support and fixing stuff, not added content stuff) could be integrated into yours and (as time permits) I'd like to assist you. This way there aren't two separate projects out there essentially trying to do the same thing. :)|||Hi pal,
sadly i never thought to keep a running log from the start, BUT i shall start one..
it'll be alot of writing from scratch but ill start putting one together..
as for adding your stuff to mod support ill certainly consider adding certain things, or taking one mod and intergrating the idea into mod support, much like i am doing with the buff stuff.
DMS is not a bug fix mod persay, its primary use is to assist in completing certain things regarding unit modding.. with this comes "some bug fixing" but i wouldnt call it bug fixing i would say changing things so that they work for what is needed.
i also started adding layout support so you can easly add your own ui layouts.. (incomplete but working)
there is a bunch of other things.. tbh ive added lots of things on the fly without writing them down lol.. my bad!
your better off downloading the current version and going through the code for 30 mins just to see what ive done and how ive done it..
all this said.. yeah id defo consider adding mods you create to DMS, just remember though that its not a bug fix mod.. its for simplyfiying common tasks and adding better support for various things.|||Hmm, ok. I know that BSF is primarily about bug fixing the whole Buff system with some added content.
I think the goal in my mind was to make it so that the changes I made in my mods could be incorporated into yours and then make my other mods that required those require yours instead, that way we wouldn't have to worry about incompatibilities. However, a lot of it is based around bug fixing, too.
You can still use my code, but I think I may have to look into compatibility between our mods, see if there is some simple code changes I can do or a mod or something to fix it.|||ok i gave it some thought..
what i can do is add the bsf mod to dms but change what i need to suit my system..
but in the functions for adding the values to each consumption table.. i can fire in a check to see if your mods uid is in activemods if it is then fire off the values into your consuption table else use mine..
this check would need to go in every function that alters the consumption of a unit..
im assuming you have functions to add/remove/alter/turn on/off consumptions on a per basis?
just have a look in the current dms unit.lua economy to see the general structure of how im going to be doing it.. ill throw a check in these functions to check for your mod, ill also throw this check into the updatecomsuption values..
this way it will always use one table to store consumtion values.
working together we can figure this out pal :)|||hi mates
i am only user of mods, but i want say my 2 cents
wouldnt be good if Domino need something recode with small change of buff system fix, he made request for it and FoS in next version of BSF will do it?
this make all mods compatible, and if u two brilliant moders make it together, i guess we get more than twice time updates in same time with twice more stuff
i see u have similar view, so better one conception, make team maybe
and keep good work
|||kamilsl

No comments:

Post a Comment