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

revscriptsys #2558

Merged
merged 18 commits into from Apr 16, 2019
Merged

revscriptsys #2558

merged 18 commits into from Apr 16, 2019

Conversation

EvilHero90
Copy link
Contributor

@EvilHero90 EvilHero90 commented Apr 5, 2019

creates a new folder called 'scripts' in the data folder.

lua files placed in the 'scripts' or sub folders will automaticly get registered on load with the right setup ofcourse.

Registering happens in the lua file itself, doesn't require xml settings.

lua files can be deactivated by placing a '#' infront of the filename ex: '#position.lua' it wont get loaded then.

console
It provides the normal lua interface error system

Currently supports:

  • Actions
  • Creaturescripts
  • Globalevents
  • Movements
  • Talkactions
  • Monsters

For a longer explanation and examples #2555

Co-Authored-By: Sam thesumm@users.noreply.github.com

EvilHero90 and others added 2 commits April 5, 2019 03:30
creates a new folder called 'scripts' in the data folder.

lua files placed in the 'scripts' or sub folders will automaticly get registered on load with the right setup ofcourse.

Registering happens in the lua file itself, doesn't require xml settings.

lua files can be deactivated by placing a '#' infront of the filename ex: '#positions.lua' it wont get loaded then.

Currently it supports:
-Actions
-TalkActions
-CreatureEvents
-GlobalEvents
-MoveEvents

There is still stuff on the todo list but they'll get added sooner or later.

Co-Authored-By: Sam <thesumm@users.noreply.github.com>
added boost-filesystem to appveyor.yml
fixed a few more compiler errors.
src/movement.h Outdated Show resolved Hide resolved
src/movement.h Outdated Show resolved Hide resolved
src/script.cpp Outdated Show resolved Hide resolved
src/script.cpp Outdated Show resolved Hide resolved
EvilHero90 and others added 4 commits April 5, 2019 12:28
removed using namespace for std / boost filesystem
had to make adjustment so lua callbacks and xml settings work alongside and don't crash the server
Have to revert the function + callback for stepin/stepout & additem/removeitem as it doesn't make sense on the second look and might cause a stackoverflow
I've also reworked the equip/dequip so it doesn't get double calls.
It'll first check if functions return true if not it won't bother to read the callback

accidently used an old spellbook.lua

added :aid(ids) :uid(ids) functions for MoveEvents
Could revert most of movements.h

made the declaration of the static functions more clear

Co-Authored-By: Damian Jarek <djarek@users.noreply.github.com>
@EvilHero90
Copy link
Contributor Author

The basic system is now working without any problems so far, would be good to have a few more reviews before I expand to Monsters / NPC's and such.

data/scripts/actions/spellbook.lua Outdated Show resolved Hide resolved
data/scripts/talkactions/position.lua Outdated Show resolved Hide resolved
djarek
djarek previously approved these changes Apr 6, 2019
@djarek djarek dismissed their stale review April 6, 2019 20:35

Not ready yet

removed commentary from movement.cpp
added newline for position.lua
reworked spellbook.lua with table.concat
src/actions.h Outdated Show resolved Hide resolved
- MonsterType's can now be created through lua functions.
- added an interface to create MonsterType's easily through lua files (register_monster_type.lua)
- added #example.lua in 'scripts\monsters\'
- renamed action vector functions for a better standard
- renamed _lib folder to lib, this folder gets now loaded when the other lib folder gets loaded aswell
- moved loading lua scripts out of the scriptfilemanager, we need to load everything after monsters etc. is loaded so MonsterType script manipulation does work
- added Loot() & MonsterSpell() metatables
removed test outfit from MonsterType
@EvilHero90
Copy link
Contributor Author

Feel free to keep suggesting stuff, if someone thinks I'm missing something just let me know

@andersonfaaria

This comment was marked as abuse.

@raymondtfr
Copy link
Contributor

I think we should consider creating a new branch for fully implementing revscriptsys and all the useful metatables and new events we can think of, as well as completely getting rid of XML by converting everything to revscriptsys to test its features and stability until it is considered stable... and maybe also implement OTFB map format, and maybe using a .json for instead of xml for items 🌮 .

@mattyx14
Copy link
Contributor

As for example this system will implement something similar to items.srv

https://github.com/TwistedScorpio/Nostalrius/blob/master/data/items/items.srv
to eliminate dependency on items.xml-otb

@Znote
Copy link
Member

Znote commented Apr 10, 2019

There are alot of ideas spawning from this pull request, but currently it does not break backwards compatibility, and functions as a partial port of a few sample scripts.

Lets keep it that way, once it gets merged we can send additional pull requests that "revscriptify" the repo, without sending this particular pull request into complete development hell.

Since there is no issues merging this as is (once the remaining checklist tasks are done), we can branch off and work on suggestions provided by @raymondtfr, @andersonfaaria and @mattyx14 in separate branches and pull requests.

At least thats what I think, get this "core" merged, then begin to play with innovation that expands on this. If said innovation takes time, no problem since this is already functioning as mods pack and can be utilized by the community right away.

@EvilHero90
Copy link
Contributor Author

I think we should consider creating a new branch for fully implementing revscriptsys and all the useful metatables and new events we can think of, as well as completely getting rid of XML by converting everything to revscriptsys to test its features and stability until it is considered stable... and maybe also implement OTFB map format, and maybe using a .json for instead of xml for items 🌮 .

