Maris Posted April 21, 2016 Share Posted April 21, 2016 (edited) I want to pay attention that the order that items are returned is not defined in pairs function. I'm not sure if it's important (e.g. for initializing EQUIPSLOT_IDS in constnts.lua and equippable_replica.lua). I mean that modders have to do the same thing. And order may change after adding new items to EQUIPSLOTS table. May be it's ok for now. But as I said officially order is not defined so it's a little risk. I think it's better to make indexed table as main table. Edited April 21, 2016 by Maris Link to comment https://forums.kleientertainment.com/forums/topic/66504-lua-pairs-and-new-equipslot_ids-variable/ Share on other sites More sharing options...
Muche Posted April 21, 2016 Share Posted April 21, 2016 It seems to me, that the implementation of pairs is stable. By that I mean that it returns the items in the same order if the source table is the same. Otherwise things like this in prefab/player_classified.lua would fail fairly quickly when run on the server vs. the client: for k, v in pairs(AllRecipes) do if IsRecipeValid(v.name) then inst.recipes[k] = net_bool(inst.GUID, "builder.recipes["..k.."]", "recipesdirty") inst.bufferedbuilds[k] = net_bool(inst.GUID, "builder.buffered_builds["..k.."]", "bufferedbuildsdirty") end end Link to comment https://forums.kleientertainment.com/forums/topic/66504-lua-pairs-and-new-equipslot_ids-variable/#findComment-753555 Share on other sites More sharing options...
Maris Posted April 21, 2016 Author Share Posted April 21, 2016 (edited) It returns the items in the same order for now. But could it be a source of random rare bugs/crashes in future? Btw I had some issues after deleting some recipes. For example: AllRecipes.spear = nil --all_cleints_require_mod Edited April 21, 2016 by Maris Link to comment https://forums.kleientertainment.com/forums/topic/66504-lua-pairs-and-new-equipslot_ids-variable/#findComment-753558 Share on other sites More sharing options...
Developer PeterA Posted April 21, 2016 Developer Share Posted April 21, 2016 Yup, there's some room for error here with mods modifying the tables. There's quite a few areas in our code that relies on the stability of pairs with tables that are identical, mods obviously will affect that, so I'll be looking into complications from this. Thanks! Link to comment https://forums.kleientertainment.com/forums/topic/66504-lua-pairs-and-new-equipslot_ids-variable/#findComment-753704 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now