 |
khil Beginner
Joined: 18 Dec 2010 Posts: 17
|
Posted: Wed Oct 23, 2013 10:13 am
2 problem: simple LUA http.request syntax and DB access bug? |
Hey
Me and my buddy cannot get simple LUA request send to our guild website database
It supposed to work like that
Patern:
Code: |
kill = zs.param(1)
local http = require "socket.http"
local result = http.request("http://guildwebsite/kill/Khil/@kill")
|
Obviously inserting the variable into URL is wrong here, we tried many combinations... (it seems I can't find proper syntax), but the point is at the moment the whole http.request doesn't seem to work. Does it need some extra packages in latest CMUD version?
Url parsing is working at the website end, we tested that (http://guildwebsite/kill/Khil/goblin adds 1 goblin to my kill list)
Problem nr. 2
I am trying to make simple recognition trigger from database. All charactes in mud have two adjectives and race like for example "strong blackhaired man" or "ugly greenish ogre"
the pattern is
Code: |
(%w %w {man|ogre|woman etc...}) |
Code: |
#dbget %find(%1)
#if %find(%1)<>%null {#sub {%1 [&NAME][&GUILD]}} |
The DB includes 3 columns: description, name and guild.
It works fine, giving subbed text, for example "strong black man [Khil] [Paladins]"
Now you can also remember characters by name, if they introduced themselves to you at one point.
Now I am trying to get the script to access DB after NAME column, to get their guild name.
- x y z different names of known characters.
Code: |
#dbget %find(%1,All,NAME)
#if %find(%1,All, NAME)<>%null {#sub {%1[&GUILD]}} |
The "NAME" column is the second one.
It doesnt want to zero on the name in DB and pick the guild name. I tried also set different Views and switch prior to searching, but to no avail... Any ideas? |
|
|
 |
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Wed Oct 23, 2013 4:35 pm Re: 2 problem: simple LUA http.request syntax and DB access bug? |
khil wrote: |
Hey
Me and my buddy cannot get simple LUA request send to our guild website database
It supposed to work like that
Patern:
Code: |
kill = zs.param(1)
local http = require "socket.http"
local result = http.request("http://guildwebsite/kill/Khil/@kill")
|
Obviously inserting the variable into URL is wrong here, we tried many combinations... (it seems I can't find proper syntax), but the point is at the moment the whole http.request doesn't seem to work. Does it need some extra packages in latest CMUD version?
Url parsing is working at the website end, we tested that (http://guildwebsite/kill/Khil/goblin adds 1 goblin to my kill list) |
You're just adding the literal string @kill to your url, since you have it in the quotes. You need to concatenate it in, like this:
Code: |
"http://guildwebsite/kill/Khil/" .. kill |
(.. is the concatenation operator in Lua). You do need LuaSocket's http library to run this, which doesn't come with CMUD. There's a great guide on setting that up here. |
|
|
 |
khil Beginner
Joined: 18 Dec 2010 Posts: 17
|
Posted: Wed Oct 23, 2013 11:14 pm |
Thanks so much. Actually just copying Lua and Socket folders did it. And of course the proper way to access value.
|
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|