Those are my future plans for it, but before all that we need to make the transition for it and I have to create some xml parsers which automaticly transfers old xml/lua stuff into the new lua format, because taking away xml dependency will give a huge hit to people who have tons of custom stuff already, if we don't provide an auto parser so people have to do it by hand.

I'm not familiar with OTFB (would be nice to provide a link)
About .json I'm not really happy with that actually, I'd rather stick to one scripting language for the entire engine, I've already plans for items in lua which allow even virtualization and such, so we take away stricktness on items.

As for example this system will implement something similar to items.srv

https://github.com/TwistedScorpio/Nostalrius/blob/master/data/items/items.srv
to eliminate dependency on items.xml-otb

same as above.

There are alot of ideas spawning from this pull request, but currently it does not break backwards compatibility, and functions as a partial port of a few sample scripts.

Lets keep it that way, once it gets merged we can send additional pull requests that "revscriptify" the repo, without sending this particular pull request into complete development hell.

Since there is no issues merging this as is (once the remaining checklist tasks are done), we can branch off and work on suggestions provided by @raymondtfr, @andersonfaaria and @mattyx14 in separate branches and pull requests.

At least thats what I think, get this "core" merged, then begin to play with innovation that expands on this. If said innovation takes time, no problem since this is already functioning as mods pack and can be utilized by the community right away.

I'm completly on your side, the entire revscriptsys for now will be completly vanilla, just a bridge between core and lua to register the events, anything beyond that can be done by future PR's once it's implemented

@EvilHero90
Copy link
Contributor Author

I have to strip down the check list, neither of the remaining can be easily ported without major rework which could most likely break stuff.
I'd rather have it this far merged and once we decide to step up and port it completly to lua only, then we can re work the other stuff aswell without worrying about xml dependency

- added createFunctions(class) it virtually creates the get/set functions for the class passed on
- 'events' folder in monsters is excluded from auto parsing files, as we load callbacks for specific monsters which have an eventFile set to 'true' or 'filename' in this folder.
@EvilHero90 EvilHero90 changed the title [WIP] revscriptsys revscriptsys Apr 13, 2019
@Znote Znote requested a review from djarek April 14, 2019 11:50
src/script.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@djarek djarek left a comment

Choose a reason for hiding this comment

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

LGTM

src/monsters.cpp Outdated Show resolved Hide resolved
src/monsters.cpp Outdated Show resolved Hide resolved
- added Game.createMonsterType(name)
- reworked MonsterType(name) to return nil if the MonsterType does not exist, so we don't suddenly create a MonsterType if we do not even want to.
- changed reinterpret_cast to static_cast
- added an option to disable scripts console logging, it can be disabled by placing 'showScriptsLogInConsole = false' into config.lua
creates a new folder called 'scripts' in the data folder.

lua files placed in the 'scripts' or sub folders will automaticly get registered on load with the right setup ofcourse.

Registering happens in the lua file itself, doesn't require xml settings.

lua files can be deactivated by placing a '#' infront of the filename ex: '#positions.lua' it wont get loaded then.

Currently it supports:
-Actions
-TalkActions
-CreatureEvents
-GlobalEvents
-MoveEvents

There is still stuff on the todo list but they'll get added sooner or later.

Co-Authored-By: Sam <thesumm@users.noreply.github.com>

cleanup on script.cpp

removed using namespace for std / boost filesystem

small fixes on movements & function additions

Have to revert the function + callback for stepin/stepout & additem/removeitem as it doesn't make sense on the second look and might cause a stackoverflow
I've also reworked the equip/dequip so it doesn't get double calls.
It'll first check if functions return true if not it won't bother to read the callback

accidently used an old spellbook.lua

added :aid(ids) :uid(ids) functions for MoveEvents

Monster handler & other stuff

- MonsterType's can now be created through lua functions.
- added an interface to create MonsterType's easily through lua files (register_monster_type.lua)
- added #example.lua in 'scripts\monsters\'
- renamed action vector functions for a better standard
- renamed _lib folder to lib, this folder gets now loaded when the other lib folder gets loaded aswell
- moved loading lua scripts out of the scriptfilemanager, we need to load everything after monsters etc. is loaded so MonsterType script manipulation does work
- added Loot() & MonsterSpell() metatables

small changes

- added createFunctions(class) it virtually creates the get/set functions for the class passed on
- 'events' folder in monsters is excluded from auto parsing files, as we load callbacks for specific monsters which have an eventFile set to 'true' or 'filename' in this folder.

stripping path string

added Game.createMonsterType(name) and small fixes

- added Game.createMonsterType(name)
- reworked MonsterType(name) to return nil if the MonsterType does not exist, so we don't suddenly create a MonsterType if we do not even want to.
- changed reinterpret_cast to static_cast

config.lua option for console

- added an option to disable scripts console logging, it can be disabled by placing 'showScriptsLogInConsole = false' into config.lua
@Znote Znote merged commit 62dac47 into otland:master Apr 16, 2019
@raymondtfr
Copy link
Contributor

raymondtfr commented Apr 17, 2019

Wiki must be updated because these changes requires vcpkg install boost-filesystem:x32-windows or vcpkg install boost-filesystem:x64-windows to be added to vcpkg Windows installation guides in order for it to compile (atleast in Visual Studio 2017). @djarek @Znote

You should update config.lua.dist with the new option showScriptsLogInConsole = false, because it is missing as of now

Using talkaction /reload will crash the server.

@EvilHero90

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

7 participants