Page 257 of 396
Re: Ask a simple question, get a simple answer
Posted: Thu Sep 27, 2018 10:40 pm
by Isaac
Pompidom wrote: ↑Thu Sep 27, 2018 10:13 pm
not really, but it should be easy to figure out looking at other editor files,
what I need the most help with is a scriptline that:
findEntity vampire_7 and then spawn a fire effect on the random location where his brain got disabled.
Code: Select all
--call delayedDeath() when ready
function delayedDeath()
delayedCall(self.go.id, 2, "death")
end
function death()
if vampire_7 then
vampire_7:spawn('wall_fire')
vampire_7.monster:die()
end
end
__________
Alternately:
Code: Select all
--This one can affect any monster
function delayedDeath(monsterId)
local monster = findEntity(monsterId)
if monster then
monster:spawn('wall_fire')
monster.brain:disable()
delayedCall(self.go.id, 5, 'death', monsterId)
end
end
function death(monsterId)
local monster = findEntity(monsterId)
if monster then
monster.monster:die()
monster:playSound('party_fall')
end
end
--call delayedDeath when ready
delayedDeath('vampire_7')
Re: Ask a simple question, get a simple answer
Posted: Thu Sep 27, 2018 11:08 pm
by Zo Kath Ra
Instead of spawning a wall_fire on the monster's tile, you can set the monster on fire:
viewtopic.php?f=22&t=7951&p=90491#p90491
Re: Ask a simple question, get a simple answer
Posted: Thu Sep 27, 2018 11:12 pm
by Isaac
That works.
*But it looks better to use both: (...though one might just want the vampire itself to burn.)
Code: Select all
function delayedDeath(monsterId)
local monster = findEntity(monsterId)
if monster then
monster.monster:setCondition("burning",5)
monster:spawn('wall_fire')
monster.brain:disable()
delayedCall(self.go.id, 5, 'death', monsterId)
end
end
function death(monsterId)
local monster = findEntity(monsterId)
if monster then
monster.monster:die()
monster:playSound('party_fall')
end
end
--call delayedDeath when ready
delayedDeath('vampire_7')
Re: Ask a simple question, get a simple answer
Posted: Thu Sep 27, 2018 11:31 pm
by Pompidom
EDIT: I got it working properly
Thank you!
Re: Ask a simple question, get a simple answer
Posted: Sat Sep 29, 2018 6:40 pm
by Pompidom
Is there a script/code line that resets an object to the default position it was assigned to?
In this particular case a g1_catwalk that moves up and down as an elevator.
The movement script is halted by a floor trigger and then you press a button to reset it to the default position.
Re: Ask a simple question, get a simple answer
Posted: Sat Sep 29, 2018 7:32 pm
by Isaac
Usually one just stores the location, then uses it later in the script. For one object, you can just manually record it in the script.
Code: Select all
g1_catwalk_1_starting_location = {level=1, x=15, y=15, facing=0, elevation=0} --for example
But if you have placed a lot of them (or if the object spawns at a random location each time), it is convenient to have them record their own locations into a dedicated script, with a setter function. Code placed in any of the object's onInit hooks, could call a script with whatever its current location is, and store it there for later use.
Re: Ask a simple question, get a simple answer
Posted: Sat Sep 29, 2018 7:46 pm
by Pompidom
I will just need to use it on a few objects.
I'll see what I can do with this line
Re: Ask a simple question, get a simple answer
Posted: Sat Sep 29, 2018 7:57 pm
by Isaac
Here is a more compact way to do it:
Code: Select all
g1_catwalk_1_starting_location = {15,15,0,0,1}
If used in the same script as the above:
Code: Select all
g1_catwalk_1:setPosition(unpack(g1_catwalk_1_starting_location))
_____
But of course... If it is just the one object, then all you really need is just to call the setPosition function with the known starting location:
Code: Select all
g1_catwalk_1:setPosition(15,15,0,0,1)
If you want that called from a button or trigger, then you put in in its own function, and add a connector from the trigger.
Code: Select all
function resetLoc()
g1_catwalk_1:setPosition(15,15,0,0,1)
end
Re: Ask a simple question, get a simple answer
Posted: Tue Oct 02, 2018 10:09 am
by furiousuk
Thanks @pompidom and @Zo Kath Ra for the answers on the torch stuff. Got it working now.
Now setting to work on changing particle and glow colour for different types of torch.
Re: Ask a simple question, get a simple answer
Posted: Mon Oct 15, 2018 7:24 pm
by KhrougH
here is my simple question:
i'm using a "setWorldPosition" on a "lock":
https://drive.google.com/open?id=1jMe4V ... 8n5QVcB7b
but i can't use a key to open the door because on the visual position it doesn't work and at the center of the screen (where the lock should be without "setWorldPosition") the champion throw the key.
how can i solve this problem?
for the moment i'm putting the lock in the original position,
https://drive.google.com/open?id=1QhGsX ... 3STyHnRp-E
unlock the door without opening it and when you click on the door the lock disappear (onClick ... lock:destroy)
https://drive.google.com/open?id=1xTqRw ... eu6OFPGM-
but why it doesn't work with the "world positioning"?