Argument not being accepted by function

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Argument not being accepted by function

James C. Wilson
Hi all,

I'm having a bit of difficulty writing up a function to simplify image sequences and make them playable by one line: playVid(stairDoorOpenLeft, 20, 4, 333, 400, 15)
  The first argument specifies the folder the images are in, then the number of frames, then the cube face, the x/y coords, and the framerate. Trouble is when I run it it tells me this : attempt to concatenate local folder, a nil value

The function is below...Anysuggestions?
 
Thanks, James


function playVid(folder, frameCnt, face, locX, locY, framerate)

local animpos = 0
local vid = patch { face = face, x = locX, y = locY, image =  " " .. folder .. "/" .. animpos .. ".jpg"  }


  pipmak.schedule(
    framerate,
    function(now, last)
      animpos = animpos + 1
      if animpos > frameCnt then animpos = 0 end
      vid:setimage ( " " .. folder .. "/" .. animpos .. ".jpg" )
      return framerate
    end
  )
end
Reply | Threaded
Open this post in threaded view
|

Re: Argument not being accepted by function

cwalther
Administrator
> I'm having a bit of difficulty writing up a function to simplify image sequences and make them playable by one line: playVid(stairDoorOpenLeft, 20, 4, 333, 400, 15)
>   The first argument specifies the folder the images are in, then the number of frames, then the cube face, the x/y coords, and the framerate. Trouble is when I run it it tells me this : attempt to concatenate local folder, a nil value

The function looks OK in that regard, so if the above is your actual call, then probably the variable stairDoorOpenLeft actually has value nil - have you checked that? Or possibly you didn't mean it to be a variable, but a string literal, i.e. you forgot the quotation marks?

 -Christian

> function playVid(folder, frameCnt, face, locX, locY, framerate)
>
> local animpos = 0
> local vid = patch { face = face, x = locX, y = locY, image =  " " .. folder .. "/" .. animpos .. ".jpg"  }
>
>
>   pipmak.schedule(
>     framerate,
>     function(now, last)
>       animpos = animpos + 1
>       if animpos > frameCnt then animpos = 0 end
>       vid:setimage ( " " .. folder .. "/" .. animpos .. ".jpg" )
>       return framerate
>     end
>   )
> end




Reply | Threaded
Open this post in threaded view
|

Re: Argument not being accepted by function

James C. Wilson
Hi,

Is this what you meant by quotation marks?
playVid("stairDoorOpenLeft", 20, 4, 333, 400, 15)

If so, there's apparently another problem. Now pipmak gives another error message, but this time it says that "global  patch" is a "nil value", which is odd because it's obviously nothing of the sort, it's just a regular patch object, as you can see in my function, not a global.

Thanks,
 James

--- On Mon, 10/10/11, Christian Walther <[hidden email]> wrote:

From: Christian Walther <[hidden email]>
Subject: Re: Argument not being accepted by function
To: "Content creation for the Pipmak Game Engine" <[hidden email]>
Date: Monday, October 10, 2011, 3:23 PM

> I'm having a bit of difficulty writing up a function to simplify image sequences and make them playable by one line: playVid(stairDoorOpenLeft, 20, 4, 333, 400, 15)
>   The first argument specifies the folder the images are in, then the number of frames, then the cube face, the x/y coords, and the framerate. Trouble is when I run it it tells me this : attempt to concatenate local folder, a nil value

The function looks OK in that regard, so if the above is your actual call, then probably the variable stairDoorOpenLeft actually has value nil - have you checked that? Or possibly you didn't mean it to be a variable, but a string literal, i.e. you forgot the quotation marks?

-Christian

> function playVid(folder, frameCnt, face, locX, locY, framerate)
>
> local animpos = 0
> local vid = patch { face = face, x = locX, y = locY, image =  " " .. folder .. "/" .. animpos .. ".jpg"  }
>
>
>   pipmak.schedule(
>     framerate,
>     function(now, last)
>       animpos = animpos + 1
>       if animpos > frameCnt then animpos = 0 end
>       vid:setimage ( " " .. folder .. "/" .. animpos .. ".jpg" )
>       return framerate
>     end
>   )
> end



