Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

shanharlmal

[HELP PLEASE ] Scripting

Recommended Posts

shanharlmal    11

Turns out I have enough programming experience to just get into a project and get nothing accomplished!

 

So I looked up all I could for tutorials and tried disecting a few mods and I think I know enough to at least understand what I am asking?

 

     (Burrow)

1:  Originaly I wanted my character to be able to burrow under the ground like a moleworm, moving slightly slower but undetectable by enemies. After some trial and much error I decided to cut my losses and settle on him just burrowing in the ground where he stands, and not move but still remain undetectable like the bush hat. I want to make it activated simply by right clicking on himself, and cancels with movement. I wanted to use the crafting animation on activation which then either changed his appearance to a dirt mound and made him immobile or...easier way?  If there is a way to make him move underground with the moleworm animation that would be amazing but like I said simple may be better.  How would I go about making that an ability on click, or would I need an item?

 

      (Shovel Claws)

2:  This I have seen in the 'Toph' mod by hornetcorset. He has his character able to mine stone without an item by clicking them and also dig stuff up without a shovel. I just want the shovel bit. I looked and thought I found the code for it but when I tried to replicate it my game just crashes. The following is the code I found:

 

inst:AddComponent("worker")
    inst.components.worker:SetAction(ACTIONS.MINE, 6)
    inst.components.worker:SetAction(ACTIONS.DIG, 1)
    inst.components.playeractionpicker.leftclickoverride = LeftClickPicker

 

I thought just deleting the MINE line would leave just the shovel but of course it's more complicated. How would I go about doing this?

 

3:  (Hair Grow)  This one is a general question for another character, but I can't seem to find the code that dictates hair growth, like for Wilson's beard. I would like to make a custom "beard" art.

Share this post


Link to post
Share on other sites
pickleplayer    206

Turns out I have enough programming experience to just get into a project and get nothing accomplished!

 

So I looked up all I could for tutorials and tried disecting a few mods and I think I know enough to at least understand what I am asking?

 

     (Burrow)

1:  Originaly I wanted my character to be able to burrow under the ground like a moleworm, moving slightly slower but undetectable by enemies. After some trial and much error I decided to cut my losses and settle on him just burrowing in the ground where he stands, and not move but still remain undetectable like the bush hat. I want to make it activated simply by right clicking on himself, and cancels with movement. I wanted to use the crafting animation on activation which then either changed his appearance to a dirt mound and made him immobile or...easier way?  If there is a way to make him move underground with the moleworm animation that would be amazing but like I said simple may be better.  How would I go about making that an ability on click, or would I need an item?

 

      (Shovel Claws)

2:  This I have seen in the 'Toph' mod by hornetcorset. He has his character able to mine stone without an item by clicking them and also dig stuff up without a shovel. I just want the shovel bit. I looked and thought I found the code for it but when I tried to replicate it my game just crashes. The following is the code I found:

 

inst:AddComponent("worker")

    inst.components.worker:SetAction(ACTIONS.MINE, 6)

    inst.components.worker:SetAction(ACTIONS.DIG, 1)

    inst.components.playeractionpicker.leftclickoverride = LeftClickPicker

 

I thought just deleting the MINE line would leave just the shovel but of course it's more complicated. How would I go about doing this?

 

3:  (Hair Grow)  This one is a general question for another character, but I can't seem to find the code that dictates hair growth, like for Wilson's beard. I would like to make a custom "beard" art.

 

Actually I think I can help you with the burrow ability. I'm working on a character that has a similar ability. I'm not 100% sure I'll be able to get the mole digging animation to work, but I probably could.

 

 

 

Rocks are already edible. ;)

 

 

Wait are they really?!

Share this post


Link to post
Share on other sites
shanharlmal    11

Rocks are already edible. ;)

 

You mean using the components.eater:SetElemental()  ??

 

I added this after looking up API components and reviewing the mole prefab. Thinking that was all that be needed. Then I realized rocks don't naturally have any food tuning values so I had to add some with a short function which called for litterally saying rocks were edible. Now I ommitted the components.eater:SetElemental() from main.lua and it still worked..  So that just told me I have to manually add tuning values to each mineral type in order to get effects from them and add that function for each type?

 

Can't I just use the Elemental table for foodprefs somehow? Then assign each some tuning?

