DoomRL > Modding

Can we have tutorial on how to make a the main.lua file?

<< < (4/6) > >>

SPTX:

--- Quote from: yaflhdztioxo on March 30, 2013, 07:47 ---You are missing a comma.  The functions are just like the other attributes--they must be comma delimited.

--- End quote ---
Where is that comma supposed to go?
I tried on both lines of each and none want to work.

yaflhdztioxo:
After the 'end' statement.


--- Code: ---{
...,
OnEquip = function (self,player)
player.res_acid = player.res_acid+50
end,
OnRemove = function (self,player)
player.res_acid = player.res_acid-50
end,
}

--- End code ---

This is an assignment, just like hp = 50 is an assignment.  In that context there is no difference between the number 50 and the big block of text from function() to end; both are just objects being assigned to a table index.
What you are actually doing is creating a Lua table with a bunch of attributes which is then being passed to the register_item procedure.  Lua tables have a fairly simple set of rules.  One of them is that multiple assignments must be separated by a comma.  The last comma is technically superfluous but it's easy to forget to add it when you expand a definition so I suggest adding it anyway.

SPTX:
Welp, I just tried and it yields the same error.

yaflhdztioxo:
Post your current procedure as a non-jpeg so I can copy it in and see what happens.

And fer chrissakes, use indenting :/.  I cannot stress this enough for new coders.  It will make your life and by extension my life easier.

Autoquark:
I've done some experimentation:

Weapon resistance attributes grant Torso and Foot resistance when wielded. Prepared weapons do not grant resistance. Weapons with resistance attributes have braces appended to their name with the first letter of the resistance(s) - for example, a pistol granting positive melee resistance and negative acid resistance (i.e. vulnerability) in some quantity appears as:

pistol (2d4) [6/6] {m-a}

The resistance value is not shown in the inventory sidebar.

Ammo packs do not grant resistance when prepared, although the resistance attribute is shown in the inventory sidebar.

So you don't need your hooks to make the player resistant - just set a resistance value on the item.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version