Configurations
การกำหนดค่าระบบปลูกพืช (Growth Garden สำหรับการปรับแต่งและกำหนดค่าต่างๆ ของระบบ
⚙️ การกำหนดค่าหลัก
Limit Configuration
Config = {
limit = 1000, -- จำนวนพืชสูงสุดต่อผู้เล่น
}
limit
number
จำนวนพืชสูงสุดที่ผู้เล่นแต่ละคนสามารถปลูกได้
1000
การตั้งค่าพืช
Config.Plants = {
['seed_name'] = {
label = 'Plant Name',
type = 'seed_name',
stages = { ... },
materialHash = { ... },
anims = { ... },
growthTimeSec = 1800,
feedIncreaseTimeSec = 900,
fertilizerMax = 600,
feedText = 'รดน้ำ',
products = { ... }
}
}
label
string
ชื่อพืชที่แสดงในเกม
type
string
ประเภทของเมล็ดพันธุ์
growthTimeSec
number
เวลาเติบโตของพืช (วินาที)
feedIncreaseTimeSec
number
เวลาเพิ่มจากการรดน้ำ (วินาที)
fertilizerMax
number
ปุ่ยสูงสุดที่สามารถใส่ได้ (วินาที)
feedText
string
ข้อความที่แสดงเมื่อรดน้ำ
ขั้นตอนการเจริญเติบโต (Stages)
stages = {
{model = 'bzzz_plants_onion_01'}, -- 0-19%
{model = 'bzzz_plants_onion_01'}, -- 20-49%
{model = 'bzzz_plants_onion_02'}, -- 50-79%
{model = 'bzzz_plants_onion_02'}, -- 80-99%
}
แต่ละขั้นตอนจะกำหนดโมเดลที่แสดงตามเปอร์เซ็นต์การเติบโต
Material Hash
materialHash = {
[-1885547121] = true,
[-2041329971] = true,
[-1595148316] = true,
[1333033863] = true,
[-913351839] = true,
[-461750719] = true,
[-1286696947] = true,
[1639053622] = true,
}
กำหนดประเภทพื้นที่สามารถปลูกพืชได้ (ดิน, หญ้า, ทราย เป็นต้น)
แอนิเมชัน (Animations)
anims = {
place = {
type = 'anim',
dict = 'amb@world_human_gardener_plant@male@base',
anim = 'base',
prop = {
model = 'prop_cs_trowel',
bone = 6286,
coords = vector3(0.025, -0.002, -0.018),
rotation = vector3(0.0, -242.8, -123.6)
},
duration = 3000
},
feed = { ... },
fertilizer = { ... },
gather = { ... }
}
ประเภทของแอนิเมชัน
place
แอนิเมชันเมื่อปลูกเมล็ดพันธุ์
feed
แอนิเมชันเมื่อรดน้ำ
fertilizer
แอนิเมชันเมื่อใส่ปุ่ย
gather
แอนิเมชันเมื่อเก็บเกี่ยว
ผลผลิต
products = {
{
rare = 0, -- ระดับความหายาก (0=ธรรมดา, 1=หายาก, 2=พิเศษ)
rate = 50, -- เปอร์เซ็นต์โอกาสได้รับ
reward = {{name = 'fruit_corn_n', count = {1, 3}}}, -- รางวัลหลัก
bonus = { -- รางวัลโบนัส
{name = 'seed_melon', count = {1, 1}, rare = 1, rate = 1},
{name = nil, count = {1, 1}, rare = 0, rate = 99}
},
model = 'bzzz_plants_onion_03' -- โมเดลเมื่อพร้อมเก็บเกี่ยว
}
}
การกำหนดค่าสปริงเกลอร์ (Sprinklers)
Config.Sprinklers = {
['sprinkler_basic'] = {
label = 'Basic Sprinkler',
type = 'sprinkler_basic',
model = 'v_ret_gc_sprinkler',
scale = 1.0,
radius = 4.0,
expireTimeSec = 3600,
materialHash = { ... },
anims = { ... }
}
}
label
string
ชื่อสปริงเกลอร์
type
string
ประเภทสปริงเกลอร์
model
string
โมเดลของสปริงเกลอร์
scale
number
ขนาดของโมเดล
radius
number
รัศมีการรดน้ำ (เมตร)
expireTimeSec
number
เวลาหมดอายุ (วินาที)
การกำหนดค่าไอเทม (Items)
Config.Items = {
['item_name'] = {
remove = true,
server_using = function(cfg, xPlayer, item) ... end,
client_using = function(cfg, item) ... end,
server_used = function(cfg, xPlayer, item, client_result) ... end,
client_used = function(cfg, item, server_result) ... end
}
}
server_using
ตรวจสอบเงื่อนไขฝั่งเซิร์ฟเวอร์ก่อนใช้ไอเทม
client_using
ดำเนินการฝั่งไคลเอนต์เมื่อใช้ไอเทม
server_used
ดำเนินการฝั่งเซิร์ฟเวอร์หลังใช้ไอเทม
client_used
ดำเนินการฝั่งไคลเอนต์หลังใช้ไอเทม
ตัวอย่างไอเทม
บัวรดน้ำ
['water_can'] = {
remove = false, -- ไม่ลบไอเทมหลังใช้
server_using = function(cfg, xPlayer, item)
return true -- อนุญาตให้ใช้เสมอ
end,
client_using = function(cfg, item)
if IsFacingWater(5) then -- ตรวจสอบว่าหันหน้าไปทางน้ำ
-- ดำเนินการแอนิเมชัน
end
end
}
เมล็ดพันธุ์
['seed_corn'] = {
remove = true,
type = 'seed_corn',
-- ฟังก์ชันการใช้งาน...
}
ปุ๋ย
['fertilizer_basic'] = {
remove = true,
fertilizerSec = 300, -- 5 นาที
-- ฟังก์ชันการใช้งาน...
}
ตัวอย่างการกำหนดพืชใหม่
-- เพิ่มพืชใหม่ชื่อ "มะเขือเทศ"
Config.Plants['seed_tomato'] = {
label = 'Tomato',
type = 'seed_tomato',
stages = {
{model = 'bzzz_plants_tomato_01'},
{model = 'bzzz_plants_tomato_02'},
{model = 'bzzz_plants_tomato_03'},
{model = 'bzzz_plants_tomato_04'},
},
materialHash = {
[-1885547121] = true, -- ดิน
[-2041329971] = true, -- หญ้า
-- เพิ่มพื้นผิวอื่นๆ ตามต้องการ
},
anims = {
-- ใช้แอนิเมชันเดียวกับพืชอื่น
place = Config.Plants['seed_corn'].anims.place,
feed = Config.Plants['seed_corn'].anims.feed,
fertilizer = Config.Plants['seed_corn'].anims.fertilizer,
gather = Config.Plants['seed_corn'].anims.gather,
},
growthTimeSec = 45 * 60, -- 45 นาที
feedIncreaseTimeSec = 15 * 60, -- 15 นาที
fertilizerMax = 20 * 60, -- 20 นาที
feedText = 'รดน้ำ',
products = {
{
rare = 0,
rate = 60,
reward = {{name = 'fruit_tomato_n', count = {2, 4}}},
bonus = {{name = 'seed_potato', count = {1, 1}, rare = 1, rate = 5}},
model = 'bzzz_plants_tomato_harvest'
},
{
rare = 1,
rate = 30,
reward = {{name = 'fruit_tomato_r', count = {2, 4}}},
bonus = {{name = 'seed_potato', count = {1, 1}, rare = 1, rate = 15}},
model = 'bzzz_plants_tomato_harvest'
},
{
rare = 2,
rate = 10,
reward = {{name = 'fruit_tomato_e', count = {1, 2}}},
bonus = {{name = 'seed_potato', count = {1, 1}, rare = 1, rate = 30}},
model = 'bzzz_plants_tomato_harvest'
},
}
}
-- เพิ่มไอเทมเมล็ดพันธุ์มะเขือเทศ
Config.Items['seed_tomato'] = lib.table.deepclone(Config.Items['seed_corn'])
Config.Items['seed_tomato'].type = 'seed_tomato'
หมายเหตุสำคัญ
Material Hash: ค่า hash ของพื้นผิวต่างๆ ที่สามารถปลูกพืชได้ ควรทดสอบในเกมเพื่อหาค่าที่ถูกต้อง
เวลา: ทุกค่าเวลาใช้หน่วยเป็นวินาที
30 * 60
= 30 นาที60 * 60
= 1 ชั่วโมง
โมเดล: ต้องแน่ใจว่าโมเดลที่ระบุมีอยู่จริงในเกม
แอนิเมชัน: Dictionary และชื่อแอนิเมชันต้องถูกต้องตาม GTA V Animation Dictionary
การคัดลอกไอเทม: ใช้
lib.table.deepclone()
เพื่อคัดลอกการกำหนดค่าไอเทมเดิม
เทคนิคการปรับแต่ง
การปรับเวลาเติบโต
เพิ่ม
growthTimeSec
= พืชโตช้าลง (ยากขึ้น)ลด
growthTimeSec
= พืชโตเร็วขึ้น (ง่ายขึ้น)
การปรับความหายากของผลผลิต
เพิ่ม
rate
ของrare = 0
= ได้ผลผลิตธรรมดามากขึ้นเพิ่ม
rate
ของrare = 2
= ได้ผลผลิตหายากมากขึ้น
การปรับประสิทธิภาพสปริงเกลอร์
เพิ่ม
radius
= รดน้ำได้ไกลขึ้นเพิ่ม
expireTimeSec
= ใช้งานได้นานขึ้น
Last updated