Jump to content

Recommended Posts

sorry im really a newbi at scripting even after playing with lua on off for years now >.< 

ok so in my mod im making "birdy" when u drop him on the ground it will attract birds just like the feather hat woud if its on your head (and play sounds but baby steps) but im not sure if it is attracting more birds or not

and from my messing around with the teddy bear from DST ive been using 
 

local function topocket(inst, owner)
	(snip...)
end

local function toground(inst, owner)
    (snip...)
end

but looking at the lightbulb.lua it has

local function OnDropped(inst)
    inst.Light:Enable(true)
end

local function OnPickup(inst)
    inst.Light:Enable(false)
end

so im wondering is there a diffronts between

"OnDropped / toground" and "OnPickup/topocket"

 

edit: heres a link to my mods github if any 1 wants to look at it to see if theres a diffront reason y its not attracting birds 
https://github.com/monkeybee11/monkey-mod

Edited by monkeybee
fix title

It does not matter how the name of the function is. It does matter if/where/how it is called.
So search for code where you see if/where/how it is called, then you will know how it works and how to implement it into your mod.

1 hour ago, monkeybee said:

really? how comes swiching them around makes the game crash? o.O

Because of the executing code. As I already said, look where it is executed. There will be written the function name. Of course it must match at both positions (the function name must mnatch the name you are calling), but the name itself does not matter.
So in your mod you can call it whatever you want, as long as you call this function the right way.

 

You did not mention much about what you want to do. You only aked what is the difference. And I answered that you see the difference not in that code you quoted, you see it in the part were it is executed.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...