[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  Lua
. . -> [Subject]  Starting with Lua, coroutines and other stuffs (need patient people to help)

Starting with Lua, coroutines and other stuffs (need patient people to help)

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1  2 

Posted by Aiseant   (33 posts)  [Biography] bio
Date Reply #15 on Thu 07 Apr 2011 08:15 AM (UTC)

Amended on Thu 07 Apr 2011 08:21 AM (UTC) by Aiseant

Message
Thanks for your help

I saw the funcion in lua_scripting, and you used it in the original startup.lua (or its equivalent to get the player's name)
If I understand well, when it says "attempt to index local room (a nil value)", this means that he doesn't know what I'm trying to call, right ? something like an undeclared function.


I just did

function mob_byte()

	local room = mud.room_info ()


...
end --function


I have this : mob_byte = require("mob_byte").mob_byte
in starup.lua

And mob_byte is called when a mob (called Byte) is created : Byte have an open_lua, then a call_lua calling mob_byte function
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #16 on Thu 07 Apr 2011 09:03 AM (UTC)
Message
Which line exactly is the error on? I don't see how this line is indexing anything:


	local room = mud.room_info ()


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Aiseant   (33 posts)  [Biography] bio
Date Reply #17 on Mon 11 Apr 2011 01:51 PM (UTC)

Amended on Mon 11 Apr 2011 03:14 PM (UTC) by Aiseant

Message
Nick Gammon said:

Which line exactly is the error on? I don't see how this line is indexing anything:


	local room = mud.room_info ()




Ya, this doesn't return error, but as soon I try to use the "room", nil value blabla
For instance, got this local room = mud.room_info () in the beginning and player= room.first_person; few lines after.

player= room.first_person; returns the attempt to index local "room" (nil value)

note: my modified L_room_info does define a first_person attribute to the room

edit : I will look if I cannot do what I wanted directly with L_players_in_room
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #18 on Mon 11 Apr 2011 11:15 PM (UTC)
Message
My code returns nil if the current character is not in a room:


static int L_room_info (lua_State *L)
{
  CHAR_DATA * ch = L_getchar (L); /* get character pointer */
  ROOM_INDEX_DATA * room = ch->in_room;  /* which room s/he is in */
  EXIT_DATA * pexit;
  
  if (lua_isnumber (L, 1))
    room = get_room_index( check_vnum (L) );
 
  if (room == NULL) 
    return 0;  /* oops - not in room or specified room does not exist */


So you need to look into whether ch->in_room is NULL or not. Maybe use gdb to get to the bottom of it?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


63,935 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]