Jump to content

Recommended Posts

To summarize I'm trying to give a character the ability to create or spawn an item into their inventory with push of a button & in the future consume a type of item in-exchange for the ability to create an item. [Kinda like crafting without actually crafting] I've read into Milk's thread about spawning Prefabs and looked at the pigking trader code as well. 
 

1) I'm not 100% sure how I should be calling up the function

2) I'm not sure if I'm simply using the wrong declaration/identifier/target as I've tried "player.components" & "self" which gave the same nil error.
3) I probably have no idea what i'm doing so i'll just shut up and listen.

 

 

I know the " - -" changes the "inst." part into a comment in lua. I'm just highlighting the main part with it here as this code gives a nil declaration error.
 

Below I'm using smallmeat in the code to test.

 

Also this is in modmain.lua for reference encase I misplaced it. 

AddModRPCHandler(modname, "POCKETFOOD", function(player)    if not player:HasTag("playerghost") and player.prefab == "fluff" then        if not player.pocketfoodincooldown then            player.components.talker:Say("Oh I found something.")            player.components.health:DoDelta(-1)                  player.components.sanity:DoDelta(-5)-- inst.components.inventory:GiveItem(SpawnPrefab("smallmeat"))                    end            player:DoTaskInTime(60, function()                player.components.talker:Say("I'm all rest up")                player.pocketfoodincooldown = false            end)        else            player.components.talker:Say("I need some time.")        end    endend)

@Hyaciao:

AddModRPCHandler(modname, "POCKETFOOD", function(player)	if not player:HasTag("playerghost") and player.prefab == "fluff" then		if not player.pocketfoodincooldown then			player.components.talker:Say("Oh I found something.")			player.components.health:DoDelta(-1)			player.components.sanity:DoDelta(-5)			local item = GLOBAL.SpawnPrefab("smallmeat")			player.components.inventory:GiveItem(item)			player:DoTaskInTime(60, function()				player.components.talker:Say("I'm all rest up")				player.pocketfoodincooldown = false			end)		else			player.components.talker:Say("I need some time.")		end	endend)

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...