forgottenserver
forgottenserver copied to clipboard
createItemType Via Lua
Pull Request Prelude
- [x] I have followed [proper The Forgotten Server code styling][code].
- [x] I have read and understood the [contribution guidelines][cont] before making this PR.
- [x] I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.
Changes Proposed
Issues addressed: Inspired by this PR #3010
Some peculiarities:
- Items can be created through lua if you are in the Rev Scripts environment
- However its charge and recharge are separate
- Can't reload with
/reload scripts
instead use/reload items
as commonly done with xml
Note:
- I have no reason to say that this is the final version, improvements in the code are probably needed
- Although I have been testing these changes for almost 2 months, it has not been peer-reviewed yet, so if you notice something weird and want to help me improve this, your suggestions are welcome.
- Note that the
items.lua
file is by convention, but you can create all the luas files you want in thedata/items
folder so that you can sort sets of items by file as you wish.
How it looks:
Game.createItemType(26378):register({
name = "gold converter",
article = "a",
weight = 1800,
duration = 604800,
charges = 500,
showcharges = true,
showduration = true
})
If you're constraining this to just data/items/
then isn't it going against modularity of Revscripts as mentioned somewhere else by @EvilHero90 ?
For now we can't really get around having it extra like we did with monsters because of the loading order (might throw errors and such if we load items from lua later than we do at xml), at current state as we approach further into lua handling stuff this is already a good enhancement and if we every going to rely on lua only we can start re arranging loading order and such so we have everything in one place.
Resolve the conflicts and then we should finaly merge it.