ID:1913455
 
(See the best response by Nadrew.)
Code:
CreateWeapon

var/_type
var/_element
var/obj/O

proc/CreateWeapon(Type,Element)
_type = Type
_element = Element
if(_type == "Sword" && _element == "Fire")
O.name = pick("Flame Saber","Firesoul Blade")
if(O.name == "Flame Saber")
O.Element = "Fire"
O.Element_Mod = 100 * (2.3/100)
world<<"[O.name] was created with [O.Element] element and [O.Element_Mod]% fire attack!"
if(O.name == "Firesoul Blade")
O.Element = "Fire"
O.Element_Mod = 100 * (3.2/100)
world<<"[O.name] was created with [O.Element] element and [O.Element_Mod]% fire attack!"



mob/verb/Create(obj/O)
CreateWeapon("Sword","Fire")


Problem description:
How do you use procs inside a datum?
Best response
var/CreateWeapon/new_weapon = new(0
new_weapon.CreateWeapon("Sword","Fire")


I don't see the point on having this as a datum though, since you're really just setting up an object to be used (and storing it as a datum's variable for some reason)

You could move it to be an /obj/Weapon proc and just use that object directly.
In response to Nadrew
Nadrew wrote:
> var/CreateWeapon/new_weapon = new(0
> new_weapon.CreateWeapon("Sword","Fire")
>

I don't see the point on having this as a datum though, since you're really just setting up an object to be used (and storing it as a datum's variable for some reason)

You could move it to be an /obj/Weapon proc and just use that object directly.

he wants to be fancy lol xD let the child have his fun.
though note itll be kinda problematic and stuff cause now everything will have to be hard coded and a extra step will be required im guessing than using your traditional soft coded technique but i mean its all on you if you wanna make it like that go ahead man practice is perfect, just dont confuse yourself haha, as to seeing you dont know how to use a proc in datum.