Hi! Welcome to the forum for Platinum Arts Sandbox Free 3D Game Maker. I currently have the forums locked as I am attempting to properly update them.

In the meantime please join the new Discord Server!

If you have any questions please e-mail me through the Platinum Arts website.

[C/C++ Source issue]Making a chat command...

Having issues not related to a specific Sandbox game mode? Get help here!
Please also read the rules for support when posting support requests.
Failure to comply with the forum rules may result in your topic being locked without resolution.
Locked
User avatar
Popinman32
Member
Member
Posts: 10
Joined: January 31st, 2010, 9:40 am
Name: Jean-Claude
IRC Username: Popinman32
Location: -Undefined-
Contact:

[C/C++ Source issue]Making a chat command...

Post by Popinman32 »

I need enough info to create a chat command, because I'm trying to add lua in addition to cubescript.

I'm aiming for something like "/lua {source}".

Don't give me *censored* about how you don't know lua. :P
Lua's source is C, so I know most of the developers can help me out here.

Why lua?
I like it, and I already have it so saved maps get a lua file, and these files are loaded with the map.

If you can't give info on making a chat command, I have a different question:
Is there a way that cubescript can be used in-game with a chat command and if so where is the source of this in-game chat method?
Last edited by Popinman32 on February 15th, 2011, 2:59 pm, edited 2 times in total.
Working on Lua in the sandbox...
print is working in-game...
Onload lua files are working...
Chat commands... eh...
Hirato
Developer
Developer
Posts: 689
Joined: May 30th, 2009, 1:23 pm
IRC Username: hirato

Re: [C/C++ Source issue]Making a chat command...

Post by Hirato »

Lua before being compiled is C, so I know most of the developers can help me out here.

Code: Select all

function factorial(n)
  if n == 0 then
    return 1
  else
    return n * factorial(n - 1)
  end
end
Sure looks like C/C++ to me
no doubt about it, definitely C/C++
there's no mistaking that it's C/C++
:roll:

I also found this on wikipedia

Code: Select all

do
  local oldprint = print   -- Store current print function as oldprint
  function print(s)        -- Redefine print function
    if s == "foo" then
      oldprint("bar")
    else 
      oldprint(s) 
    end
  end
end
At any rate you should do something similar. This is pure speculation, but you'll probably want to expose conoutf to lua, and override print with it.
I really don't know a thing about lua (and frankly I really dislike its syntax), so you're by all means on your own.
Is there a way that cubescript can be used in-game and if so where is the source of this in-game method?
Depends on the game, they all do things differently.
For example, the RPG relies on everything being defined on a per game basis (typically somewhere in data/rpg/games/), while the FPS relies on everything being done on a per map basis. Village is a shining example of doing things the FPS way. If you have a copy of sauer handy, you should check out Lost as well.
This is not a url, clicking it is pointless
User avatar
Popinman32
Member
Member
Posts: 10
Joined: January 31st, 2010, 9:40 am
Name: Jean-Claude
IRC Username: Popinman32
Location: -Undefined-
Contact:

Re: [C/C++ Source issue]Making a chat command...

Post by Popinman32 »

Clarified the post...

CHAT COMMAND for cubescript?

Lua's SOURCE is C/C++
Working on Lua in the sandbox...
print is working in-game...
Onload lua files are working...
Chat commands... eh...
arcones
Support Team
Support Team
Posts: 2734
Joined: January 13th, 2010, 12:42 pm
Name: Timothy
IRC Username: I use Steam
Location: Looking over your shoulder...
Contact:

Re: [C/C++ Source issue]Making a chat command...

Post by arcones »

Cube 2 at one point had an implementation of Chat Commands in MP games. They might actually have some of that work on the wiki, but that's doubtful as I couldn't find it when I checked.
Image
Want a user bar like this one? PM Leo!
Hirato
Developer
Developer
Posts: 689
Joined: May 30th, 2009, 1:23 pm
IRC Username: hirato

Re: [C/C++ Source issue]Making a chat command...

Post by Hirato »

Popinman32 wrote:Clarified the post...

CHAT COMMAND for cubescript?

Lua's SOURCE is C/C++
The built in console does 3 things, in order.
First it acts if "action" is defined, this requires that you explicitly define the input command (ie, team chat).
The second act is invoked when a / is present which causes it to the executed.
Other wise, everything is sent to game::toserver; the FPS game uses this to send chat.

FPS

Code: Select all

void toserver(char *text) { conoutf(CON_CHAT, "<%s>\f0 %s", colorname(player1), text); addmsg(N_TEXT, "rcis", player1, CHAT_TALK, text); }
Everything Else

Code: Select all

void toserver(char *text) {}
This is not a url, clicking it is pointless
Locked