Jump to content

Recommended Posts

The component in question is attached and is being added to world_network post init. thanks in advance for any help.

 

edit: didnt hit attach file. oops.SuperTeleporter.lua

 

http://pastebin.com/SqT9BNv0

im kind of an idiot and put the log in lua.. xD

 

edit: derp a quick search would've done me good.
https://github.com/nsimplex/wicker/blob/master/kernel_extensions/dst_abstraction/netvars.lua

Edited by Kam297

I should really post some proper documentation on wicker. I started writing it some time ago, but there's still a reasonable amount to cover.

Either way, yes, the standard netvar types are not imported into wicker environments by default. The custom derivative types (NetBool, NetShort, NetUShort, NetByte, NetUByte, NetUByteArray, NetEntity, etc.) are, following a strict naming convention ("Net" followed by the capitalised type name; for integral types or arrays of integral types, if that name is preceded by "U", the variable is unsigned, otherwise it's signed; all integral and array of integral netvar types have both signed and unsigned versions, even those where the game itself doesn't provide both versions). The only netvar type which isn't wrapped is net_hash.

You can access the value of these wrapped netvars via ".value" or ".local_value", i.e.:

local var = NetShort(inst, "iamastring") --// Note it's 'inst', not 'inst.GUID'.--// New network value. Only broadcasts if host.var.value = 2--// Does not broadcast. Equivalent to var:set_local(3) for unwrapped netvars.var.local_value = 3--// Forces a network sync (if host), even if the value didn't change.var:ForceSync(4)print( var.value ) --// prints "4"print( var.local_value ) --// prints "4". Accessing (i.e., getting) var.local_value is always the same as accessing var.value--// The constructor does **not** take a third parameter. Instead do this:var:AddOnDirtyFn(some_callback)var:AddOnDirtyFn(some_other_callback_which_will_run_right_after_the_first_one)--[[/*-- When 'var' becomes dirty, the callbacks will be called receiving the 'inst' as their first parameter and the netvar itself as the second parameter.--*/]]
However, you can access global variables within a wicker environment as such:

local var = _G.net_bool(inst.GUID, "iamastring")
or, equivalently, as

local var = GLOBAL.net_bool(inst.GUID, "iamastring")
Furthermore, you can put this at the top of the file:

BindGlobal()
which allows transparent access to global variables whilst still remaining in a wicker environment. For a file with "BindGlobal()" on top, accessing a variable named "qux", as in

print(qux)
will obey the following lookup rules (in order of decreasing priority):
  • If there is a local variable named "qux", that is the value referenced;
  • If there is a variable in the file's environment (which includes wicker's standard variables) named "qux", that is the value referenced;
  • If there is a global variable named "qux", that is the value referenced (and if there isn't, no error is raised, unlike "_G.qux");
  • nil.
EDIT: However, I did post some documentation for the DST abstraction parts of wicker. You can find it here. Netvars and RPCs are precisely the two major topics still missing, though. Edited by simplex
Furthermore, you can put this at the top of the file: ? 1 BindGlobal() which allows transparent access to global variables whilst still remaining in a wicker environment.
 

oh fantastic, so I can be as lazy or as in dept as I want here.

Your helpfulness knows no bounds.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...