Back again!!
Can anyone tell me why the following code will not work?
party.party:getChampion(3):insertItem(1,spawn("long_sword").item)
A little testing with the print statement tells me the sword was created and (with different code) I can place it directly in front of the party then pick it up but I cannot get it to insert into a champion's hand.
insertItem
- Zo Kath Ra
- Posts: 944
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: insertItem
Did you put it inside a script entity, but outside of any functions?
Doesn't work, probably because it's too early, but I have no idea for what.
This works when put inside a script entity:
Doesn't work, probably because it's too early, but I have no idea for what.
This works when put inside a script entity:
Code: Select all
delayedCall(self.go.id, 0, "test")
function test()
party.party:getChampion(3):insertItem(1,spawn("long_sword").item)
endRe: insertItem
Thank you. Works great. But if you are trying to delay the event, why the zero time on the delayedCall?
Re: insertItem
In this case, just including the function name would also work.
Funny thing is, it works for me with just the base statement.
However the editor needs to be restarted each time; there is a certain persistence of state between previews, that only gets reset by a reload.
Code: Select all
function test()
party.party:getChampion(3):insertItem(1,spawn("long_sword").item)
end
test()
Code: Select all
party.party:getChampion(3):insertItem(1,spawn("long_sword").item)Re: insertItem
Some such things worked for me too when place directly in the script but others didn't.
I remember trying to get code to work when placed directly in the script and it wouldn't so I placed a simple print("hello") line into the same script. It still didn't work but 'hello' printed out on the screen so I know the script was run.
The delayedCall(self.go.id, 0, functionName) seems to work fine but even with that sometimes I have to replace the '0' with '0.1' to get it to work.
I think it must have something to do with the order of things in the mod.
I remember trying to get code to work when placed directly in the script and it wouldn't so I placed a simple print("hello") line into the same script. It still didn't work but 'hello' printed out on the screen so I know the script was run.
The delayedCall(self.go.id, 0, functionName) seems to work fine but even with that sometimes I have to replace the '0' with '0.1' to get it to work.
I think it must have something to do with the order of things in the mod.