AWAY FROM US - Documentation
  • 📄คู่มือการใช้งาน ( Document )
  • 🌍การใช้งานเว็บไซต์
    • วิธีการสมัครสมาชิก
    • ลืมรหัสผ่านทำยังไง ?
    • เปลี่ยน IP ที่ผูกยังไง ?
    • สถานะของทรัพยากรณ์ดูยังไง ?
  • ☄️AFUCore
    • ⚙️Configuration (ตั้งค่า)
      • Events ของอาชีพ
      • เฟรมเวิร์ค (Framework)
      • คลังไอเทม (Inventory)
      • การแจ้งเตือน (Notifications)
      • ผู้เล่น (Players)
      • อาวุธ (Weapons)
      • ดีบัค (Debug)
      • ทึกฐานข้อมูล (Queries)
    • Client
      • PlayerData
        • ข้อมูลผู้เล่น (PlayerData)
      • Functions
        • ระบบบัญชี (Accounts)
        • ระบบไอเทม (Item System)
        • ระบบอาชีพ (Job System)
        • ระบบการแจ้งเตือน (Notification System)
      • Game
    • Common
      • Faker
      • Math
      • Logger
      • String
      • Table System
      • Config
      • Timeout
    • Shared
    • Server
      • Command
      • OneSync
      • Item
      • Job
      • Player
      • xPlayer
  • 📂ทรัพยากรณ์
    • 📄วิธีการใส่ License
    • 🛍️AFU Enhanced Shop
      • คู่มือการตั้งค่า
    • 💞AFU.Status
      • exports ที่มีให้ใช้
    • 📧AFU.Mailbox
    • 🔮AFU.Gasha
      • Config.lua
      • Config.OpenZone.lua
      • ปัญหาที่พบบ่อยใน AFU.Gasha
  • ⚠️ข้อตกลงการให้บริการ
    • Terms & Conditions
    • ❓ปัญหาที่พบบ่อย
Powered by GitBook
On this page
  • ภาพรวม
  • ที่อยู่ไฟล์
  • ฟังก์ชัน
  • PositiveOnly
  • Round
  • GroupDigits
  • Trim
  • FormatMs
  • FormatMsTag
  • หมายเหตุ
  1. AFUCore
  2. Common

Math

Server & Client Supported

ภาพรวม

ฟังก์ชันสำหรับการคำนวณและจัดรูปแบบตัวเลขต่างๆ

ที่อยู่ไฟล์

source/modules/common/math.lua

ฟังก์ชัน

PositiveOnly

เอาเฉพาะค่าบวก ถ้าเป็นค่าลบจะคืนค่า 0

พารามิเตอร์
ประเภท
คำอธิบาย

value

number

ค่าที่ต้องการตรวจสอบ

ค่าที่ส่งกลับ: number - ค่าบวกหรือ 0

-- ตัวอย่างการใช้งาน
print(AFUCore.Math.PositiveOnly(5))    -- 5
print(AFUCore.Math.PositiveOnly(-3))   -- 0
print(AFUCore.Math.PositiveOnly(0))    -- 0

Round

ปัดเศษตัวเลขตามจำนวนทศนิยมที่กำหนด

พารามิเตอร์
ประเภท
คำอธิบาย

value

number

ตัวเลขที่ต้องการปัดเศษ

numDecimalPlaces

number

จำนวนตำแหน่งทศนิยม

ค่าที่ส่งกลับ: number - ตัวเลขที่ถูกปัดเศษแล้ว

-- ตัวอย่างการใช้งาน
print(AFUCore.Math.Round(3.14159, 2))  -- 3.14
print(AFUCore.Math.Round(3.14159, 0))  -- 3
print(AFUCore.Math.Round(3.14159))     -- 3

GroupDigits

แบ่งหลักตัวเลขด้วยเครื่องหมาย , (หรือตามที่กำหนดใน locale)

พารามิเตอร์
ประเภท
คำอธิบาย

value

number

ตัวเลขที่ต้องการแบ่งหลัก

ค่าที่ส่งกลับ: string - ตัวเลขที่ถูกแบ่งหลักแล้ว

-- ตัวอย่างการใช้งาน
print(AFUCore.Math.GroupDigits(1000))      -- "1,000"
print(AFUCore.Math.GroupDigits(1000000))   -- "1,000,000"
print(AFUCore.Math.GroupDigits(1234.56))   -- "1,234.56"

Trim

ตัดช่องว่างหน้า-หลังข้อความ หรือตัดช่องว่างทั้งหมด

พารามิเตอร์
ประเภท
คำอธิบาย

value

string

ข้อความที่ต้องการตัดช่องว่าง

allSpaces

boolean

true = ตัดทุกช่องว่าง, false = ตัดเฉพาะหน้า-หลัง

ค่าที่ส่งกลับ: string - ข้อความที่ถูกตัดช่องว่างแล้ว

-- ตัวอย่างการใช้งาน
print(AFUCore.Math.Trim("  hello  "))          -- "hello"
print(AFUCore.Math.Trim("  hello  world  "))   -- "hello  world"
print(AFUCore.Math.Trim("  hello  world  ", true))  -- "helloworld"

FormatMs

แปลงเวลาจากมิลลิวินาทีเป็นรูปแบบ HH:MM:SS

พารามิเตอร์
ประเภท
คำอธิบาย

ms

number

เวลาในหน่วยมิลลิวินาที

ค่าที่ส่งกลับ: string - เวลาในรูปแบบ HH:MM:SS

-- ตัวอย่างการใช้งาน
print(AFUCore.Math.FormatMs(3600000))    -- "01:00:00"
print(AFUCore.Math.FormatMs(65000))      -- "00:01:05"
print(AFUCore.Math.FormatMs(5000))       -- "00:00:05"

FormatMsTag

แปลงเวลาจากมิลลิวินาทีเป็นข้อความ (hr, hrs, min, mins, sec, secs)

พารามิเตอร์
ประเภท
คำอธิบาย

ms

number

เวลาในหน่วยมิลลิวินาที

ค่าที่ส่งกลับ: string - เวลาในรูปแบบข้อความ

-- ตัวอย่างการใช้งาน
print(AFUCore.Math.FormatMsTag(3600000))   -- "1 hr"
print(AFUCore.Math.FormatMsTag(7200000))   -- "2 hrs"
print(AFUCore.Math.FormatMsTag(60000))     -- "1 min"
print(AFUCore.Math.FormatMsTag(120000))    -- "2 mins"
print(AFUCore.Math.FormatMsTag(1000))      -- "1 sec"
print(AFUCore.Math.FormatMsTag(2000))      -- "2 secs"

หมายเหตุ

  • ฟังก์ชันเหล่านี้ช่วยในการจัดการตัวเลขและการแสดงผล

  • GroupDigits ใช้เครื่องหมายตามการตั้งค่าภาษา (locale)

  • FormatMs และ FormatMsTag ใช้สำหรับแสดงเวลาในรูปแบบที่อ่านง่าย

PreviousFakerNextLogger
☄️