------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users
Reply | Threaded
Open this post in threaded view
|

Re: Argument not being accepted by function

cwalther
Administrator
> Is this what you meant by quotation marks?
> playVid("stairDoorOpenLeft", 20, 4, 333, 400, 15)

Yes (but I don't know if it's what *you* meant).

> If so, there's apparently another problem. Now pipmak gives another error message, but this time it says that "global  patch" is a "nil value", which is odd because it's obviously nothing of the sort, it's just a regular patch object, as you can see in my function, not a global.

Then you're calling the function at another time than node loading, and the error message is completely correct. It's not talking about any patch object, it's talking about the global function "patch" that you're trying to call here. The configuration functions like "patch" are only available at node loading time and are nil otherwise. You shouldn't think of them as functions, but as declarative statements. See <http://thread.gmane.org/gmane.games.devel.pipmak.user/721/focus=722>.

You currently can't create new patches while a node is running, all patches you need must already be present in the original node configuration.

(Calling this same playVid() function at node loading time however isn't a good idea either, you shouldn't schedule timers or perform other actions at node loading time - it will currently work, but in a future version the node description may also be loaded at other times than when you enter the node it, e.g. to populate a project map. You must separate the creation of the patch and the starting of the animation.)

 -Christian

Reply | Threaded
Open this post in threaded view
|

Re: Argument not being accepted by function

James C. Wilson
Oh, right, I forgot about patches being declarative..Sorry about that.

  On another note, is there a way to chain other calls to run right after my animation is complete other then seperatly timing them with pipmak.schedule?

Thanks,
   James

--- On Tue, 10/11/11, Christian Walther <[hidden email]> wrote:

From: Christian Walther <[hidden email]>
Subject: Re: Argument not being accepted by function
To: "Content creation for the Pipmak Game Engine" <[hidden email]>
Date: Tuesday, October 11, 2011, 3:28 PM

> Is this what you meant by quotation marks?
> playVid("stairDoorOpenLeft", 20, 4, 333, 400, 15)

Yes (but I don't know if it's what *you* meant).

> If so, there's apparently another problem. Now pipmak gives another error message, but this time it says that "global  patch" is a "nil value", which is odd because it's obviously nothing of the sort, it's just a regular patch object, as you can see in my function, not a global.

Then you're calling the function at another time than node loading, and the error message is completely correct. It's not talking about any patch object, it's talking about the global function "patch" that you're trying to call here. The configuration functions like "patch" are only available at node loading time and are nil otherwise. You shouldn't think of them as functions, but as declarative statements. See <http://thread.gmane.org/gmane.games.devel.pipmak.user/721/focus=722>.

You currently can't create new patches while a node is running, all patches you need must already be present in the original node configuration.

(Calling this same playVid() function at node loading time however isn't a good idea either, you shouldn't schedule timers or perform other actions at node loading time - it will currently work, but in a future version the node description may also be loaded at other times than when you enter the node it, e.g. to populate a project map. You must separate the creation of the patch and the starting of the animation.)

-Christian
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users
Reply | Threaded
Open this post in threaded view
|

Re: Argument not being accepted by function

cwalther
Administrator
>   On another note, is there a way to chain other calls to run right after my animation is complete other then seperatly timing them with pipmak.schedule?

There's no way around pipmak.schedule, but instead of timing them from the beginning, you could also trigger your additional calls from the scheduled function that displays the last frame of your animation.

 -Christian



Reply | Threaded
Open this post in threaded view
|

Possible bug in system node -11

