Jump to content

Rinart73

Members
  • Posts

    416
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Rinart73

  1. That's normal Lua behaviour. Sadly though you can't use DLL Lua modules in Avorion because Lua is included in exe (no export data).
  2. My mod TransferCargoTweaks was updated to 0.17.1+, so please add it to the list
  3. Bump, because this is important. Having a way to specify script index in "invokeFunction" will give players a way to work with multiple instances of the same script. And having an API to install upgrades will allow modders to create functional solutions, that will be compatible with default Upgrade Tab.
  4. As far as I can see, trading with stations uses following functions: "data/scripts/lib/tradingmanager.lua" line 860 - "TradingManager:buyFromShip(shipIndex, goodName, amount, noDockCheck)" line 968 - "TradingManager:sellToShip(shipIndex, goodName, amount, noDockCheck)" line 1054 - "TradingManager:buyGoods(good, amount, otherFactionIndex, monetaryTransactionOnly)" line 1096 - "TradingManager:sellGoods(good, amount, otherFactionIndex, monetaryTransactionOnly)" In all of them "this object" is always a station. local stationFaction = Faction() And "other object" is a ship, that can be player or npc. local otherFaction = Faction(otherFactionIndex) So you need to check if 'stationFaction' is a player faction: if stationFaction.isPlayer then .. And then do some stuff
  5. Bix, yeah, it's in the same script. I'll see what I can do :)
  6. Tested on Windows 10 x64. If you'll define "LUA_PATH" system variable (for example you installed Lua for some tasks), calling "require" in your ingame scrips may fail. Ingame Lua will check "LUA_PATH" variable and use it instead of "..steamapps/common/Avorion/". At least this is what happens with mods (maybe because "require" is being called using "pcall"): local ext, err = pcall(require, 'mods/ExtTurretFactory/scripts/entity/merchants/turretfactory') if not ext then print('Mod: ExtTurretFactory, failed to extend turretfactory.lua!') end module 'mods/ExtTurretFactory/scripts/entity/merchants/turretfactory' not found: 2018-07-20 15-53-31| no field package.preload['mods/ExtTurretFactory/scripts/entity/merchants/turretfactory'] 2018-07-20 15-53-31| no file 'C:\Program Files\Lua\5.2\lua\mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.luac' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file '/data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'data/scripts/lib/mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.lua' 2018-07-20 15-53-31| no file 'C:\Program Files (x86)\Steam\steamapps\common\Avorion\bin\mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.dll' 2018-07-20 15-53-31| no file 'C:\Program Files (x86)\Steam\steamapps\common\Avorion\bin\loadall.dll' 2018-07-20 15-53-31| no file '.\mods/ExtTurretFactory/scripts/entity/merchants/turretfactory.dll' After I removed "LUA_PATH" system variable, everything worked just fine, so it's not mod problem. So please make ingame Lua ignore "LUA_PATH" variable.
  7. Bix, glad that you liked it :) Feel free to post your suggestions
  8. Shrooblord, thank you :) If you have any suggestions I will be glad to discuss them.
  9. Updated mod to 0.17.1+, made significant performance improvements, fixed few things. Fixed: Cargo sorting order for languages that have non-latin characters (no more "Ö" after "Z" in German) Improved: Mod updated to Avorion 0.17.1+ Improved: utf8 library was rewritten to make mod more performance friendly Improved: Localized 'Search' label Improved: Search toogle button now has different icon when search query is not empty. This should be helpful in case you searched something and then toggled search bar off
  10. Mod was updated to 0.16.5+ with new features and no more predictions. So it's a release now - 1.0.0 Added: Added new API function 'i18n.getMods' - returns the list of all mods that tried or successfully registered in i18n Added: Config - new option 'secondaryLanguages' - mod will try to load translation files for specified languages if it will fail to load for language, determined by 'getCurrentLanguage()'. Also, first language in this array will be used as server language Improved: Mod updated to Avorion 0.16.5+ - using 'getCurrentLanguage' function now for client-side Improved: Function 'i18n.registerMod' now returns various error codes that will help to determine the source of a problem Removed: Config - options 'langCode' and 'detectMode' Removed: API functions 'i18n.detectLanguage' and 'i18n.getLanguage' were removed. Use native function 'getCurrentLanguage' instead I'm a slowpoke, I know :)
  11. Apparently there is a way to remove entity scripts by indeces. I recently looked at the entitydbg.lua code to try to add more functionality and fix some stuff. And I found this: function removeEntityScript(script) if onClient() then local entry = tonumber(scripts[scriptList.selected]) if entry ~= nil then invokeServerFunction("removeEntityScript", entry) invokeServerFunction("sendEntityScripts", Player().index) end return end print("remove script " .. script) Entity():removeScript(tonumber(script)) print("remove script done ") end Remember, entitydbg panel allows you to remove any script from sector or entity. It's just not specified in Documentation that we can use a number here. But we still don't have a way to install upgrades.
  12. 1.0.1 update Fix: Now mod is truly client-side If mod will be installed only on client-side, it will use a way to detect, when it should use 'refreshUI' instead of full 'onShowWindow'. If mod will be installed on server-side, it will directly call 'refreshUI' instead of 'onShowWindow'. In this case, you will need to install mod on client-side only if you want to have additional QoL content. As for other mods, I will release merged versions soon.
  13. Oh, you're right, thanks :) I will look if I can make this client-side only. As for adding compatibility for our mods, bobisback and Hammelpilaw, I can look at your mods source code and provide compatibility patches/files.
  14. As you can see in this thread and few others, it appears, that: If you have several scripts with the same script path, attached to the entity, you can call 'invokeFunction' only on first one. Based on that, first suggestion is: please add a way to replace scriptName with scriptIndex when calling invokeFunction like we can do with 'removeScript' function. Second suggestion is about installing upgrades. Currently modders can only remove them - they remove script and on C side upgrade disappears (from upgrades UI etc). But we can't install upgrade. We can add system upgrade to the entity, but it will not appear in the Upgrades Tab. Update: Edited post, because you can specify script index in 'removeScript' function to remove specific script. But there is still no way to invoke function on a certain script. Update: As of version 0.18.2 we can now install/uninstall upgrades. Thanks
  15. Oh, you're right, I misread. You can create new thread in the Suggestions forum.
  16. Your current problem is that invokeFunction addresses the first attached script with certain name. If done correctly, my way will work a bit differently: instead of invoking upgrades functions, upgrades themselves will invoke function of storage script (which can be only one per entity). And then your script will successfully get info from storage.
  17. I think I have an idea. We attach an additional script to the entity, that will act as a storage for our system upgrades info. Then we modify our system upgrades. I think that will be no problem for you since you already did this (energybooster.lua doesn't have getSeed function by default). So, we modify onInstalled function and invoke function of our storage script to 'register' it and pass upgrade info (seed, etc). There might be some issues with keeping the link which module is which, though. In the end, you will invoke function of storage script to get what you need. I'll try it in the next days to see if this will work.
  18. Documentation/Sector [server].html There are different functions, but I think the best way to do this will be using following code (on the server side): local wormholes = {Sector():getEntitiesByType(EntityType.WormHole)} This code will result in a table of wormhole entities in current sector, though I didn't looked how to detect if it's a just wormhole or a gate (which is actually a wormhole too, but you can see the difference). There is "onPlayerEntered" in Documentation/Sector Callbacks.html "onSectorEntered" in Documentation/Player Callbacks.html Use registerCallback(string callbackName, string functionName) to attach your function to the event. But if gates are missing only when sector is reloading, you can just add your code to the "DefaultSector.initialize" function (which is in "data/scripts/sector/sector.lua"). This way it will be called only when server is loading Sector in memory, not when each player re-enters a sector. There are some mod folder style that was developed by a modding community to help make mods more compatible with each other. But I suggest you to just write your code as it is, any way that is comfortable for you. Later on, as you will make everything work, you can start to optimize things and make mod structure "right".
  19. There can be a ton of projects, I don't have a whole concept of mine yet, but I can name reasons to have this functions in game: There a lot of suggestions, lots of things that people want but devs will not make just because they have their roadmap and certain suggestions will require a lot of time. Or when a suggestion doesn't fit the game concept that devs have. Also mods help to keep interest for the game even after second, third.. time you won. So, I think that devs should expand Scripting API not just when they add a new thing like an Alliances, but generally allow modders to do more things, not just drawing, that I mentioned here. This is a sandbox with modding support. Basicaly this means, that Devs should do basic things and modders should expand the game. Look at Minecraft: Vanilla: mine diamonds, kill the dragon. Look at Minecraft mods: whoa! Look at Skyrim, the game that is still alive only because huge expansions that modders made (not because of some Special Edition). - Originally I wanted to display some effects on the ship, as a part of some space discovery mod. Exposions and other effects needed to be constantly created and draw too much attention to them. So for the space corrosion effect I wanted to draw a few overlaying textures on some blocks. Then I discovered that drawDebugSphere doesn't work. And this annoyed me, because it's hard to test system upgrade radius without seeing it.
  20. Basically now we have a way to draw 2D UI: text, rect, border and turret/fighter tooltips. Drawing debug sphere/box/line is either broken or unintuitive, because I din't see anybody who got this working. I suggest to implement 2 ways of drawing things: First one is usual drawSomething (line, circle for 2D UI context; sphere, box, plain (flat 2d surface) for 3D context). Yes, it is expensive to draw things from Lua but it doesn't mean that we shouldn't have this possibility. Second one is more performance-friendly and has some slight similarities with how SVG image format works in HTML (and how game UI currently works too). So, instead of: local color = ColorARGB(0.5, 0.35, 0.35, 0.35) function draw() drawSphere(Entity().position, 10, color) end We will create a DrawSphere as an object. We can: Hide or show it whenever we want to (toggle its drawing) Adjust its position, rotation Link it to the entity: position only or position + rotation This way there will be no drawback from Lua calling draw function every frame. C++ will handle all drawing, while just getting commands like "show", "hide", "move", "destroy". local mySphere local sphereTimer function init() local entity = Entity() mySphere = DrawSphere() mySphere.lockToEntity = entity mySphere.lockToEntityOrientation = true mySphere.entityOrientation = entity.orientation mySphere.color = ColorARGB(0.5, 0.35, 0.35, 0.35) mySphere.translation = dvec3(10, 15, 10) end function someEvent() -- maybe button was pressed or damage taken mySphere.show() sphereTimer = 30 end function updateClient(timeStep) if sphereTimer > 0 then sphereTimer = sphereTimer - timeStep if sphereTimer <= 0 then mySphere.hide() end end end
  21. Just imagine how it will affect collision detection. I mean, if this block is not a solid circle. Pretty sure that devs said that there will be no dynamic parts somewhere on this forum.
  22. Nevermind, it appears that I searched "active sell/buy" code in a wrong location.
  23. Starting from version 1.0.1, mod is client-side. But it is safe to install it on server-side. (Actually, if you'll install it on server-side, you will not need to install it on client-side, unless you want additional QoL changes) I saw many people (including me) reporting that in 0.15.x after they press "Build Turret" button, their ingredients amount reset, so they can't build several identical turrets in a row. I found a source of the problem and here is my small mod that fixes this behaviour. But I thought that I want to add more useful features to this (that I personally would like to see in vanilla), so.. from now on your ingredients amount will save for each weapon type, each rarity. This way you can easilly compare different turrets or rarities without need of re-adjusting values every time you switch. Basically these values will save as long as you're in the sector so reopening the window will not reset anything too. I might add the feature of saving values even after revisiting sector in the future. Post if you want to. Installing [*]Make a copy of 'data/scripts/entity/merchants/turretfactory.lua' [*]Unpack mod archive into Avorion folder Uninstalling [*]Restore file 'data/scripts/entity/merchants/turretfactory.lua' Changelog TurretFactoryAmountFix-1.0.1-0.15.x.zip TurretFactoryAmountFix-old-versions.zip
  24. This happens not because of factory price, but because of how getFactoryUpgradeCost function works (productions.lua). function getFactoryUpgradeCost(production, size) -- calculate the difference between the value of ingredients and results local ingredientValue = 0 local resultValue = 0 for _, ingredient in pairs(production.ingredients) do local good = goods[ingredient.name] ingredientValue = ingredientValue + good.price * ingredient.amount end for _, result in pairs(production.results) do local good = goods[result.name] resultValue = resultValue + good.price * result.amount end local diff = resultValue - ingredientValue local costs = diff * 1000 * size return costs end While we have following in productionsindex.lua: table.insert(productions, {factory="${good} Farm ${size}", ingredients={{name="Energy Cell", amount=6, optional=1}, {name="Water", amount=30, optional=0}}, results={{name="Potato", amount=35}}, garbages={{name="Oxygen", amount=8}}}) So, basically we have following values: ingredientValue = 300 + 600 = 900 resultValue = 840 diff = -60 costs = -60 * 1000 * size Is optional ingredient even a thing? How it works? Anyway, thats because this happens.
×
×
  • Create New...