Page 1 of 2

Few questions

Posted: Tue Dec 25, 2012 11:55 pm
by thermalburn
A couple of quick questions:

1. is there a way to make pits(with or without trap doors) just kill the whole party rather then drop them down 1 level?

2. I made a clone of a shield and gave it a stat of Protection +2 and Evasion +2. However in game, the Protection stat does not apply to the player; the shield clearly says +2 Protection but it just doesnt apply for some reason. The Evasion stat works fine

3. I'm practicing with my scripting and im getting an error "Bad Argument to findEntity (string expected, got nil)". Here is what im doing:

There are 2 pressure plates. the first one checks to see if an entity exists; if it does then destroy it otherwise do nothing. the second spawns the entity. the player will step on the first plate (since the entity isnt spawned, then it should do nothing) then he will step on the second plate (which spawns the entity) finally he will go back to the first which this time will find the entity and destroy it.

I spawn the entity fine, but the destroy part seems to fail. here is my code:

spawn entity:

Code: Select all

function spawnMonster()
	spawn("goromorg", 3, 23, 18, 3, skellington)
end
destroy entity:

Code: Select all

function toospookyforme()
	local spawnedEntity = findEntity(skellington)
	if spawnedEntity == nil then
		print("nil")
	else
		print("destroy")
		skellington:destroy()
	end
end	
there error generates on line "local spawnedEntity = findEntity(skellington)"

thanks. i will probably update this with more questions as i work further :/

Re: Few questions

Posted: Wed Dec 26, 2012 12:00 am
by Xanathar
1 =>
Put an hidden pressure plate over the pit, and connect it to this:

Code: Select all

function gameover()
	damageTile(party.level, party.x, party.y, party.facing, 64, "physical", 100000000)
end
If you prefer to see the animation, connect it to a very short timer (like 0.5 sec or less, try what's best) and connect the timer itself to the above function.

2 => Don't know :D

3 =>
function spawnMonster()
spawn("goromorg", 3, 23, 18, 3, "skellington")
end

and

local spawnedEntity = findEntity("skellington")

Note that if you know the id this way, you should be able to use it directly as:

Code: Select all

function toospookyforme()
   if skellington== nil then
      print("nil")
   else
      print("destroy")
      skellington:destroy()
   end
end   
Disclaimer: all of this should in theory work, but I tested none.

Re: Few questions

Posted: Wed Dec 26, 2012 12:40 am
by thermalburn
great! they both worked, thanks a lot!

anyone have a solution to #2?

Re: Few questions

Posted: Wed Dec 26, 2012 1:36 am
by thermalburn
Im having some difficulty in understanding the FX setlight command.

how do i define a new FX entity?

Re: Few questions

Posted: Wed Dec 26, 2012 1:50 am
by Komag
IIRC 2 can't be solved at present, deals with "hard coded" stuff

you can lay down fx objects in the editor and mess with it via scripts later, or spawn them on the fly entirely with scripting. If it will be for lighting that is longer term than momentary, best to use custom defined light objects instead, as they persist across saves while fx lights/effects don't.

Re: Few questions

Posted: Wed Dec 26, 2012 2:00 am
by thermalburn
ah thats too bad.

what exactly is an FX entity? i dont see it anywhere in the props/items/logic screen

Re: Few questions

Posted: Wed Dec 26, 2012 2:40 am
by Neikun
Guys guys, is that a possible work around for not being able to add protection to a shield class item?


Perhaps in the party definition, a check if the item is equipped, and it runs a function that modifies the stat if it returns true?

Re: Few questions

Posted: Wed Dec 26, 2012 5:47 am
by Komag
thermalburn wrote:ah thats too bad.

what exactly is an FX entity? i dont see it anywhere in the props/items/logic screen
can't test right now, but maybe it's only visible in the all list

Re: Few questions

Posted: Wed Dec 26, 2012 6:19 am
by thermalburn
yes it is. thanks

also how do you get scripts to initialize as soon as the game is loaded? Say i have a function, how can i get it to automatically start doing its task without me having to trigger it?

Re: Few questions

Posted: Wed Dec 26, 2012 6:48 am
by Isaac
thermalburn wrote:yes it is. thanks

also how do you get scripts to initialize as soon as the game is loaded? Say i have a function, how can i get it to automatically start doing its task without me having to trigger it?
Don't put it in a function; or call the function from outside.