Page 109 of 400
Re: Ask a simple question, get a simple answer
Posted: Sat Jan 02, 2016 11:44 pm
by Eleven Warrior
Hi all
I have this Script that allows you to give a NPC a item and the item is destroyed and then you can do some other stuff. (Below)
Code: Select all
function Reward1(self, npc, item)
if item.go.name == "rock" then
hudPrint("Thank You.")
return true
end
hudPrint("I have no need for this item.")
return false
end
How can I add more items to this code eg: Say I have to give the NPC a Rock, Gem and sword. All the items need to be destroyed and then cool stuff happens like running a script function(s) etc....
Any help would be most appreciated thxs

Re: Ask a simple question, get a simple answer
Posted: Wed Jan 06, 2016 6:16 pm
by Vandalar
Hello Eleven Warrior,
If I understand you correctly, you must :
-Check if it's the correct item
-If all three items were given to the npc, it trigger the reward function. ?
I'm not an expert in LUA scripting, so they are maybe better way to do it, but in your shoes, I would do something like this :
-Call checkItemReceived instead of Reward1.
-checkItemReceived, in the if statement, will call checkReward, it will return true if it was a proper item (and in the process, destroy the item, print something to the player, the global variable rewardCheckVar will be incremented before the second part of the statement is called) and IF rewardCheckVar is equal to 3, then it means the players gave all items to the npc
-If both condition are true, then call Reward1
Please note
I didn't test the code below, but it should be close enough for your needs. If you need more help, p.m. me.
Code: Select all
function checkItemReceived(self, npc, item)
if checkReward(self, npc, item) and rewardCheckVar == 3 then
Reward1(npc)
end
end
function checkReward(self, npc, item)
if item.go.name == "rock" then
hudPrint("Thank You.")
rewardCheckVar = rewardCheckVar + 1 --global var, you could use a counter too
item.go:destroy()
return true
end
if item.go.name == "ancient_claymore" then
rewardCheckVar = rewardCheckVar + 1
hudPrint("Thank You.")
item.go:destroy()
return true
end
if item.go.name == "power_gem" then
rewardCheckVar = rewardCheckVar + 1
hudPrint("Thank You.")
item.go:destroy()
return true
end
hudPrint("I have no need for this item.")
return false
end
function Reward1(self, npc)
--Do whatever you want, give XP or items.
end
Regards,
Vand
Re: Ask a simple question, get a simple answer
Posted: Thu Jan 07, 2016 2:10 am
by Eleven Warrior
Thank you so kindly will test it now. Thxs again man awesome

Re: Ask a simple question, get a simple answer
Posted: Sat Jan 09, 2016 12:52 am
by Eleven Warrior
Hi all
I have this object that I want to spawn directly on the party: See below Code(s). When the Object is spawned it is spawned in front of the party and not on the same square they are in.
Ye I know I can use: spawn("spider_web_fake",7,7,28,0,0,"swf7a") but the web is spawned after a certain event directly on the party. Any help as to what imam doing wrong here?
Code: Select all
function SpiderQueen7A()
spawn("spider_web_fake", party.level, dx, dy, 0, party.elevation )
end
Object Code:
Code: Select all
defineObject{
name = "spider_web_fake",
baseObject = "base_floor_decoration",
components = {
{
class = "Model",
model = "mod_assets/models/spider/tow_spider_web.fbx",
},
},
placement = "floor",
editorIcon = 104,
minimalSaveState = true,
}
EDIT: Errrr sorry about this I now know where I went wrong
It's: spawn("spider_web_fake", party.level, party.x, party.y, party.facing, party.elevation )
Re: Ask a simple question, get a simple answer
Posted: Wed Jan 20, 2016 7:18 pm
by Slicyr
What prop object is it usually that the blob spell is shot from? It was pretty long since I played the game, and I honestly can't remember. Were there even blobs in LoG2?
Daemon Heads just seem too menacing to be shooting harmless projectiles. I can't even remember what was used in LoG1...
If it in fact is true that blob shooters weren't present in LoG2, could someone suggest a good prop to use? Right now I'll just settle for a receptor.
Re: Ask a simple question, get a simple answer
Posted: Wed Jan 20, 2016 8:31 pm
by THOM
In Log2 you can use Daemon Faces and the spelllauncher from the mine-set. That's how it was done in the main-campaign...
Re: Ask a simple question, get a simple answer
Posted: Wed Jan 20, 2016 9:31 pm
by Slicyr
Thank you! The mine spell launcher is perfect!
Re: Ask a simple question, get a simple answer
Posted: Sun Jan 24, 2016 4:57 am
by Eleven Warrior
Hi all.
I want to create a spell that when the player casts the spell or uses the spell scroll it will open a door or run a script. I had this in log 1 but I cannot find how I did it any help pls thxs
PS: If the player uses the Spell Scroll it cannot be used again thxs

Re: Ask a simple question, get a simple answer
Posted: Fri Jan 29, 2016 5:19 am
by Slicyr
Sorry if this already has been answered. Neither Google or the forum's search gives me any good results...
I need a script that springs a trap once a specific item is taken from an alcove. Not when any item is taken, just the specific one.
EDIT: adding some tags so that some poor soul like yesterday-me might find this if they use the forum search function: alcove remove removed specific item take taken surface
Re: Ask a simple question, get a simple answer
Posted: Fri Jan 29, 2016 6:56 am
by minmay
Connect the surface's onRemoveItem event to a script entity function. That function will receive the surface as the first parameter, and the item as the second parameter. So for instance, if you wanted to trigger it for removing a rock:
Code: Select all
function itemRemoved(surface,item)
if item.go.name == "rock" then
[spring trap]
end
end