Lonster_Monster Posted January 10, 2018 Report Posted January 10, 2018 (edited) i have a genuine killer exclusive with the australium paint on iti done var item = ourItems[i].market_name; var des = ourItems[i].descriptions; console.log(item) console.log(des) if (item == stock[item] && des == stock[item].description){ if (item == Prices[item] && des == Prices[item].description){ console.log(Prices[item].sell) } } when it does the console log on item and des it shows "Genuine Killer Exclusive": [ { type: "text", value: "Paint Color: Australium Gold", color: "756b5e", app_data: "" }, { type: "text", value: "Break news, spirits and heads.", app_data: "" } ] i put the descriiption text in the stock under the item name and is the value of description like below { "Genuine Killer Exclusive": { "instock": 0, "stocklimit":1, "description": [ { "type": "text", "value": "Paint Color: Australium Gold", "color": "756b5e", "app_data": "" }, { "type": "text", "value": "Break news, spirits and heads.", "app_data": "" } ] } } the problem is with the "" around type, value, color, app_data, type, value, app_data it acts as if that is not the value but json wont work without the " " around the certain words SOLUTION: I finally fixed the problem in var item = ourItems[i].market_name; var des = ourItems[i].descriptions; console.log(item) console.log(des) if (item == stock[item] && des == stock[item].description){ if (item == Prices[item] && des == Prices[item].description){ console.log(Prices[item].sell) } }changed the code to the code below and i think it is cool how i can call stuff like this now const filestockname = './/settings/Prices/Prices.json'; const filestock = require(filestockname); for (var i in ourItems) { var item = ourItems[i].market_name; var des = ourItems[i].description console.log(item) console.log(des) if (filestock[item]){ fs.readFile(filestockname, (err, data) => { if (err) throw err; console.log('File read'); }); filestock[item].description = des console.log('writing to ' + filestockname); fs.writeFile(filestockname, JSON.stringify(filestock, null, 2), function (err) { if (err) return console.log(err); console.log('writing to ' + filestockname); }); } } that is only for the our items side i didnt post for the their items side of the trade becaseu it is basically the same Edited January 12, 2018 by Lonster_Monster Quote
Eradicate Posted January 10, 2018 Report Posted January 10, 2018 Objects would just work fine as string.. var object = { 'this_works':'it actually did!' }; console.log(object.this_works); ..? Quote
Lonster_Monster Posted January 11, 2018 Author Report Posted January 11, 2018 (edited) Objects would just work fine as string..var object = { 'this_works':'it actually did!'}; console.log(object.this_works);..?so say i wanted to do the code i have above, what exactly would i do i mean as an object like i am wanting Sorry if it is a noob question i am still kinda new to nodejs i have been making my own bot for about a year leanring new stuff in it Edited January 11, 2018 by Lonster_Monster Quote
Lonster_Monster Posted January 12, 2018 Author Report Posted January 12, 2018 I finally fixed the problem in var item = ourItems[i].market_name; var des = ourItems[i].descriptions; console.log(item) console.log(des) if (item == stock[item] && des == stock[item].description){ if (item == Prices[item] && des == Prices[item].description){ console.log(Prices[item].sell) } } changed the code to the code below and i think it is cool how i can call stuff like this now const filestockname = './/settings/Prices/Prices.json'; const filestock = require(filestockname); for (var i in ourItems) { var item = ourItems[i].market_name; var des = ourItems[i].description console.log(item) console.log(des) if (filestock[item]){ fs.readFile(filestockname, (err, data) => { if (err) throw err; console.log('File read'); }); filestock[item].description = des console.log('writing to ' + filestockname); fs.writeFile(filestockname, JSON.stringify(filestock, null, 2), function (err) { if (err) return console.log(err); console.log('writing to ' + filestockname); }); } } that is only for the our items side i didnt post for the their items side of the trade becaseu it is basically the same Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.