James C. Wilson
There may or may not be a bug in pipmak's system nodes-- specifically node -11.
  In a few nodes in my project, there are several sounds which, while declared in node.lua are not yet placed in the project folder. Whenever I enter one of these nodes, pipmak prints the expected "The system cannot find the file specified". However, about 3 times out of 5, it also prints:
"Error running text editor keydown handler: -11/node.lua:76: calling 'selection' on bad self (texteditor expected, got userdata)
stack traceback:
  [C]: in function 'selection'
  -11/node.lua:76: in function <-11/node.lua:33>"

I don't know if this is just somehow due to me not yet including the sound files or whether there is something else at work...

Reply | Threaded
Open this post in threaded view
|

Re: Possible bug in system node -11

cwalther
Administrator
> There may or may not be a bug in pipmak's system nodes-- specifically node -11.
>   In a few nodes in my project, there are several sounds which, while declared in node.lua are not yet placed in the project folder. Whenever I enter one of these nodes, pipmak prints the expected "The system cannot find the file specified". However, about 3 times out of 5, it also prints:
> "Error running text editor keydown handler: -11/node.lua:76: calling 'selection' on bad self (texteditor expected, got userdata)
> stack traceback:
>   [C]: in function 'selection'
>   -11/node.lua:76: in function <-11/node.lua:33>"

Node -11 is the Lua command line. I think what you're seeing is what was fixed in revision 211 <http://pipmak.svn.sourceforge.net/viewvc/pipmak?view=revision&revision=211>. I'm not sure about the details without more information about your situation, but one way to provoke that error message (before r211) is as follows: You have node A open, and the Lua command line above it. You do pipmak.gotonode(B). The node.lua of node B has an error that prevents the node from loading (a missing sound file should not be sufficient for that). Node A has already been left, but node B could not be entered, which means that the Lua command line (node -11) is now the bottommost node in the node stack, i.e. the background node. (*) Now you do pipmak.gotonode(C). This leaves node -11 and enters node C, and the former is what triggers the error message, since node -11 is designed to work as an overlay, not as a background node that can be left in that way, so it is confused by that.

Maybe you can align this explanation with your experience somehow, and if not, at least find a reliable way of reproducing the error. You should easily be able to recognize situation (*) by the fact that the Lua command line appears on top of a gray striped background rather than on top of one of your nodes.

 -Christian

Reply | Threaded
Open this post in threaded view
|

Re: Possible bug in system node -11

James C. Wilson
Yeah, that sounds exactly right. Thanks for clarifying!
  One other thing: I'm not certain how the messaging system works. How do I tell pipmak which node to contact? If I just do "34:message(lightFlicker)" or "34:getid():message(lightflicker)" pipmak says "unexpected symbol near 34", both times.
  I'm probably making a stupid mistake but I don't know what it is.

Thanks,
  James


--- On Thu, 10/20/11, Christian Walther <[hidden email]> wrote:

From: Christian Walther <[hidden email]>
Subject: Re: Possible bug in system node -11
To: "Content creation for the Pipmak Game Engine" <[hidden email]>
Date: Thursday, October 20, 2011, 4:13 PM

> There may or may not be a bug in pipmak's system nodes-- specifically node -11.
>   In a few nodes in my project, there are several sounds which, while declared in node.lua are not yet placed in the project folder. Whenever I enter one of these nodes, pipmak prints the expected "The system cannot find the file specified". However, about 3 times out of 5, it also prints:
> "Error running text editor keydown handler: -11/node.lua:76: calling 'selection' on bad self (texteditor expected, got userdata)
> stack traceback:
>   [C]: in function 'selection'
>   -11/node.lua:76: in function <-11/node.lua:33>"

