I've been playing around with this and so far I can't get the addItem to work unless the item is already on the level. At first I was placing them on the map in side areas where the player couldn't get. Then I discovered the spawn command and combined them into two lines in my script:
Code: Select all
spawn("xafi_khakis",level,0,0,0,0,"xafi_khakis_1")
dungeon_alcove_1.surface:addItem(xafi_khakis_1.item)
This works and I don't have to have the item placed pre-existing on the level. So my final function looks like this:
Code: Select all
function GoldLockRewardOne()
spawn("dungeon_alcove",level,11,4,0,0,"alcove_gold_reward_1")
spawn("xafi_khakis",level00,0,0,0,0,"xafi_khakis_1")
spawn("xafi_robe",level00,0,0,0,0,"xafi_robe_1")
spawn("sandals",level00,0,0,0,0,"sandals_1")
spawn("cutlass",level00,0,0,0,0,"cutlass_1")
alcove_gold_reward_1.surface:addItem(xafi_khakis_1.item)
alcove_gold_reward_1.surface:addItem(xafi_robe_1.item)
alcove_gold_reward_1.surface:addItem(sandals_1.item)
alcove_gold_reward_1.surface:addItem(cutlass_1.item)
lock_gold_reward_1:destroy()
end
This snippet makes the lock disappear and an alcove appear in a specific location with a specific set of items. Right now it's instant and 'magical' but I'm going to add a hudPrint and am trying to figure out how to make a sound play too.