I am trying to add a string to an empty list in Zapier code.
I have tried the code locally and it works. I don't understand why it's not working inside Zapier. Here is the code
output = []
if (input_data[0]=="true"): output.append("string")
Here is the error
Traceback (most recent call last):
File "/tmp/tmpEeICti/usercode.py", line 10, in the_function
if (input_data[0]=="true"): output.append("Situationsplan")
KeyError: 0
David here, from the Zapier Platform team.
input_data is a dict but you're accessing it like an array. There's not a '0' key, so you're getting that error. The keys in input_data are created right above the code input, so feel free to edit that form to get different data.
Additionally, output will need to be an array of dicts, so a value of ["Situationsplan"] will cause an error once this actually does run.
Related
I'm trying to get [https://github.com/twilio-labs/function-templates/tree/main/funlet-simulring] to work. I'm trying to upgrade my IVR to have a whisper (announce who is calling to the called party before accepting the call) and a voicemail fallback so callers don't get my personal cell voicemail instead of the work line.
I'm trying to get the Funlet Simulring working. I'm getting an error at the "split" function (full error copied below).
I copied in the code here (https://github.com/twilio-labs/function-templates/blob/main/funlet-simulring/functions/funlet-simulring.protected.js) and two numbers to line 37:
phoneNumbers: [+1xxx,+1xxx],
I also have to environmental variables set:
TWILIO_VOICE_WEBHOOK_URL=/funlet-simulring and:
FUNLET_SIMULRING_PHONE_NUMBERS=+1xxx,+1xxx
I put some more context below, but my issue is if I "fix" the split error the number doesn't forward, but if I leave it as is I get a function error.
I've tried editing line 145 since "FUNLET_FINDME_PHONE_NUMBERS" seems to me to not be defined anywhere. But if I define it my just hard coding in my forwarding numbers, I can get the function to play, but it doesn't forward anywhere.
Error: {"message":"Cannot read property 'split' of undefined","name":"TypeError","stack":"TypeError: Cannot read property 'split' of undefined\n at getPhoneNumbers (/var/task/handlers/ZNxxx.js:145:37)\n at Object.exports.handler (/var/task/handlers/ZNxxx.js:387:29)\n at Object.exports.handler (/var/task/node_modules/runtime-handler/index.js:339:10)\n at Runtime.exports.handler (/var/task/runtime-handler.js:17:17)\n at Runtime.handleOnceNonStreaming (/var/runtime/Runtime.js:74:25)"}
I'm following your roguelike tutorial and have encountered a problem I do not know how to solve. This is my first-time coding with Lua
If r.nospawn then return 0
--Attempt to index local "R" (a nil value)
I asked the PICO-8 discord server, they tried to help me, but I still don't fully understand, and I did not want to pester them further with the issue. The name of my file on PICO-8 is called Rogue - if that has anything to do with the issue.
Here's a picture of the error, the discord comment I received, and a link to the full list of code on GitHub.
Error in PICO-8
Discord Comment
Github Code
I think you are missing a simple failure case. i.e. what happens when all the entries in rpot have been removed. Then local r=getrnd(rpot) should return null. That might be an error in it's own right i.e. there should always be something to allocate from there.
However getrnd will fail.
function getrnd(arr)
return arr[1+flr(rnd(#arr))]
end
In the case when arr is empty you will try and return element 1, which will be out of bounds. I don't know lua but it might return null for you which leads to the next problem. But that has a simple fix:
repeat
local r=getrnd(rpot)
if r
placed+=infestroom(r)
del(rpot,r)
end
until #rpot==0 or placed>maxmons[floor]
I am a beginner in Python using Spyder to code from Anaconda3.
I tried to enter such codes in Spyder (Python 3.7). I pressed "Enter" when trying to split the codes and the indents appear auto. But it always returns with "SyntaxError: invalid syntax" and "SyntaxError: 'return' outside function".
E.g. 1
data = {'state':['Ohio','Ohio','Ohio','Nevada','Nevada','Nevada'],
'year':[2000,2001,2002,2001,2002,2003],
'pop':[1.5,1.7,3.6,2.4,2.9,3.2]}
When I press F9 in either line, it returns "SyntaxError: invalid syntax".
E.g. 2
def f(x):
return pd.Series([x.min(),x.max()],index=['min','max'])
Press F9 to run the line, it returns "SyntaxError: unexpected EOF while parsing". If in the second line, it returns "SyntaxError: 'return' outside function".
In addition, I also tried to put "\"s at the end of each line. It doesn't work either. And find from webpages that if the lines end with : or , then you don't need \ to split.
But!!! if I deleted the 'Enters' and put everything in a single line without splits, it works well totally.
Why my python cannot work with code blocks? How can I fix it with Anaconda3?
Thank you so much~~~~
The problem is that you need to select the entire function before pressing F9, if you select only a part of it it will raise an error
You can use \ at the end of each line to tell Python that the line continues below:
data = {\
'state':['Ohio','Ohio','Ohio','Nevada','Nevada','Nevada'],\
'year':[2000,2001,2002,2001,2002,2003],\
'pop':[1.5,1.7,3.6,2.4,2.9,3.2]\
}
Having the dictionary split across multiple lines may look pretty, but it is not proper syntax. I've also been tripped up by tutorials that show their dictionaries like that :|
This may not work in interpreters other than IDLE.
The echo twimlet gives this error in the developer console when trying to save:
TypeError: $(...) is null
base.js:2:20968
TypeError: t is not a function
Ajax.Request<.initialize()
ext.js:1
t()
ext.js:1
Ext.lib.Ajax.request()
ext.js:4
.request()
ext.js:6
.save()
twimlets.js:1
Ext.Button<.onClick()
ext.js:13
E/a()
ext.js:5
n/a()
ext.js:3
ext.js:1:18861
Any ideas on what might be the problem? I've tried even a very simple echo twimlet, as well as trying to edit an existing twimlet.
There is currently an issue with editing saved Twimlets. An error will occur when you attempt to edit a saved Twimlet. However, this error does not apply when generating a new Twimlet.
We are moving towards using Twiml Bins in the Twilio Console. You can create request URLs containing some TwiML instructions and save and edit them at anytime.
It can be a bit of extra work to do this from scratch so if you are really hoping to stick with the Twimlet, alternatively, be sure to check your URL encoding.
I've got an addon on my server that basically allows you to create territories. On top of that, I have one which allows you to make permanent properties, which players own even when they aren't online. Additionally, you are able to save the props inside these permanent buildings so that when you next get on, the props are all still there.
It was working fine, but I now seem to be encountering the following error whenever I save the props inside my house and restart the server. Also, a lot of the houses don't seem to work. But, when I unsave the props inside a house and restart, everything is back to normal.
The error
[ERROR] addons/darkrpmodification-master/lua/darkrp_modules/territory/sh_init.lua:514: bad argument #1 to 'pairs' (table expected, got nil)
1. pairs - [C]:-1
2. LoadProps - addons/darkrpmodification-master/lua/darkrp_modules/territory/sh_init.lua:514
3. tsetUpDoors - addons/darkrpmodification-master/lua/darkrp_modules/territory/sv_init.lua:273
4. unknown - addons/darkrpmodification-master/lua/darkrp_modules/territory/sv_init.lua:290
Code
function BuyableTerritory:LoadProps(steamid, t)
for k, v in pairs(t) do
local e = ents.Create("prop_physics")
e:SetPos(v.pos)
e:SetAngles(v.ang)
e:SetModel(v.model)
if v.color then
e:SetColor(v.color)
end
if v.material then
e:SetMaterial(v.material)
end
e:Spawn()
e.permaOwner = steamid
e:GetPhysicsObject():EnableMotion(false)
end
local ply = DarkRP.findPlayer(steamid)
if IsValid(ply) then
self:SetPropsOwner(ply, ply:SteamID())
end
The code starts at line 513, so the second line in is the one having problems. Thank you.
Just read the error message. It tells you that the input to pairs() is nil instead of the expected table. pairs is a so called iterator. It only works with a Lua table as input.
Your input t to BuyableTerritory:LoadProps(steamid, t) is not valid.
You either have to change that or check if t is a table befor you call pairs(t) to prevent the error from happening.
Go to line 273 of sv_init.lua to find out whats going on.