Node -11 is the Lua command line. I think what you're seeing is what was fixed in revision 211 <http://pipmak.svn.sourceforge.net/viewvc/pipmak?view=revision&revision=211>. I'm not sure about the details without more information about your situation, but one way to provoke that error message (before r211) is as follows: You have node A open, and the Lua command line above it. You do pipmak.gotonode(B). The node.lua of node B has an error that prevents the node from loading (a missing sound file should not be sufficient for that). Node A has already been left, but node B could not be entered, which means that the Lua command line (node -11) is now the bottommost node in the node stack, i.e. the background node. (*) Now you do pipmak.gotonode(C). This leaves node -11 and enters node C, and the former is what triggers the error message, since node -11 is designed to work as an overlay, not as a background node that can be left in that way, so it is confused by that.

Maybe you can align this explanation with your experience somehow, and if not, at least find a reliable way of reproducing the error. You should easily be able to recognize situation (*) by the fact that the Lua command line appears on top of a gray striped background rather than on top of one of your nodes.

-Christian
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users
Reply | Threaded
Open this post in threaded view
|

Re: Messaging (was: Possible bug in system node -11)

cwalther
Administrator
>   One other thing: I'm not certain how the messaging system works. How do I tell pipmak which node to contact? If I just do "34:message(lightFlicker)" or "34:getid():message(lightflicker)" pipmak says "unexpected symbol near 34", both times.

