Goomboss Posted January 12, 2015 Share Posted January 12, 2015 Hello everyone, I have been making a character mod and got the basics to work. My current issue is how to make the script select the client which plays as this character, rather then the host of the server or the first instance of this character on the online list. local makewine = 0 local isDrunk = 0 local dawncheck = 0 print("started") local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset( "ANIM", "anim/player_basic.zip" ), Asset( "ANIM", "anim/player_idles_shiver.zip" ), Asset( "ANIM", "anim/player_actions.zip" ), Asset( "ANIM", "anim/player_actions_axe.zip" ), Asset( "ANIM", "anim/player_actions_pickaxe.zip" ), Asset( "ANIM", "anim/player_actions_shovel.zip" ), Asset( "ANIM", "anim/player_actions_blowdart.zip" ), Asset( "ANIM", "anim/player_actions_eat.zip" ), Asset( "ANIM", "anim/player_actions_item.zip" ), Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ), Asset( "ANIM", "anim/player_actions_bugnet.zip" ), Asset( "ANIM", "anim/player_actions_fishing.zip" ), Asset( "ANIM", "anim/player_actions_boomerang.zip" ), Asset( "ANIM", "anim/player_bush_hat.zip" ), Asset( "ANIM", "anim/player_attacks.zip" ), Asset( "ANIM", "anim/player_idles.zip" ), Asset( "ANIM", "anim/player_rebirth.zip" ), Asset( "ANIM", "anim/player_jump.zip" ), Asset( "ANIM", "anim/player_amulet_resurrect.zip" ), Asset( "ANIM", "anim/player_teleport.zip" ), Asset( "ANIM", "anim/wilson_fx.zip" ), Asset( "ANIM", "anim/player_one_man_band.zip" ), Asset( "ANIM", "anim/shadow_hands.zip" ), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), Asset( "ANIM", "anim/beard.zip" ), Asset( "ANIM", "anim/meery.zip" ), Asset( "ANIM", "anim/ghost_meery_build.zip" ), } local prefabs = { } local start_inv = { -- Custom starting items } local function runner(inst) if makewine == 3 then inst.components.inventory:GiveItem( SpawnPrefab("bottle_r") ) makewine = 0 end if TheWorld.state.phase == "day" then if dawncheck == 1 then inst.components.health:DoDelta(isDrunk, false, "Alcohol poisoning") isDrunk = 0 dawncheck = 0 end elseif TheWorld.state.phase == "dusk" then dawncheck = 1 elseif TheWorld.state.phase == "night" then dawncheck = 1 end end -- This initializes for both clients and the host local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "meery.tex" ) end local function oneat(inst, food) if food and food.components.edible and food.prefab == "berries" then makewine = (makewine + 1) elseif food and food.components.edible and food.prefab == "bottle_r" then isDrunk = (isDrunk - 10) end end -- This initializes for the host only local master_postinit = function(inst) inst.components.eater:SetOnEatFn(oneat) table.insert( inst.components.eater.foodprefs, "ALCOHOL" ) function inst:ActionStringOverride(bufaction) if bufaction.action == ACTIONS.EAT and bufaction.invobject.prefab and bufaction.invobject.prefab:match("^bottle_") then return "Drink" end end -- choose which sounds this character will play inst.soundsname = "willow" -- Stats inst.components.health:SetMaxHealth(150) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(200) --no sanity loss at night inst.components.sanity.night_drain_mult = 0 --scared of ghosts inst.components.sanity.ghost_drain_mult = 2 -- gets cold fast inst.components.temperature.maxtemp = 5 -- Checks for Day/Dusk/Night/Cave, & Health Conditions. local refreshTime = 1/5 inst:DoPeriodicTask(refreshTime, function() runner(inst, refreshTime) end) end return MakePlayerCharacter("meery", prefabs, assets, common_postinit, master_postinit, start_inv) the orange parts are the parts that dont quite seem to work. Anyone got any idea? Thanks in advance, Goomboss Link to comment https://forums.kleientertainment.com/forums/topic/49023-need-help-player-selecting-and-new-food-groups/ Share on other sites More sharing options...
rezecib Posted January 12, 2015 Share Posted January 12, 2015 @Goomboss, I think the orange got overridden by the code tag. Link to comment https://forums.kleientertainment.com/forums/topic/49023-need-help-player-selecting-and-new-food-groups/#findComment-600998 Share on other sites More sharing options...
Goomboss Posted January 14, 2015 Author Share Posted January 14, 2015 if makewine == 3 theninst.components.inventory:GiveItem( SpawnPrefab("bottle_r") )makewine = 0end Seems to not want to target the client but rather the host Link to comment https://forums.kleientertainment.com/forums/topic/49023-need-help-player-selecting-and-new-food-groups/#findComment-601687 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now