Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createItemType Via Lua #3354

Closed
wants to merge 3 commits into from

Conversation

MillhioreBT
Copy link
Contributor

@MillhioreBT MillhioreBT commented Mar 2, 2021

Pull Request Prelude

  • I have followed [proper The Forgotten Server code styling][code].
  • I have read and understood the [contribution guidelines][cont] before making this PR.
  • 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
})

@@ -312,6 +322,8 @@ class ItemType
std::unique_ptr<Abilities> abilities;
std::unique_ptr<ConditionDamage> conditionDamage;

std::map<std::string, bool> hasEdited;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I will use a unordered_map, I am hoping to find more things to improve the code

data/lib/compat/compat.lua Outdated Show resolved Hide resolved
Co-authored-by: Evil Puncker <EPuncker@users.noreply.github.com>
@DSpeichert
Copy link
Member

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

@EvilHero90
Copy link
Contributor

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.

Copy link
Contributor

@EvilHero90 EvilHero90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tons of formatting issues in luascript.cpp which need to be resolved but other then that it looks fine.

} else if (abilitieName == "absorbpercentall") {
int16_t value = getNumber<int16_t>(L, 3);
for (uint8_t i = COMBAT_NONE; i <= COMBAT_COUNT; i++) {
abilities.absorbPercent[i] += value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
abilities.absorbPercent[i] += value;
abilities.absorbPercent[indexToCombatType(i)] += value;

} else if (abilitieName == "fieldabsorbpercentall") {
int16_t value = getNumber<int16_t>(L, 3);
for (uint8_t i = COMBAT_NONE; i <= COMBAT_COUNT; i++) {
abilities.fieldAbsorbPercent[i] += value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
abilities.fieldAbsorbPercent[i] += value;
abilities.fieldAbsorbPercent[indexToCombatType(i)] += value;

@MillhioreBT MillhioreBT closed this Sep 7, 2023
@MillhioreBT MillhioreBT deleted the createItemType_via_lua branch September 7, 2023 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants