Jump to content

[HELP] with custom item, please


Recommended Posts

Hello. I would like to create a custom range weapon. Something like the staff, but other sprites. Does anyone has a template for me, or may tell me, which files I will need? I made already meele weapons, but these staffs looking confused, alot of files called "staffgfx".

Link to comment
Share on other sites

@ntdi

u really only need staff.lua, theres an initfunction for each color of staff in there. just remove all of those but the one that is most like what u need, the other files are just for specific things that certain colored staffs can do.

alternatively u could use the throwable spears mod as a base.

Edited by Seiai
Link to comment
Share on other sites

@ntdi

if u leave only the stuff that relates to for example the fire-staff, u will notice that it uses a prefab called fire_projectile. this prefab is in the file staff_projectile.lua. so u will probably need that file too.

Link to comment
Share on other sites

took another range weapon as example. tried everything to make it work. following problems: weapon isnt shooting projectiles (not visible), weapon doesnt deals any damage. anyone may tell me how to fix that? heres my current weapon:bowandarrow.zip

Link to comment
Share on other sites

@ntdi

this is what u set as the animation in bow_projectile.lua:



inst.AnimState:SetBank("projectile")
inst.AnimState:SetBuild("bow_projectile")
inst.AnimState:PlayAnimation(anim, true)


 

the build is the name of the spriterfile. u correctly named both "bow_projectile".

 

the bank is the name of the folder inside of the spriterfile in the animationstab. in the spriterfile u named that "bow_projectile".

 

the variable anim in PlayAnimation(anim, true) is the parameter u call your common-function with, from the fire function:




local function fire()
    return common("bow_spin_loop", "shaders/anim.ksh")
end


so u are trying to play the animation "bow_spin_loop". but the animation in your spriterfile is called "idle".

Edited by Seiai
Link to comment
Share on other sites

hello seiai. really happy that youre trying to help me out with my stuff. i renamed the animationname in the scml file into "bow_spin_loop", also i renamed the folder the spritefile into "bow_projectile". after trying to make it work ingame, my character still made the attack animation with the weapon,but dealt 0 damage and no arrows were seen. i cant upload the edited file now because im not home. may u help me out once again please?

Link to comment
Share on other sites

wow, you are them an rons0n. i thank you so fkin much. i didnt added it to the prefabfiles, u were right. does it has to be in the prefabfiles? if yes, why is that? i thought u add names to the prefabfiles u want to be able to spawn ingame. is there anything else behind it?

Link to comment
Share on other sites

is there anything else behind it?

prefabfiles by themselfes(the way we create them) are actually not doin anything in objectoriented programming. that's why we return the Prefab()-function at the bottom, to make it an actual object(there's a Class-defninition in prefabs.lua).and then we still just have an object, that has to be used by something. so we tell the game that this is a prefab, so it can be used like all other prefabs ingame.
  • Like 1
Link to comment
Share on other sites

but do the prefab could be the reason why my weapon wont work as i wish it to?

this sentence does not make any sense^^

can you find anything else in my files i did wrong?

attach your new version.
Link to comment
Share on other sites

got everything fixed. another problem right now:

I tried to create a configurable modconfig, so you can set your own recipe.

If I set it and press apply, following happens:

 

[00:00:52]: loaded modindex    
[00:00:52]: ModIndex: Beginning normal load sequence.
    
