MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / GiveItem

Method GiveItem

internal/scripting/actor_func.go:453–484  ·  view source on GitHub ↗
(itm any)

Source from the content-addressed store, hash-verified

451}
452
453func (a ScriptActor) GiveItem(itm any) {
454
455 var sItem *ScriptItem
456
457 if itmScriptItem, ok := itm.(*ScriptItem); ok {
458 sItem = itmScriptItem
459 } else if itmInt, ok := itm.(int); ok {
460 sItem = CreateItem(itmInt)
461 } else if itmInt64, ok := itm.(int64); ok {
462 sItem = CreateItem(int(itmInt64))
463 } else if itmInt32, ok := itm.(int32); ok {
464 sItem = CreateItem(int(itmInt32))
465 } else if itmFloat64, ok := itm.(float64); ok {
466 sItem = CreateItem(int(itmFloat64))
467 }
468
469 if sItem != nil {
470 iRecord := sItem.itemRecord
471 if a.characterRecord.StoreItem(*iRecord) {
472 if a.userId > 0 {
473
474 events.AddToQueue(events.ItemOwnership{
475 UserId: a.userId,
476 Item: *iRecord,
477 Gained: true,
478 })
479
480 }
481 }
482 }
483
484}
485
486func (a ScriptActor) TakeItem(itm ScriptItem) {
487 if a.characterRecord.RemoveItem(*itm.itemRecord) {

Callers 14

onEnterFunction · 0.80
onCommandFunction · 0.80
onEnterFunction · 0.80
onEnterFunction · 0.80
onCommandFunction · 0.80
onCommandFunction · 0.80
onCommandFunction · 0.80
onCommand_useFunction · 0.80
onAskFunction · 0.80
onGiveFunction · 0.80
onEnterFunction · 0.80
onCommandFunction · 0.80

Calls 3

AddToQueueFunction · 0.92
CreateItemFunction · 0.85
StoreItemMethod · 0.45

Tested by

no test coverage detected