Serious Sam Classics: Revolution

Serious Sam Classics: Revolution

Adamasterr Shakikg 2016 年 8 月 28 日 上午 3:30
samrev scripting documentation
Hello,

am I doing something wrong or have you not implemented everything you have in the documentation at http://docs.samrev.com/en/latest/scripting.html yet?
I have this code example:
print(Entities.GetCount()) //that's ok but print(Draw.GetScreenWidth()) //says I'm calling Null
If my presumption is correct, which script handles are ready to use right now?
< >
正在显示第 1 - 4 条,共 4 条留言
Melissa 2016 年 8 月 28 日 上午 3:54 
Draw is a handle that works, but probably not in the context you're using it in. I assume you're using this script in a Script entity. In this context, I don't believe there is a functioning Draw handle. (I could be wrong, but Bromvlieg should be able to confirm or deny this.)

What I do know is, in the context of addons (Scripts/Addons/*/cl_init.bs) you can make custom HUD elements with the Draw handle.

For example, this should work as an addon: (try it in the script entity too, though I'm not 100% certain whether it works)

// "Draw" handle passed here as "draw" local function paint(draw){ draw.Text("Hello, world!", 100, 100, 1, 0xFF0000FF) } RegisterHook("OnHUDDraw", paint)
Adamasterr Shakikg 2016 年 8 月 28 日 上午 7:10 
I was using it in the Script entity, sorry for not specifying it.

When I ran your script I saw no text on screen so I added a line to print the width

local function paint(draw){ draw.Text("Hello, world!", 100, 100, 1, 0xFF0000AA) print(draw.GetScreenWidth()) } RegisterHook("OnHUDDraw", paint)

It kept printing to the console, I then changed it to heigth and it was printing both, so I know that now there are 3 "hooks registered", 1st shows me nothing, 2nd shows me nothing and prints width and 3rd shows nothing and prints height.

What is "OnHUDDraw" and what other identificators/strings can I replace it with?
Is it possible to unregister/delete hook after it does what it does just once?
Am I able to pass the handles without calling RegisterHook() ?
Melissa 2016 年 8 月 28 日 上午 7:19 
I suppose drawing only works properly in addons then. Are you stopping/starting the script from editor? Not sure why it keeps the registered hooks in memory then, that's probably a bug.

Here's a list of hooks that are currently being called: (I haven't tested them myself though, also I'm pretty sure not all of these will work in Script entity, but rather in Addons)
  • OnInitialize()
  • OnMapStart()
  • OnMapEnd()
  • OnRoundStart()
  • OnRoundEnd()
  • OnUpdate()
  • OnPlayerConnect(int client_index, string client_name, uint64 client_steamid, string client_sentpassword)
  • OnPlayerDisconnect(PlayerHandle player)
  • OnPlayerDeath(PlayerHandle player)
  • OnPlayerSpawn(PlayerHandle player)
  • OnPlayerInit(PlayerHandle player)
  • OnHUDDraw(DrawHandle draw)
  • OnChat(int client_index, string message)
I'll also link this thread to Bromvlieg, he'll be able to give you more info.
最后由 Melissa 编辑于; 2016 年 8 月 28 日 上午 7:20
Adamasterr Shakikg 2016 年 8 月 28 日 上午 7:28 
I am doing everything within the editor, starting the script with a trigger.

Thank you, I will try messing around in the Addons folder now.
< >
正在显示第 1 - 4 条,共 4 条留言
每页显示数: 1530 50