[00:00:52]: WARNING loading modinfo.lua: workshop-401483511 does not specify if it is compatible with Don't Starve Together. It may not work properly.    
[00:00:52]: ModIndex:GetModsToLoad inserting moddir,     shuriken    
[00:00:52]: loaded mod_config_data/modconfiguration_shuriken    
[00:00:52]: Loading mod: shuriken (Shuriken) Version:1.0    
[00:00:52]: Mod: shuriken (Shuriken)    Loading modworldgenmain.lua    
[00:00:52]: Mod: shuriken (Shuriken)      Mod had no modworldgenmain.lua. Skipping.    
[00:00:52]: Mod: shuriken (Shuriken)    Loading modmain.lua    
[00:00:52]: Warning: Calling Recipe from a mod is now deprecated. Please call AddRecipe from your modmain.lua file.    
[00:00:52]: Mod: shuriken (Shuriken)      Error loading mod!
[string "../mods/shuriken/modmain.lua"]:45: attempt to index global 'shuriken' (a nil value)
LUA ERROR stack traceback:
        ../mods/shuriken/modmain.lua(45,1) in main chunk
        =[C] in function 'xpcall'
        scripts/util.lua(560,1) in function 'RunInEnvironment'
        scripts/mods.lua(382,1) in function 'InitializeModMain'
        scripts/mods.lua(363,1) in function 'LoadMods'
        scripts/main.lua(248,1) in function 'ModSafeStartup'
        scripts/main.lua(296,1)
        =[C] in function 'SetPersistentString'
        scripts/mainfunctions.lua(25,1) in function 'SavePersistentString'
        scripts/modindex.lua(78,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(65,1) in function 'BeginStartupSequence'
        scripts/main.lua(295,1) in function 'callback'
        scripts/modindex.lua(474,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(451,1) in function 'Load'
        scripts/main.lua(294,1) in main chunk
    
[00:00:52]: [string "../mods/shuriken/modmain.lua"]:45: attempt to index global 'shuriken' (a nil value)
LUA ERROR stack traceback:
        ../mods/shuriken/modmain.lua(45,1) in main chunk
        =[C] in function 'xpcall'
        scripts/util.lua(560,1) in function 'RunInEnvironment'
        scripts/mods.lua(382,1) in function 'InitializeModMain'
        scripts/mods.lua(363,1) in function 'LoadMods'
        scripts/main.lua(248,1) in function 'ModSafeStartup'
        scripts/main.lua(296,1)
        =[C] in function 'SetPersistentString'
        scripts/mainfunctions.lua(25,1) in function 'SavePersistentString'
        scripts/modindex.lua(78,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(65,1) in function 'BeginStartupSequence'
        scripts/main.lua(295,1) in function 'callback'
        scripts/modindex.lua(474,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(451,1) in function 'Load'
        scripts/main.lua(294,1) in main chunk
[00:00:52]: Error error! We tried displaying an error but TheFrontEnd isn't ready yet...    
[00:00:52]: LOADING LUA SUCCESS
[00:00:52]: PlayerDeaths loaded morgue    5261    
[00:00:52]: loaded profile    
[00:00:52]: bloom_enabled    false    
[00:00:52]: loaded saveindex    
[00:00:52]: OnFilesLoaded()    
[00:00:52]: OnUpdatePurchaseStateComplete    
[00:00:52]:     Unload BE    
[00:00:52]: Could not unload undefined prefab 0xee4faffd (shuriken)
[00:00:52]: Could not unload undefined prefab 0xee4faffd (shuriken)
[00:00:52]:     Unload BE done    
[00:00:53]: Mod: shuriken (Shuriken)    Registering prefabs    
[00:00:53]: Mod: shuriken (Shuriken)      Registering prefab file: prefabs/shuriken    
[00:00:53]: Mod: shuriken (Shuriken)        shuriken    
[00:00:53]: Mod: shuriken (Shuriken)      Registering prefab file: prefabs/shuriken_projectile    
[00:00:53]: Mod: shuriken (Shuriken)        ice_projectile    
[00:00:53]: Mod: shuriken (Shuriken)        shuriken_projectile    
[00:00:53]: Mod: shuriken (Shuriken)      Registering default mod prefab    
[00:00:53]:     Load FE    
[00:00:53]:     Load FE: done    
[00:00:53]: platform_motd    table: 0E0366D0    
[00:00:53]: SimLuaProxy::QueryServer()
[00:00:53]: SimLuaProxy::QueryServer()
[00:00:53]: SimLuaProxy::QueryServer()
[00:00:53]: Disabling shuriken (Shuriken) because it had an error.    
[00:00:53]: SCRIPT ERROR! Showing error screen    
[00:00:53]: ModIndex: Load sequence finished successfully.    
[00:00:53]: Reset() returning
[00:00:54]: platform_motd    table: 0E033638    
[00:00:54]: Stale Component Reference: GUID 100025, scripts/widgets/text.lua:55
[00:00:54]: Stale Component Reference: GUID 100026, scripts/widgets/text.lua:55
[00:00:54]: Stale Component Reference: GUID 100037, scripts/widgets/text.lua:55
[00:00:54]: Stale Component Reference: GUID 100037, scripts/widgets/text.lua:25
 

need help from you guys, please. heres the new v:shuriken.zip

Link to comment
Share on other sites

@ntdi,

it has nothing to do with the modconfig, u never declared the "shuriken" variable u use in "shuriken.atlas". what u probably meant to do is "shurikenrecipe.atlas".

aside from that, u should add recipes like that:

AddRecipe("itemtobuild", {Ingredient("meat", 1)}, GLOBAL.RECIPETABS.TOWN, GLOBAL.TECH.NONE, nil, nil, nil, nil, "charactername","images/inventoryimages/itemtobuild.xml")GLOBAL.STRINGS.RECIPE_DESC.ITEMTOBUILD = "Item to Build."
Edited by Seiai
Link to comment
Share on other sites

[00:04:17]: [string "scripts/components/playercontroller.lua"]:804: attempt to index field 'placer' (a nil value)
LUA ERROR stack traceback:
scripts/components/playercontroller.lua:804 in (method) StartBuildPlacementMode (Lua) <797-809>
   self =
      placer = 116120 - shuriken (valid:true)
      predictionsent = false
      controller_target_age = 1.#INF
      draggingonground = false
      handler = table: 41AD9F78
      inst = 112606 - wilson (valid:true)
      remote_vector = (0.00, 0.00, 0.00)
      classified = 112607 - player_classified (valid:true)
      map = Map (2D18E9F0)
      directwalking = false
      placer_recipe = table: 14C96630
      locomotor = table: 39FE3760
      time_direct_walking = 1.1666667275131
      ismastersim = true
      predictwalking = false
      mousetimeout = 10
      dragwalking = false
      deploy_mode = true
      remote_controls = table: 3A1F8A28
   recipe = table: 14C96630
scripts/widgets/widgetutil.lua:67 in (global) DoRecipeClick (Lua) <22-94>
   owner = 112606 - wilson (valid:true)
   recipe = table: 14C96630
   knows = true
   can_build = true
   buffered = false
scripts/widgets/craftslot.lua:48 in (method) OnControl (Lua) <41-53>
   self =
      callbacks = table: 3A57C4E8
      recipe = table: 14C96630
      recipepopup = Text - Shuriken
      inst = 112917 -  (valid:true)
      focus = true
      locked = false
      children = table: 3A57C128
      focus_flow_args = table: 3A57C908
      focus_target = false
      atlas = images/hud.xml
      tile = RecipeTile
      owner = 112606 - wilson (valid:true)
      open = true
      canbuild = true
      fgimage = Image - images/hud.xml:craft_slot_locked.tex
      parent = CraftSlots
      name = Craftslot
      enabled = true
      focus_flow = table: 3A57C8E0
      shown = true
      recipename = shuriken
      bgimage = Image - images/hud.xml:craft_slot.tex
   control = 29
   down = false
scripts/widgets/widget.lua:115 in (method) OnControl (Lua) <109-119>
   self =
      enabled = true
      focus_target = false
      shown = true
      owner = 112606 - wilson (valid:true)
      slots = table: 3A55FA10
      parent = Crafting
      focus_flow_args = table: 3A55F678
      inst = 112881 -  (valid:true)
      focus = true
      focus_flow = table: 3A55F650
      name = CraftSlots
      children = table: 3A55EC00
      callbacks = table: 3A55EB38
   control = 29
   down = false
   k = Craftslot
   v = Craftslot
scripts/widgets/widget.lua:115 in (field) OnControl (Lua) <109-119>
   self =
      use_idx = true
      out_pos = (0.00, 0.00, 0.00)
      callbacks = table: 3A55D8C8
      scrolldir = true
      downbutton = BUTTON
      parent = CraftTabs
      inst = 112879 -  (valid:true)
      focus = true
      in_pos = (145.00, 0.00, 0.00)
      horizontal = false
      children = table: 3A55D800
      max_slots = 10
      focus_flow_args = table: 3A55E6B0
      focus_target = false
      current_slots = 10
      num_recipes = 17
      valid_recipes = table: 2DCB09A8
      owner = 112606 - wilson (valid:true)
      open = true
      idx = 8
      upbutton = BUTTON
      enabled = true
      name = Crafting
      filter = function - scripts/widgets/crafttabs.lua:107
      focus_flow = table: 3A55E318
      craftslots = CraftSlots
      shown = true
      bg = TileBG
   control = 29
   down = false
   k = CraftSlots
   v = CraftSlots
scripts/widgets/crafting.lua:180 in (method) OnControl (Lua) <179-191>
   self =
      use_idx = true
      out_pos = (0.00, 0.00, 0.00)
      callbacks = table: 3A55D8C8
      scrolldir = true
      downbutton = BUTTON
      parent = CraftTabs
      inst = 112879 -  (valid:true)
      focus = true
      in_pos = (145.00, 0.00, 0.00)
      horizontal = false
      children = table: 3A55D800
      max_slots = 10
      focus_flow_args = table: 3A55E6B0
      focus_target = false
      current_slots = 10
      num_recipes = 17
      valid_recipes = table: 2DCB09A8
      owner = 112606 - wilson (valid:true)
      open = true
      idx = 8
      upbutton = BUTTON
      enabled = true
      name = Crafti
[00:04:17]: [string "scripts/components/playercontroller.lua"]:804: attempt to index field 'placer' (a nil value)
LUA ERROR stack traceback:
    scripts/components/playercontroller.lua:804 in (method) StartBuildPlacementMode (Lua) <797-809>
    scripts/widgets/widgetutil.lua:67 in (global) DoRecipeClick (Lua) <22-94>
    scripts/widgets/craftslot.lua:48 in (method) OnControl (Lua) <41-53>
    scripts/widgets/widget.lua:115 in (method) OnControl (Lua) <109-119>
    scripts/widgets/widget.lua:115 in (field) OnControl (Lua) <109-119>
    scripts/widgets/crafting.lua:180 in (method) OnControl (Lua) <179-191>
    scripts/widgets/widget.lua:115 in (field) OnControl (Lua) <109-119>
    scripts/widgets/crafttabs.lua:240 in (method) OnControl (Lua) <239-293>
    scripts/widgets/widget.lua:115 in (method) OnControl (Lua) <109-119>
    scripts/widgets/widget.lua:115 in (method) OnControl (Lua) <109-119>
    scripts/widgets/widget.lua:115 in (method) OnControl (Lua) <109-119>
    scripts/widgets/widget.lua:115 in (method) OnControl (Lua) <109-119>
    scripts/widgets/widget.lua:115 in (field) OnControl (Lua) <109-119>
    scripts/screens/playerhud.lua:404 in (method) OnControl (Lua) <403-480>
    scripts/frontend.lua:267 in (method) OnControl (Lua) <260-309>
    scripts/input.lua:163 in (method) OnControl (Lua) <160-167>
    scripts/input.lua:362 in () ? (Lua) <361-363>
    
[00:04:17]: SCRIPT ERROR! Showing error screen    
[00:04:40]: Force aborting...

 

got fixed everything, except this error. it is happening if I craft the item. It works to spawn it via console. Whats wrong? need help please.... :(Shurkanz.zip

Link to comment
Share on other sites

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
 Share

×
  • Create New...