Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ Lua ➜ 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 page


Pages: 1  2 

Posted by Aiseant   (33 posts)  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
Top

Posted by Nick Gammon   Australia  (23,140 posts)  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
Top

Posted by Aiseant   (33 posts)  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
Top

Posted by Nick Gammon   Australia  (23,140 posts)  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
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.


71,944 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 page

Go to topic:           Search the forum


[Go to top] top

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