Share this post


Link to post
Share on other sites
shanharlmal    11

After some more 'digging' around in code I found out you can offset your characters coordinates rather easily. So for the burrowing ability I would think I could just have him do the 'craft something' animation when you click on him, make a dirt mound or rabbit hole where he stands, then drop his Y coords below ground level until you cancel the ability then pop back to original coords?

 

As I typed this all the 'how dos' came rolling in...Mainly how do you have click on self be an ability trigger?

Share this post


Link to post
Share on other sites
pickleplayer    206

After some more 'digging' around in code I found out you can offset your characters coordinates rather easily. So for the burrowing ability I would think I could just have him do the 'craft something' animation when you click on him, make a dirt mound or rabbit hole where he stands, then drop his Y coords below ground level until you cancel the ability then pop back to original coords?

 

As I typed this all the 'how dos' came rolling in...Mainly how do you have click on self be an ability trigger?

 

Have you tried setting the character's stategraph and build to the mole's temporarily?

 

inst.AnimState:SetBank("mole")

inst.AnimState:SetBuild("mole")
inst:SetStateGraph("SGmole")
 
That might be a way to replace your running animation to the moles animation
 
I havent actually looked through SGmole.lua, so maybe their running animation isn't actually that burrowing animation.
And changing stategraphs might crash the game. but it might not. 
 
 
Also, heres a bit of code that I dug up from the "examine traps first" mod that was edited for whatever I was using it for, I think it was for examining gravestones. You could use this to activate a function when clicking on yourself
AddSimPostInit(function(inst)	GLOBAL.TheInput:AddControlHandler(GLOBAL.CONTROL_PRIMARY, function(down)	local ents=GLOBAL.TheInput:GetAllEntitiesUnderMouse()	    for k,ent in pairs(ents) do			if ent and ent.prefab=="gravestone" and GLOBAL.GetPlayer().prefab=="kaji" then --and not ent.components.activatable.inactive then				--ent.components.inventoryitem.canbepickedup=true				--local creature = GLOBAL.SpawnPrefab("alkianspeachbubble")				inst:DoTaskInTime(0.1, function(inst) GLOBAL.GetPlayer().components.talker:Say("What are these funny looking stone slabs?") end)			end		end	end)end)

You can put that in your modmain. Replace Kaji with your characters name. And the gravestone's name too

 

Share this post


Link to post
Share on other sites
shanharlmal    11

 

Have you tried setting the character's stategraph and build to the mole's temporarily?

 

inst.AnimState:SetBank("mole")

inst.AnimState:SetBuild("mole")
inst:SetStateGraph("SGmole")
 
That might be a way to replace your running animation to the moles animation
 
I havent actually looked through SGmole.lua, so maybe their running animation isn't actually that burrowing animation.
And changing stategraphs might crash the game. but it might not. 
 
 
Also, heres a bit of code that I dug up from the "examine traps first" mod that was edited for whatever I was using it for, I think it was for examining gravestones. You could use this to activate a function when clicking on yourself
AddSimPostInit(function(inst)	GLOBAL.TheInput:AddControlHandler(GLOBAL.CONTROL_PRIMARY, function(down)	local ents=GLOBAL.TheInput:GetAllEntitiesUnderMouse()	    for k,ent in pairs(ents) do			if ent and ent.prefab=="gravestone" and GLOBAL.GetPlayer().prefab=="kaji" then --and not ent.components.activatable.inactive then				--ent.components.inventoryitem.canbepickedup=true				--local creature = GLOBAL.SpawnPrefab("alkianspeachbubble")				inst:DoTaskInTime(0.1, function(inst) GLOBAL.GetPlayer().components.talker:Say("What are these funny looking stone slabs?") end)			end		end	end)end)

You can put that in your modmain. Replace Kaji with your characters name. And the gravestone's name too

 

 

interesting, I will try that if I could get my mod to launch at all now. Seems once a mod crashes, you can't start it again? I undid everything back to where it original worked but all I keep getting when I re-enable the mod is the "...this mod previously crashed and has been disabled" Then its stuck and I have to alt-f4 out. Frankly all I changed was I added a couple of the exact same functions that worked previously in the same manner, all were closed and all looked correct. I'm lost now. Cant even test anything.

 

Share this post


Link to post
Share on other sites