RAINBOW Posted May 9, 2014 Share Posted May 9, 2014 Came up with some code that checks for a custom item I've modded in called "Ctoken". Have a look if you like, I have gotten to the point where I access the server specific item, then realised I don't have a clue if I can just 'add' in values to it. The idea behind storing it on an item is for our persistent server, each character will get the item when they join (If they don't already possess one that is!). The event OnGameStart is serving fine for this purpose, anyway, boolean (true or false) values such as "Trusted Player" and custom player factions such as "Trader" are going to be set on this wonderific "do it all" item. Here's my code: --+ Raenbow +----+ 9th May 2014 +-- --+ CHARACTER TOKEN HANDLER. +---- function loadToken(_player)local player = _player;local token = player:getInventory():FindAndReturn("Raenbow.Ctoken");--local string sDebug = token:getName(); --returns "Character Token" --How can I add in 'another' value to the object token? end function raenbow_ctoken() local player = getPlayer(); --Check if a ctoken exists in inventory or not here:if player:getInventory():contains("Item_Ctoken") == false then--No Ctoken exists, create one and move on:print("Raenbow: No CTOKEN FOUND. CREATING ONE:");getPlayer():getInventory():AddItem("Raenbow.Ctoken");elseprint("Raenbow: CTOKEN FOUND!");end --to do here, Check there is not more than one ctoken here: --Execute next part here:loadToken(player);end Events.OnGameStart.Add(raenbow_ctoken); I'm entirely unsure if I can just 'add' in a value somehow, like with a simple "SetValue()" command or whatever, all I managed to trawl up from the javadocs and gleaming the forums was these: setScriptItem(token);ScriptManager():getItem(); But from what I see on the forums, the scripting stuff is getting binned or whatever anyway. Surely there must be a simple way to attach a bunch of string/int/bools to an inventory item object? Thanks in advance! This one has me stumped Link to comment Share on other sites More sharing options...
RAINBOW Posted May 9, 2014 Author Share Posted May 9, 2014 I wasn't too sure about this script business. I read This and I'm beginning to wonder. "Is creating my own custom variable and attaching it to an item, as simple as adding a line of code in here?" For example:item EnergyDrink{HungerChange = 10,Weight = 1.0,Type = Food,UnhappyChange = 10,ThirstChange = -5,DisplayName = Energy drink,ReplaceOnUse = PopBottleEmpty,Icon = Pop4,CustomContextMenu = Drink,}Can I just 'add' in a line here? such as item EnergyDrink{HungerChange = 10," " " " " "CharacterTokenFaction = Bandit," " " " " "CustomContextMenu = Drink,} Surely it can't be that simple? Link to comment Share on other sites More sharing options...
Aricane Posted May 10, 2014 Share Posted May 10, 2014 Hardly Link to comment Share on other sites More sharing options...
RAINBOW Posted May 11, 2014 Author Share Posted May 11, 2014 Is that a no Aricane? I'll have to put a value into a lua file too? Gonna try it first, might be just THIS simple after all? Link to comment Share on other sites More sharing options...
RAINBOW Posted May 11, 2014 Author Share Posted May 11, 2014 Solved it! Whoever it is that made the "Pillow Silencer" mod, (He doesn't leave his name!) has written this: http://pz-mods.net/guide/get-what-data-getmoddata/ It's how to save a table of values to ANY item we want in the game. Kickass. Link to comment Share on other sites More sharing options...
Aricane Posted May 11, 2014 Share Posted May 11, 2014 Dude, try it already. I wanna know Solved it! Whoever it is that made the "Pillow Silencer" mod, (He doesn't leave his name!) has written this: http://pz-mods.net/guide/get-what-data-getmoddata/ It's how to save a table of values to ANY item we want in the game. Kickass.Don't trust the guy who wrote that syfy and Viceroy 2 Link to comment Share on other sites More sharing options...
RAINBOW Posted May 11, 2014 Author Share Posted May 11, 2014 kk! Testing it now matey! Link to comment Share on other sites More sharing options...
RAINBOW Posted May 11, 2014 Author Share Posted May 11, 2014 Dude. Totally fucking works. Hard to believe someone who created a "Pillow Case silencer" could stumble upon this beauty! Also, that is the most horrendously commented tutorial I've ever read! Link to comment 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