mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 19:10:25 +00:00
[Quest API] Add convert_money_to_string() to Perl/Lua (#3418)
* [Quest API] Add convert_money_to_string() to Perl/Lua
# Perl
- Add `quest::convert_money_to_string(money_hash)`.
# Lua
- Add `eq.convert_money_to_string(money_table)`.
# Notes
- Allows operators to convert money in to a readable string using `Strings::Money`.
# Examples
## Perl
```pl
sub EVENT_SAY {
if ($text=~/#a/i) {
my %money_data = (
"platinum" => 3123,
"gold" => 5692,
"copper" => 9
);
quest::message(315, quest::convert_money_to_string(%money_data));
}
}
```
## Lua
```lua
function event_say(e)
if e.message:find("#a") then
local money_data = {
gold = 12,
silver = 523904,
copper = 3
}
eq.message(315, "Lua: " .. eq.convert_money_to_string(money_data))
end
end```
* Update lua_general.cpp
This commit is contained in:
@@ -5325,6 +5325,25 @@ void Perl__send_channel_message(Client* from, const char* to, uint8 channel_numb
|
||||
quest_manager.SendChannelMessage(from, to, channel_number, guild_id, language_id, language_skill, message);
|
||||
}
|
||||
|
||||
std::string Perl__convert_money_to_string(perl::hash table)
|
||||
{
|
||||
uint64 platinum = table.exists("platinum") ? static_cast<uint64>(table["platinum"]) : 0;
|
||||
uint64 gold = table.exists("gold") ? static_cast<uint64>(table["gold"]) : 0;
|
||||
uint64 silver = table.exists("silver") ? static_cast<uint64>(table["silver"]) : 0;
|
||||
uint64 copper = table.exists("copper") ? static_cast<uint64>(table["copper"]) : 0;
|
||||
|
||||
if (
|
||||
!copper &&
|
||||
!silver &&
|
||||
!gold &&
|
||||
!platinum
|
||||
) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
return Strings::Money(platinum, gold, silver, copper);
|
||||
}
|
||||
|
||||
void perl_register_quest()
|
||||
{
|
||||
perl::interpreter perl(PERL_GET_THX);
|
||||
@@ -5649,6 +5668,7 @@ void perl_register_quest()
|
||||
package.add("collectitems", &Perl__collectitems);
|
||||
package.add("commify", &Perl__commify);
|
||||
package.add("completedtasksinset", &Perl__completedtasksinset);
|
||||
package.add("convert_money_to_string", &Perl__convert_money_to_string);
|
||||
package.add("countitem", &Perl__countitem);
|
||||
package.add("countspawnednpcs", &Perl__countspawnednpcs);
|
||||
package.add("createdoor", (uint16(*)(const char*, float, float, float, float))&Perl__CreateDoor);
|
||||
|
||||
Reference in New Issue
Block a user