Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 4 5 6 7 8 … 18 Next »
Creating sound for multivalue table fails
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
Creating sound for multivalue table fails
29-10-2018, 06:11 PM, (This post was last modified: 29-10-2018, 06:12 PM by Captain Krisu. Edited 1 time in total.)
#1
Captain Krisu Offline
Valued donator and member
****
Posts: 38
Threads: 14
Joined: Nov 2013
Question  Creating sound for multivalue table fails
Just a general question/help request, since I can't seem to find solution myself.

I'm trying to do a multivalue table where I store my sounds, with their paths for getting sound durations easier and creating them easier.. except the latter won't work.

Error: attempt to call field 'create' (a nil value)

Code:
local chip = ents.self() local sounds = { ["alert"] = { path = "st/misc/abandon_ship.wav", snd = nil } for k,v in pairs(sounds) do print(tostring(v) .. ", " .. tostring(v.snd)) -- Debugging stuff, had to check if stuff was correct, it is v.snd = sounds.create(chip, v.path) end

I've tried using key instead of straight value, ipairs, nothing worked.

I like sdwel
Find
Reply
29-10-2018, 08:00 PM,
#2
Salira Offline
Valued donator and member
****
Posts: 196
Threads: 78
Joined: May 2015
RE: Creating sound for multivalue table fails

local sounds = {
alert = { path = "st/misc/abandon_ship.wav", snd = nil }
}

This should be the correct formatting. Let me know if this still doesn't work.
Read from sounds.alert.path for the path of the sound.
Find
Reply
29-10-2018, 08:21 PM,
#3
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Creating sound for multivalue table fails
Here is the problem:
local sounds = {
You've created a local variable called sounds, then later are trying to use the global sounds table. You'll need to rename your local variable so it doesn't clash.
Find
Reply
29-10-2018, 08:52 PM,
#4
Captain Krisu Offline
Valued donator and member
****
Posts: 38
Threads: 14
Joined: Nov 2013
RE: Creating sound for multivalue table fails
(29-10-2018, 08:21 PM)Person8880 Wrote: Here is the problem:
local sounds = {
You've created a local variable called sounds, then later are trying to use the global sounds table. You'll need to rename your local variable so it doesn't clash.

Oh heck

[Image: 1*YZyHx8ZittvvirTTlwffxQ.gif]

I'm an idiot Big Grin

I like sdwel
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


Users browsing this thread:
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.