Page 238 of 400
Re: Ask a simple question, get a simple answer
Posted: Mon May 14, 2018 9:24 pm
by Curunir
Just when you think you're getting it, the game always finds a way to smack you in the face.
I got a crash with "attempt to perform arithmetic on a nil value" using this:
Code: Select all
function spawnWalls()
spawn("swamp_toad", party.level, 12, 2, 4, party.elevation, "frogger_1")
spawn("zarchton_pair", party.level, 8, 2, 3, party.elevation, "ztons_1")
frogger_1.monster:setAIState("guard")
ztons_1.monstergroup:setAIState("guard")
end
What is wrong here? I am calling this at the end of a string of events the player has to perform. I tried using delayedCall and the other actions at the end of the sequence execute fine, then it crashes while trying to summon the monsters. The chain of LUA game files in the info dump starts with Brain.lua.
Re: Ask a simple question, get a simple answer
Posted: Tue May 15, 2018 12:46 am
by Isaac
It's the toad. You've set the facing argument to 4, but the valid range is 0-3.
Re: Ask a simple question, get a simple answer
Posted: Tue May 15, 2018 6:55 am
by Curunir
I should stop crunching so hard on that mod and also never try to write scripts past 11pm. I know what the valid facing values are but I never figured out what was wrong!
Thanks, Isaac! <3
Edit: Is there a way to edit and trim down an exported item_atlas.dds?
Re: Ask a simple question, get a simple answer
Posted: Thu May 17, 2018 2:31 pm
by Pompidom
I decided to gate everything behind currency including experience in my mod.
Experience will have to be bought.
What's the easiest way to make all monsters give 0 experience?
Re: Ask a simple question, get a simple answer
Posted: Thu May 17, 2018 3:17 pm
by Curunir
You can copy all monster definitions from the asset pack, rename the monsters' editor names (the first 'name' field in the LUA files) and give them zero in experience values under exp = XYZ in the 'Monster' class of the definition.
Or you can wait for Isaac or minmay to come up with a better way!

Re: Ask a simple question, get a simple answer
Posted: Thu May 17, 2018 4:47 pm
by Xardas
MonsterComponent:setExp(number)
Re: Ask a simple question, get a simple answer
Posted: Thu May 17, 2018 8:35 pm
by Pompidom
Xardas wrote:MonsterComponent:setExp(number)
And where exactly do I implement this line?
I added 1 single turtle on my map, it's called turtle_1
I changed it's hp value to 1 in the dungeon editor and then saved my dungeon and closed the editor.
Then I checked the lines in the dungeon.lua
Right under the set health line.
spawn("turtle",13,13,2,0,"turtle_1")
turtle_1.monster:setHealth(1)
so I tried adding turtle_1.monster:setExp(0)
I have obviously no idea what I'm doing because that didn't work

Re: Ask a simple question, get a simple answer
Posted: Thu May 17, 2018 9:15 pm
by Xardas
Don´t look into the definitions for this one.
There is an object, which is called "script_entity" in the Editor. You have to write your Code inside one of These.
Here is a simple, but not excellent solution for your Problem.
Name your Monsters ("monster_1","monster_2",etc...)
change "highest monsternumber" to the highest Monster index
e.g. monster_5 was your last monster so write: for i = 1, 5 do
then copy paste this into a lua script and it should work....
I haven´t tested it in the Editor, if there´s a Problem with it pm me.
Code: Select all
function setexp()
for i = 1, "highest monsternumber" do --put index here
local monster = findEntity("monster_"..i)
if monster then
monster. monster:setExp(0)
end
end
end
delayedCall(self.go.id, 0.1, "setexp") --calls the function at the start of the game
Also take a look at that. It´s the Scripting reference.
https://github.com/JKos/log2doc/wiki/Components
Re: Ask a simple question, get a simple answer
Posted: Thu May 17, 2018 9:59 pm
by Curunir
I need something relatively simple but I can't figure out how to do it.
I have a bossfight which changes the lighting in its room, turning off some light sources and swapping them for others. However, once the fight is over, I'd like to fade back to the original non-boss lighting. I thought about onDie hooks for the bosses, that tick down a counter, which changes lighting when the bosses die, like in Skuggasveinn's tutorial, but the monsters are spawned via script and I'm not sure how to attach onDie to spawned stuff.
Nevermind, figured it out!
boss_id_1.monster:addConnector("onDie", "countername", "decrement")
I hadn't formatted the parameters as strings with quotation marks!

Re: Ask a simple question, get a simple answer
Posted: Fri May 18, 2018 7:42 am
by Curunir
Can someone detail how and why exactly setWorldPosition() works?
The scripting reference has nothing on it, LOG2DOC tells me it takes (vec). Searching the forum shows me at least two different uses:
lr_6:setWorldPosition(26.9999,-0.49,27.5,0)
but also in a table, used by Isaac: "mine_door_spear_1", 'setWorldPosition',vec(50.65,0,49.5)
Is there anywhere I can read up on how vectors work, because I really don't understand those? I sort of figured out color vectors in sky and fog definitions but have no idea how positional ones work.
Why does the firs example use 4 values (3 commas) and the second one - just 3 values (2 commas)?