Files

57 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ladyitem.js — main() (satır 1)
[← ladyitem.js](index.md) · [← Master](../../wiki.md)
Parça 1/2 · [sonraki](main-2.md)
```javascript
function main(c)
{
var source = c.getSubject();
var result = source.rayTrace(64);
if (!result || !result.isEntity()) return;
var target = result.getEntity();
if (!target || !target.isPlayer()) return;
if (target.isSame(source)) return;
// hedef oyuncunun adını kaydet
source.getStates().setString("hedef_oyuncu", target.getName());
var inv = target.getInventory();
var ui = mappet.createUI(c, "handler").background().notClosable();
var panel = ui.graphics().id("panel");
var click = ui.click().id("click");
var alBtn = ui.button("Al").id("al");
var cikis = ui.icon("close").id("kapat");
panel.rxy(0.5, 0.5).wh(340, 220).anchor(0.5);
click.rxy(0.5, 0.5).wh(340, 220).anchor(0.5);
alBtn.rx(0.5, -40).ry(0.5, 95).wh(80, 22);
cikis.rx(0.5, 148).ry(0.5, -107).wh(20, 20).tooltip("Kapat", 1);
// panel çiz
panel.rect(0, 0, 340, 220, 0xff111118);
panel.rect(0, 0, 340, 28, 0xff1e1e28);
panel.rect(0, 27, 340, 1, 0xff3a3a4a);
panel.text(target.getName() + " - Envanter", 170, 8, 0xfff0f0f8, 0.5, 0.0);
// 36 slot çiz — 4 satır 9 sütun
for (var i = 0; i < 36; i++)
{
var col = i % 9;
var row = Math.floor(i / 9);
var x = 10 + col * 36;
var y = 34 + row * 36;
panel.rect(x, y, 32, 32, 0xff2a2a3a);
panel.rect(x + 1, y + 1, 30, 30, 0xff1a1a24);
var item = inv.getStack(i);
if (item && !item.isEmpty())
{
var isim = item.getItem().getId().split(":")[1];
if (isim.length > 5) isim = isim.substring(0, 5);
panel.text(isim, x + 16, y + 8, 0xffffffff, 0.5, 0.0);
```