forgottenserver icon indicating copy to clipboard operation
forgottenserver copied to clipboard

createItemType Via Lua

Open MillhioreBT opened this issue 3 years ago • 2 comments

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 the data/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
})

MillhioreBT avatar Mar 02 '21 02:03 MillhioreBT

If you're constraining this to just data/items/ then isn't it going against modularity of Revscripts as mentioned somewhere else by @EvilHero90 ?

DSpeichert avatar Feb 06 '22 06:02 DSpeichert

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.

EvilHero90 avatar Aug 16 '22 00:08 EvilHero90