Goomboss Posted January 9, 2015 Share Posted January 9, 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. [codesyntax]local makewine = 0local isDrunk = 0local dawncheck = 0print("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 theninst.components.inventory:GiveItem( SpawnPrefab("bottle_r") )makewine = 0endif TheWorld.state.phase == "day" thenif dawncheck == 1 theninst.components.health:DoDelta(isDrunk, false, "Alcohol poisoning")isDrunk = 0dawncheck = 0endelseif TheWorld.state.phase == "dusk" thendawncheck = 1elseif TheWorld.state.phase == "night" thendawncheck = 1endend-- This initializes for both clients and the hostlocal common_postinit = function(inst)-- Minimap iconinst.MiniMapEntity:SetIcon( "meery.tex" )endlocal function oneat(inst, food)if food and food.components.edible and food.prefab == "berries" thenmakewine = (makewine + 1)elseif food and food.components.edible and food.prefab == "bottle_r" thenisDrunk = (isDrunk - 10)endend-- This initializes for the host onlylocal 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_") thenreturn "Drink"endend-- choose which sounds this character will playinst.soundsname = "willow"-- Statsinst.components.health:SetMaxHealth(150)inst.components.hunger:SetMax(150)inst.components.sanity:SetMax(200)--no sanity loss at nightinst.components.sanity.night_drain_mult = 0--scared of ghostsinst.components.sanity.ghost_drain_mult = 2-- gets cold fastinst.components.temperature.maxtemp = 5-- Checks for Day/Dusk/Night/Cave, & Health Conditions.local refreshTime = 1/5inst:DoPeriodicTask(refreshTime, function() runner(inst, refreshTime) end)endreturn MakePlayerCharacter("meery", prefabs, assets, common_postinit, master_postinit, start_inv)[/codesyntax] the orange parts are the parts that dont quite seem to work. Anyone got any idea? Thanks in advance, Goomboss Link to comment Share on other sites More sharing options...
Goomboss Posted January 11, 2015 Author Share Posted January 11, 2015 Allow me to explain furter and clearer. What I am looking for is a way to select the client and only that client running this script. Link to comment Share on other sites More sharing options...
Blueberrys Posted January 11, 2015 Share Posted January 11, 2015 @Goomboss, please post this in DST Mod section. You'll find more people there who know what you're looking for.As far as I know (never played or modded DST), you may be able to use GetPlayer() and check it's prefab name.GLOBAL.GetPlayer().prefab == "your_character_prefab" Link to comment Share on other sites More sharing options...
Recommended Posts
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.