34 is a number and doesn't have a "message" method (numbers don't have methods at all, which explains the error message). What you want is the node object that represents node 34. How to obtain that depends on how you displayed node 34 - see section 3.6.3 "Node Objects" in the manual. (If node 34 is not being displayed, no node object for it exists and you can't message it.)

 -Christian

Reply | Threaded
Open this post in threaded view
|

Re: Messaging (was: Possible bug in system node -11)

James C. Wilson
Is this what you meant?
Including this in node 34:
onenternode(function() medCtr_recordsRoom = pipmak.thisnode() end)

And the message to 34:
medCtr_recordsRoom:message("lightFlicker")

If I do that pipmak says medCtr_recordsRoom has no "message" function.

Thanks,
  James
 


--- On Sat, 10/22/11, Christian Walther <[hidden email]> wrote:

From: Christian Walther <[hidden email]>
Subject: Re: Messaging (was: Possible bug in system node -11)
To: "Content creation for the Pipmak Game Engine" <[hidden email]>
Date: Saturday, October 22, 2011, 6:38 AM

>   One other thing: I'm not certain how the messaging system works. How do I tell pipmak which node to contact? If I just do "34:message(lightFlicker)" or "34:getid():message(lightflicker)" pipmak says "unexpected symbol near 34", both times.

34 is a number and doesn't have a "message" method (numbers don't have methods at all, which explains the error message). What you want is the node object that represents node 34. How to obtain that depends on how you displayed node 34 - see section 3.6.3 "Node Objects" in the manual. (If node 34 is not being displayed, no node object for it exists and you can't message it.)

-Christian
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users
Reply | Threaded
Open this post in threaded view
|

Re: Messaging

cwalther
Administrator
> Is this what you meant?
> Including this in node 34:
> onenternode(function() medCtr_recordsRoom = pipmak.thisnode() end)
>
> And the message to 34:
> medCtr_recordsRoom:message("lightFlicker")
>
> If I do that pipmak says medCtr_recordsRoom has no "message" function.

That should work. Can you give more details about your situation? Is node 34 the background node and the other node an overlay, or the other way around, or both overlays? At what time (in response to what) are you calling the message method?

 -Christian

Reply | Threaded
Open this post in threaded view
|

Re: Messaging

James C. Wilson
Both are background nodes. The point is when a hotspot is clicked in one node, to move to node 34 and execute a function(in this case, panning to a different angle as a light flickers on). Would create a problem? The way you phrased your question leads me to belive the messaging system can only be used for nodes visible at the same time...is that so?

Thanks,
 James

--- On Fri, 10/28/11, Christian Walther <[hidden email]> wrote:

From: Christian Walther <[hidden email]>
Subject: Re: Messaging
To: "Content creation for the Pipmak Game Engine" <[hidden email]>
Date: Friday, October 28, 2011, 6:49 AM

> Is this what you meant?
> Including this in node 34:
> onenternode(function() medCtr_recordsRoom = pipmak.thisnode() end)
>
> And the message to 34:
> medCtr_recordsRoom:message("lightFlicker")
>
> If I do that pipmak says medCtr_recordsRoom has no "message" function.

That should work. Can you give more details about your situation? Is node 34 the background node and the other node an overlay, or the other way around, or both overlays? At what time (in response to what) are you calling the message method?

-Christian
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users
Reply | Threaded
Open this post in threaded view
|

Re: Messaging

cwalther
Administrator
> The way you phrased your question leads me to belive the messaging system can only be used for nodes visible at the same time...is that so?

Yes. Is the documentation not clear enough about that? How could it be improved?

> The point is when a hotspot is clicked in one node, to move to node 34 and execute a function(in this case, panning to a different angle as a light flickers on).

There is no need for inter-node messaging for that. You can execute that function in an enternode handler of node 34, and if it shouldn't be done every time you enter the node, you decide whether or not based on some global setting, either an entry in the "state" table if it should be part of saved games or a plain global variable if it shouldn't, that you can set from the previous node.

 -Christian

Reply | Threaded
Open this post in threaded view
|

Re: Messaging

James C. Wilson
Oh, thanks. I personally didn't get that from the manual..Here's the original section:

3.6.2 Inter-Node Communication
Often some way of communication between one displayed node and another is needed.
The obvious naive way of achieving this would be defining a global function in node A
and calling it from node B. However, this doesn’t work as expected in many cases: Lua
doesn’t care in which file a function was defined. Even if it was defined in the node.lua file
of node A, calling the function from node B will make the code run in node B. Anything
it does that makes an implicit assumption about the “current node” will affect node B, not
node A.
To solve this problem, a messaging system is provided. By including
messages {
messagename = handler,
...
}
in its node.lua, a node can define a set of messages to which it responds. Each entry in
the messages table links a string messagename to a handler function that will be called
when the corresponding message is received. The message handler function then runs in
the node where it was defined, not in the one who sent the message. To send a message to a node, use its message method.

..And here's what I feel would be a bit clearer:

3.6.2 Inter-Node Communication
Often some way of communication between two or more simultaneously displayed nodes is needed.


How does that look?

Thanks,
  James

--- On Sat, 10/29/11, Christian Walther <[hidden email]> wrote:

From: Christian Walther <[hidden email]>
Subject: Re: Messaging
To: "Content creation for the Pipmak Game Engine" <[hidden email]>
Date: Saturday, October 29, 2011, 5:19 AM

> The way you phrased your question leads me to belive the messaging system can only be used for nodes visible at the same time...is that so?

Yes. Is the documentation not clear enough about that? How could it be improved?

> The point is when a hotspot is clicked in one node, to move to node 34 and execute a function(in this case, panning to a different angle as a light flickers on).

There is no need for inter-node messaging for that. You can execute that function in an enternode handler of node 34, and if it shouldn't be done every time you enter the node, you decide whether or not based on some global setting, either an entry in the "state" table if it should be part of saved games or a plain global variable if it shouldn't, that you can set from the previous node.

-Christian
------------------------------------------------------------------------------
Get your Android app more play: Bring it to the BlackBerry PlayBook
in minutes. BlackBerry App World™ now supports Android™ Apps
for the BlackBerry&reg; PlayBook™. Discover just how easy and simple
it is! http://p.sf.net/sfu/android-dev2dev
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users
Reply | Threaded
Open this post in threaded view
|

Re: Messaging

cwalther
Administrator
> ..And here's what I feel would be a bit clearer:
>
> 3.6.2 Inter-Node Communication
> Often some way of communication between two or more simultaneously displayed nodes is needed.
>
> How does that look?

Looks good - changed, thanks! http://pipmak.svn.sourceforge.net/viewvc/pipmak?view=revision&revision=231

 -Christian