import re
from compiler import *
from header_common import reg0 as reg0
register_plugin()
cur_reg = 64
def str_print(s, *argl):
global cur_reg
if s == "":
return
p = re.compiler"{?([:$][a-zA-Z_]\w*)\b}?")
cur_reg = 64
assigns = []
def replacer(match):
global cur_reg
val = match.group(1)
cur_reg -= 1
assigns.append( (assign, reg0+cur_reg, val) )
return "{reg" + str(cur_reg) + "}"
s = re.sub(p, replacer, s)
if s[0] != "@":
s = "@" + s
return assigns + [(display_message, s)]
extend_syntax(str_print)
Excellent Didn't expect it to be in rgl_config..
Here is some simple code that reproduces the errors:
plant_props = {}
for inst in game.propInstI(2, 5) do -- propInstI([object_id], [object_type])
table.insert(plant_props, inst)
end
v1 = vector3.new()
v2 = vector3.new()
v2.x = 1
print("vec: " .. tostring( v1:dist(v2) )) --prints 1, good
p1 = game.pos.new().o
p2 = game.pos.new().o
p2.x = 1
print("pos: " .. tostring( p1:dist(p2) )) --prints 0, not good
r1 = game.preg[0].o
r2 = game.preg[1].o
print("reg: " .. tostring( r1:dist(r2) )) --error (dist is nil)
for inst in game.propInstI(i, game.const.somt_flora) do
table.insert(plant_props, inst)
end
local origin = game.preg[0].o
if not game.position_is_behind_position(1, 0) and origin:dist(game.preg[1].o) > 2 then
...
--b.lua
a = 3
--main.lua
a = 5
dofile(b.lua)
->a=3
-------BasicState.lua--------
BasicState = {
new = function()
local obj = {} -- you can also init some stuff in here if you dont want them in BasicState itself
setmetatable(obj, BasicState)
return obj
end,
begin = function()
error("Did not overwrite default begin()")
--or maybe some default code?
end,
}
----------IdleState.lua-----------
IdleState = {
new = function()
local obj = State.new()
setmetatable(obj, IdleState)
return obj
end,
begin = function()
....
}
setmetatable(IdleState, BasicState) --so the table returned by idlestate.new has metatable IdleState, which has metatable BasicState. This is the lua way to do inheritance
----------main.lua------------
require("BasicState")
require("IdleState")
globalStates = {
idle = IdleState.new(),
...
}
selectedState = nil
function setState(state)
selectedState = globalStates[state]
end
function exec(funcName, ...)
if selectedState then --not nil
selectedState[funcName](...)
end
end
----or----
function exec(stateName, funcName, ...)
if globalStates[stateName] and globalStates[stateName][funcName] then
globalStates[stateName][funcName](...)
end
end
("wse_console_command_received", [ #this is a script that WSE adds
(store_script_param, ":command_type", 1),
(str_equals, s0, "@reloadMain"),
(lua_push_str, "@main.lua"),
(lua_call, "@dofile", 1), #one param, the string we pushed
(set_trigger_result, 1),
]),
[lua]
disable_game_const_warnings = 1
funcTable = {
function(...) ... end, --remember this is [1] in lua
function(...) ... end,
...
}
function call_index(index, ...)
funcTable[index](...)
end
SupaNinjaMan said:
[Bcw]Btm_Earendil said:
55th_Col_Armbresker said:
I am familiar with the codebase but AFAIK there is no performance benefit in installing WSE. At least not if your mods don't make use of the script extensions.55th_Col_Armbresker said:
Was about to ask if it works in MS. Weird...Bridge_Troll said:
Bridge_Troll said:
Bridge_Troll said: