Jump to content

celludriel

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by celludriel

  1. Thanks so it's not in yet, I was kinda hoping it was. I just like to play a small galaxy game with a few factions and create an empire from scratch
  2. Is it possible yet to change the size ?
  3. I've learned that you can only do these kind of things on scripts attached to objects that exist client and server side at the same time with the same unique id. You can't just instance a class and expect it to be able to do this kind of communication. For future reference
  4. Hey, I want to create a script that when "a player" enters a sector he finds a ship waiting there to be killed, so he can get a reward. What I do NOT want is attach a script with callback to the Player() object. Logically I would attach it to When a player enters and it is for the first time, the ship to destroy gets created. Sound and simple design ... HOWEVER since sectors aren't all generated before hand. I need a way, when the mission gets created the sector gets loaded, the script attached to it and then the sector can be unloaded whatever ... I just want my script attached to it. In pseudo code that would become Mission mission = createMission("DestroyShip") Sector sector = mission.findSectorToKillShip() sector.attachScriptToLoadShipSpawner() - So first my logic to create a mission saving the data somewhere - Then finding an empty sector somewhere AND loading it into a variable - Attach my callback script to the sector that when "a player" enters no matter who, the ship to destroy gets spawned I've been browsing SectorSpecifics, the sectors folder and other scripts and usually Sector() is used but this implies probably the sector the player is in and that's not what I'm aiming for, that target could be in a sector nobody has ever visited
  5. You are not wrong, however, looking through the lua scripts code the game seems very tight coupled to them. Avorion is a great sandbox, with the right mechanics, where we could basically build any kind of gameplay in. So decouple all scripts that have to deal with the story from required to optional and moreover configurable and we come into all new terrain. Suppose you got the following directory setup Avorion Data Mods Official The official directory holds all the scripts and mechanics to play the current story in Avorion. However when I delete the Mods folder whole, avorion would still work. You can go to stations, mine, get attacked by pirates and aliens. Just the story won't be there. Then I can change the galaxy size however I like, cause you could still play the game in any size (within reason you need minimum sizes). If you then could setup the story with parameters, the story could adapt itself to any size as well. It's another kind of design. One that I think is possible within the constraints there are right now. However ... it's a LOOOOOT of work, pretty sure the lead developer doesn't have that time :(
  6. Can this be maintained further ? This is an interesting thing to have but it's outdated to version 0.10
  7. I did I'm using a Json library now http://dkolf.de/src/dkjson-lua.fsl/home It works but I lose some flexibility and some overhead decoding and encoding the json. We are devs we always find workarounds, doesn't mean we have to like them though. Not even fond on having to use globals ... it's not like they act as singletons ...
  8. Aaargh this is frustrating, you can't use an array as a global variable {}. This sucks , it's one of the most important things you want an associative array you can use as context to reach in your entire application. Think springbeans in the springcontext if you would talk java. Or just basic IOC design in any other programming language .... grmbl ... I guess I could work with tons of prefixed variables in the global array as string ... but that is just messy ...
  9. I added a setGlobal in one script that runs on server startup, then tried using that global in a script attached to a script with getGlobal. But its always nil Are those globals just global in one script run, or are they global over the game instance ? If they are just global in one script run, I'm so very very boned ....
  10. I like to be able to start a game with a different size galaxy between limits you can choose between x 1000 and X 250 Y 1000 and Y 250 I know this will be hard since you have some hard coded limits in the LUA scripts but can't you change those by calls to the Server().GetGalaxyDimensions or something ?
  11. Yeah I did the same at first to, hoping to find any kind of label in any of the lua files. I got the workaround working now. I just don't understand his design decision on this one. It makes sense to have different menu options for different kind of ships. So I get it why you would attach UI scripts to ship objects. But surely you want options available all the time. The API also doesn't allow to addScripts on the Server object which for me sucks since I wanted to have a persistant script running each five seconds server side. I had to workaround it with a coroutine and bootstrap it to server.lua ... which I'm not happy about, but ... it works.
  12. I got following class package.path = package.path .. ";data/scripts/lib/?.lua" package.path = package.path .. ";data/scripts/empirebuilder/?.lua" package.path = package.path .. ";data/scripts/empirebuilder/util/?.lua" package.path = package.path .. ";data/scripts/player/?.lua" require ("EmpireBuilderUtil") TaskManager = require ("TaskManager") local EmpireBuilderGameManager = {} EmpireBuilderGameManager.__index = EmpireBuilderGameManager local function new() logDebug("creating EmpireBuilderGameManager") local obj = setmetatable({}, EmpireBuilderGameManager) local taskManager = TaskManager() obj.taskManager = taskManager EmpireBuilderContext["GameManager"] = obj return obj end function EmpireBuilderGameManager:registerCallbacks(player) logDebug("begin TaskManager:registerCallbacks") player:registerCallback("onSectorEntered", "attachEmpireInformationWindowOnSectorChange") player:registerCallback("onShipChanged", "attachEmpireInformationWindowOnShipChange") logDebug("end TaskManager:registerCallbacks") end function attachEmpireInformationWindowOnSectorChange() logDebug("begin TaskManager:attachEmpireInformationWindowOnSectorChange") end function attachEmpireInformationWindowOnShipChange(playerIndex, craftIndex) logDebug("begin TaskManager:attachEmpireInformationWindowOnShipChange", playerIndex, " + ", craftIndex) local player = Player(playerIndex) logDebug("player ", player) invokeClientFunction(player, "addEmpireInformationWindowToShip") logDebug("end invoke addEmpireInformationWindowToShip") end function addEmpireInformationWindowToShip() logDebug("addEmpireInformationWindowToShip") local ship = Player().craft if not ship.isDrone then if not ship:hasScript("data/scripts/empirebuilder/ui/EmpireInformationWindow.lua") then ship:addScriptOnce("data/scripts/empirebuilder/ui/EmpireInformationWindow.lua") end end end function EmpireBuilderGameManager:executeGameLoop() logDebug("begin executeGameLoop") self.taskManager:executeTaskManager() logDebug("end executeGameLoop") end return setmetatable({new = new}, {__call = function(_, ...) return new(...) end}) There is an instance of it running serverside, but I want to add a script to the ship a player is flying after he changed ships. If you look at the method attachEmpireInformationWindowOnShipChange you see I do a clientInvokeFunction, but it never triggers and there is no error. not in server log or client log. However I do find logDebug("end invoke addEmpireInformationWindowToShip") in the server log, so the method has been triggered somehow, just never run. Without any logging I have no idea why. Except maybe that the instance of EmpireBuilderGameManager isn't know at client side ? Is there a better way for the server to call client methods ?
  13. Oh I know that though, I got it working by attaching it to the ship the player is flying, but well that is not really what I wanted. It's a workaround but a lot of code for something this simple. I had hoped there was an easy way to attach it to the player instead of an Entity Really hope there is a way or there will be one in the future
  14. Is it possible to add a new top right menu icon to a player ? In most of the current scripts they all get attached to a ship, but I want my icon to be present all the time. It made sense attaching it to the player but I just can't get it to work. Client side there is no addScript() option to Player. And I don't think the code belongs server side. Has anyone got some experience with it yet ?
  15. I was wondering if it is possible to mod the size of the galaxy ? One million sectors is nice and all but it's a bit much as well. So I was trying to figure out if the galaxy is hard coded in the exe or a a lua script. I found the galaxy.lua function Balancing_GetDimensions() return 1000 end but changing that didn't do much , so I guess this is only used to make calculations and not for the galaxy generation ?
  16. Well I went ahead and wrote a bit of code that I think would be fundamental for my idea. A way to run the empire builder manager on it's own thread. Well ... kinda ... since it seems there is no such thing as real multi threading in lua. I had to come up with some kind of middle way solution. I'm happy with the results but it could be a lot better, since I'm hijacking server.lua Update() for scheduling my thread. Which should be a not done scenario when the game updates server.lua I'm SOL. thread class: package.path = package.path .. ";data/scripts/lib/?.lua" package.path = package.path .. ";data/scripts/?.lua" package.path = package.path .. ";?.lua" package.path = package.path .. ";?" local EmpireBuilderThread = {} EmpireBuilderThread.__index = EmpireBuilderThread local function new() local obj = setmetatable({}, EmpireBuilderThread) printlog("creating thread") obj.thread = coroutine.create(obj.createEmpireBuilderMasterThread) coroutine.resume(obj.thread) return obj end function EmpireBuilderThread:resume() printlog("resuming thread", type(self)) coroutine.resume(self.thread) end function EmpireBuilderThread:createEmpireBuilderMasterThread() local elapsedTime = os.clock() local nextTriggerTime = elapsedTime + 5 while true do printlog("thread is running") if elapsedTime >= nextTriggerTime then nextTriggerTime = nextTriggerTime + 5 end coroutine.yield() elapsedTime = os.clock() end end return setmetatable({new = new}, {__call = function(_, ...) return new(...) end}) server updates function onStartUp() Server():registerCallback("onPlayerLogIn", "onPlayerLogIn") Server():registerCallback("onPlayerLogOff", "onPlayerLogOff") Galaxy():registerCallback("onPlayerCreated", "onPlayerCreated") Galaxy():registerCallback("onFactionCreated", "onFactionCreated") empireBuilderThread = EmpireBuilderThread(); end function update(timeStep) local guardianRespawnTime = Server():getValue("guardian_respawn_time") if guardianRespawnTime then guardianRespawnTime = guardianRespawnTime - timeStep; if guardianRespawnTime < 0 then guardianRespawnTime = nil end Server():setValue("guardian_respawn_time", guardianRespawnTime) end empireBuilderThread:resume() end See how I instantiate the thread at startup and use the update to resume my yielded thread. It works but certainly not how I want it. There should be some kind of callback on serverStart and serverUpdate so I could move all my code to the thread class. Well not sure if I'm going to continue yet, but it does seem to be possible finishing my idea
  17. Hey, This is something I had in mind during my X3 days but never worked out because of the frustrating scripting language x3 had. Avorion gives the right tools to maybe do it though. Lua is a pretty strong language to develop in and it might work. This is what I had in mind. The players are all agents for a wealthy family that wants to create an empire from scratch. Each player that joins the server gets tasks assigned all towards building that empire. These tasks can be building a station in a specific system, mining an amount of resources that you need to deliver to a station, Destroy a pirate den threatening the empire, Build a bunch of ships for the empire, Help fight of an enemy empire invasion, etc... With each accomplished task the wealthy family rewards the player with money, mods or whatever drives a player to complete the tasks. There could be an end goal to win the game for example the family owns a certain amount of territory, or gains an amount of money, influence. This would be a first iteration of the mod, in later iterations there could be AI families , managed by some sort of simulation running in the background, rivaling the players family but that is an all other matter of complexity. I see following challenges in this endeavor - Players login and logoff their tasks need to be persisted somewhere and each time they login their needs to be a way to load the task and assign it to the logged in player. - There needs to be one master script running from the moment the server starts. Lets call it the game mode script, that assigns tasks to players, keeps track of their progress, gives rewards, checks if the game has been won, generates events to annoy the players while they finish their tasks etc... I'm not sure Avorion offers a way to run a script on it's own thread. Also this script has to be crash proof, suppose it goes down, it needs to reset itself so the server doesn't have to be rebooted. - The tasks given to the players need to make sense in building an empire. So that means devising some kind of order in things. First build a farm station, before building a habitat for example. Deciding when to start building the next station in queue or give a task to supply an existing station with supplies. - Since not all sectors are loaded all the time, means supplies of stations don't dwindle, there needs to be a simulation that takes supplies from stations. There are probably many more challenges, this won't be easy to create. However should it work, I think this can be a fun game mode, giving meaning to the Avorion sandbox. So what do you guys think, possible, don't even try, could be fun, worst idea ever etc... ?
×
×
  • Create New...